Skip to content

fix(wasm-utxo): infer input script type in fromPsbt without derivations - #361

Draft
OttoAllmendinger wants to merge 1 commit into
masterfrom
otto/WCN-2155-infer-input-script-type
Draft

fix(wasm-utxo): infer input script type in fromPsbt without derivations#361
OttoAllmendinger wants to merge 1 commit into
masterfrom
otto/WCN-2155-infer-input-script-type

Conversation

@OttoAllmendinger

Copy link
Copy Markdown
Contributor

Summary

Dimensions.from_psbt unconditionally classified inputs lacking BIP32 derivation paths as P2shP2pk (replay protection), regardless of the actual script type. For externally-signed P2WSH PSBTs (e.g. Swan self-signing) this inflated vsize ~2.5x, understating feeRate and triggering maxfeerate broadcast rejections (WCN-2155).

Changes

  • psbt_wallet_input.rs — Add infer_input_script_type, which classifies a PSBT input from script/witness metadata alone (no wallet keys/derivations needed). Classification order: taproot fields → redeem/witness script presence (with P2PK shape check for validated replay protection) → output-script-shape fallback (is_p2wsh/is_p2tr). Errors on ambiguous P2SH without redeem_script rather than guessing.
  • dimensions.rs — Replace the Err(_) fallback in from_psbt (which assumed P2shP2pk) with a call to infer_input_script_type, propagating classification errors.
  • test/dimensions.ts — Flipped the red test to green (P2WSH without derivations now classified as segwit) and added a second test verifying P2SH-P2PK replay protection inputs are validated via the P2PK redeem-script shape check.

Refs: WCN-2155

Dimensions.from_psbt unconditionally classified inputs lacking BIP32
derivation paths as P2shP2pk (replay protection), regardless of the
actual script type. For externally-signed P2WSH PSBTs (e.g. Swan
self-signing) this inflated vsize ~2.5x, understating feeRate and
triggering maxfeerate broadcast rejections (WCN-2155).
Add infer_input_script_type, which classifies a PSBT input from
script/witness metadata alone — taproot fields, redeem/witness script
presence (with a P2PK shape check for validated replay protection),
and an output-script-shape fallback for inputs carrying only
witness_utxo. Error on ambiguous P2SH without redeem_script rather
than guessing.
Refs: WCN-2155
@linear-code

Copy link
Copy Markdown

WCN-2155

Sign up for freeto 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.

1 participant

@OttoAllmendinger