Skip to content

smite: validate negotiated features and channel types in accept_channel oracle - #209

Draft
NishantBansal2003 wants to merge 11 commits into
lnfuzz:masterfrom
NishantBansal2003:accept-chan-feature-oracle
Draft

smite: validate negotiated features and channel types in accept_channel oracle#209
NishantBansal2003 wants to merge 11 commits into
lnfuzz:masterfrom
NishantBansal2003:accept-chan-feature-oracle

Conversation

@NishantBansal2003

@NishantBansal2003 NishantBansal2003 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Depends-on: #192
Depends-on: #186 (added some changes to it, which will be removed once that PR is finalized)
Opening this as a draft since it depends on two PRs. Otherwise, the changes are ready for review.

I tried to add all the definitive checks for open_channel and accept_channel mentioned in the BOLT 2, including ones that aren't currently possible, such as option_dual_fund, since we haven't negotiated it. I think having parity with the BOLTs is good, especially for the future when we extend smite to support more protocols

Some more missing oracles that I will add in follow-up PR are:

open_channel

  • chain_hash != regtest
  • channel_reserve_satoshis >= funding_satoshis
  • dust_limit_satoshis > 10_000 sat
  • feerate_per_kw < 253 for non 0FC channels

accept_channel

  • dust_limit_satoshis > 10_000 sat
  • htlc_minimum_msat > max_htlc_value_in_flight_msat
  • htlc_minimum_msat > open_channel.funding_satoshis
  • to_self_delay < 144
  • max_accepted_htlcs == 0
  • pubkey match any pubkeys from open_channel and accept_channel
  • per_commitment_point should not be reused

NishantBansal2003 and others added 11 commits August 19, 2026 13:55
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
BOLT-02 specifies sender requirements for shutdown scripts. They must be
witness v0 (P2WPKH, P2WSH) or following features must be negotiated:

* `option_shutdown_anysegwit`: witness v1-v16 with a 2..=40 byte program
* `option_simple_close`: `OP_RETURN` with a single minimal data push of
  6..=80 bytes

Receivers may accept legacy scripts (P2PKH, P2SH), but we reject them
since we're judging the sender's output.

This applies to the `shutdown` and `closing_complete` messages, and the
`upfront_shutdown_script` TLV in the `open_channel`, `open_channel2`,
`accept_channel` and `accept_channel2` messages.

This commit adds a helper to catch targets that don't comply with the
spec.
The `accept_channel` oracle needs to verify that `channel_type`
uses the smallest possible bitmap and represents a defined
channel type. Keeping `ChannelTypeVariant` in `bolt::types`
gives the oracle a canonical set of channel types to validate
against and avoids duplicating the definition across modules.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
We strip certain feature bits during setup to exercise only the single
funded flow, so the features stored here are what both sides have
agreed to continue with, the negotiated feature set, not just the
target's advertised features.

This prepares for oracle validation that will use negotiated features to
validate field constraints. If the target didn't disconnect after our init,
that confirms it also conforms to our negotiated features, not its original
advertised feature set.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
This is useful when comparing features in message fields
against negotiated features. For eg., comparing channel_type
in open_channel and accept_channel to ensure they match the
features negotiated during setup.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants