Uh oh!
There was an error while loading. Please reload this page.
fix(wasm-utxo): infer input script type in fromPsbt without derivations - #361
Draft
OttoAllmendinger wants to merge 1 commit into
Draft
fix(wasm-utxo): infer input script type in fromPsbt without derivations#361OttoAllmendinger wants to merge 1 commit into
OttoAllmendinger wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dimensions.from_psbtunconditionally classified inputs lacking BIP32 derivation paths asP2shP2pk(replay protection), regardless of the actual script type. For externally-signed P2WSH PSBTs (e.g. Swan self-signing) this inflated vsize ~2.5x, understatingfeeRateand triggeringmaxfeeratebroadcast rejections (WCN-2155).Changes
psbt_wallet_input.rs— Addinfer_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 withoutredeem_scriptrather than guessing.dimensions.rs— Replace theErr(_)fallback infrom_psbt(which assumedP2shP2pk) with a call toinfer_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