Skip to content

smite: add is_standard_shutdown_script helper - #186

Open
ekzyis wants to merge 1 commit into
lnfuzz:masterfrom
ekzyis:is-standard-shutdown-script
Open

smite: add is_standard_shutdown_script helper#186
ekzyis wants to merge 1 commit into
lnfuzz:masterfrom
ekzyis:is-standard-shutdown-script

Conversation

@ekzyis

@ekzyis ekzyis commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Depends on #192.

From the commit message:

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 data push of 6..=80
    bytes

Legacy scripts (P2PKH, P2SH) may be accepted for backward compatibility.

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.

As per the note I added to the code, I'm not sure if the fuzzer should also reject legacy scripts, since a target must not send them. update: decided to reject them, see discussion

I haven't wired this into existing code or #163 yet, but I thought the introduction of the helper might be worthwile to review itself, especially considering the question wrt legacy scripts.

@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from f33051b to 22217d9 Compare August 4, 2026 11:07

@NishantBansal2003 NishantBansal2003 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I was about to add this as a follow-up to #185, but it looks like I don’t have to now

Comment thread smite/src/bolt/shutdown.rs Outdated
Comment thread smite/src/bolt/shutdown.rs Outdated
Comment thread smite/src/bolt/shutdown.rs Outdated
Comment thread smite/src/bolt/shutdown.rs Outdated
@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from 22217d9 to 220b1bf Compare August 9, 2026 12:30
Comment thread smite/src/bolt/shutdown.rs Outdated
@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from 220b1bf to 847c2f1 Compare August 9, 2026 18:00

@NishantBansal2003 NishantBansal2003 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly, it looks good. Just a few small comments. I'm not sure how this follows the merge with #192, but if it's merged before, I'll add the updated feature check there

Comment thread smite/src/bolt/shutdown.rs
Comment thread smite/src/bolt/shutdown.rs Outdated
Comment thread smite/src/bolt/shutdown.rs
Comment thread smite/src/bolt/shutdown.rs Outdated
Comment thread smite/src/bolt/shutdown.rs Outdated
@ekzyis

ekzyis commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure how this follows the merge with #192

Putting this into draft until #192 is merged, I rebased this and I addressed the feedback

@ekzyis
ekzyis marked this pull request as draft August 13, 2026 11:53
@ekzyis ekzyis mentioned this pull request Aug 20, 2026
3 tasks
@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch 2 times, most recently from dd42b6b to 63fed11 Compare August 20, 2026 15:47
@ekzyis

ekzyis commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

I rebased this PR on top of #192 since I don't expect it to change much. I didn't address all feedback yet, see #186 (comment) and TODO in the code + commit message.


Update: rebased again on top of #192 (ACK 40f7aa8)

@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from 63fed11 to 6b8d367 Compare August 21, 2026 15:16
@ekzyis
ekzyis marked this pull request as ready for review August 24, 2026 14:06
@ekzyis
ekzyis marked this pull request as draft August 24, 2026 14:28
@ekzyis
ekzyis marked this pull request as ready for review August 24, 2026 14:31
@ekzyis
ekzyis marked this pull request as draft August 24, 2026 14:37
@ekzyis

ekzyis commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

TODO:

@morehouse morehouse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Needs a rebase now that #192 is merged. Also would be good to include the additions from #209 before merging this.

@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from 6b8d367 to c62c850 Compare September 1, 2026 21:18
@ekzyis

ekzyis commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

c62c850: rebased on master (87ebab6), added is_acceptable_shutdown_script from #192, and updated commit message. I think is_acceptable_shutdown_script is simple and enough for our needs; no need for enum Side like we did for commitments.

f024116: fixed wrong usage of backticks in is_standard_shutdown_script documentation

@ekzyis
ekzyis marked this pull request as ready for review September 1, 2026 21:23
@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from c62c850 to f024116 Compare September 1, 2026 21:28
Comment thread smite/src/bolt/shutdown.rs
Comment thread smite/src/bolt/shutdown.rs Outdated
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

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 two helpers to catch targets that don't comply with the
spec: is_standard_shutdown_script and is_acceptable_shutdown_script.
@ekzyis
ekzyis force-pushed the is-standard-shutdown-script branch from f024116 to ab9cbad Compare September 2, 2026 22:45
@ekzyis

ekzyis commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

ab9cbad: rebased again on master (d0b2679) + updated commit message

With the new tests, I noticed I could define helpers for p2pkh, p2sh, etc., so there's less to read per test now.

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.

3 participants