Skip to content

Refactor/script templates#138

Open
Sosthene00 wants to merge 3 commits into
masterfrom
refactor/script_templates
Open

Refactor/script templates#138
Sosthene00 wants to merge 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
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).
@Sosthene00 Sosthene00 force-pushed the refactor/script_templates branch from 4ee0368 to 1b6d8f5 Compare June 23, 2026 13:07
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