Skip to content

Refactor/script templates - #138

Merged
cygnet3 merged 3 commits into
masterfrom
refactor/script_templates
Aug 11, 2026
Merged

Refactor/script templates#138
cygnet3 merged 3 commits into
masterfrom
refactor/script_templates

Conversation

@Sosthene00

Copy link
Copy Markdown
Collaborator

This PR accomplishes 2 things:

  1. it moves the scripts templates matching code in its own module, instead of having it at the end of receiving.rs
  2. it improves the existing pattern matching that was missing a few obvious checks

@Sosthene00
Sosthene00 force-pushed the refactor/script_templates branch from 7a4cf1b to 2398e3f Compare June 18, 2026 08:47
@cygnet3
cygnet3 force-pushed the refactor/script_templates branch from 0eb17cc to 2178f15 Compare June 22, 2026 12:42
Comment thread silentpayments/src/utils/receiving.rs Outdated
Comment thread silentpayments/src/utils.rs
@Sosthene00
Sosthene00 force-pushed the refactor/script_templates branch 2 times, most recently from 1b6d8f5 to 2d417f0 Compare June 23, 2026 13:13
@Sosthene00
Sosthene00 force-pushed the refactor/script_templates branch 3 times, most recently from c4e6701 to ab792f0 Compare August 11, 2026 15:02
P2SH-P2WPKH: validate the redeem-script hash160 against the output script
pubkey before trusting it. Previously any push in script_sig was accepted
without checking the commitment, which would silently allow malformed
inputs to pass.

P2TR: the old check for a script-path spend indexed the last witness item
as [1..33] without verifying length, which panics on items shorter than
33 bytes. Tighten the guard to control_block.len() >= 33 and only check
effective_stack >= 2 (key-path spends have a single witness item).

Extract last_push (returns the last data push in a push-only script) and
witness_compressed_pubkey (verifies compressed pubkey + hash160 match)
as helpers, removing three near-identical match blocks.

Also includes PublicTweakData::new signature change from the two-NonEmptyArray
pattern to &TransactionInputs (companion to the TransactionInputs commit).
@cygnet3
cygnet3 force-pushed the refactor/script_templates branch from ab792f0 to 2c125d2 Compare August 11, 2026 23:11
@cygnet3
cygnet3 merged commit eb82e8f into master Aug 11, 2026
2 checks passed
@cygnet3
cygnet3 deleted the refactor/script_templates branch August 11, 2026 23:23
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