Skip to content

fix(wasm-utxo): handle replay protection inputs in PSBT reconstruction#271

Merged
OttoAllmendinger merged 2 commits intomasterfrom
BTC-2650.fix-fromnetworktx-bch-rp
Apr 29, 2026
Merged

fix(wasm-utxo): handle replay protection inputs in PSBT reconstruction#271
OttoAllmendinger merged 2 commits intomasterfrom
BTC-2650.fix-fromnetworktx-bch-rp

Conversation

@OttoAllmendinger
Copy link
Copy Markdown
Contributor

Allow PSBT reconstruction from half-signed BCH transactions that
include unsigned replay protection inputs. Previously, inputs without
scriptSig or witness data would error; now they parse as Unsigned.

When hydrating from a legacy transaction, use the expected pubkey from
unspents metadata if the input is unsigned, rather than requiring the
pubkey to be extracted from the transaction.

Add comprehensive regression tests for BCH FORKID sighash finalization
and PSBT hydration scenarios. Tests verify that:

  • All partial sigs use hashType 0x41 (SIGHASH_ALL|SIGHASH_FORKID)
  • utxolib's finalizeAllInputs() succeeds without "Invalid hashType 0"
  • Both unsigned and signed p2shP2pk inputs reconstruct correctly
  • fromNetworkFormat preserves sigs in half-signed and fully-signed txs
  • Wallet-platform hydrate-and-cosign flow completes successfully

Remove tests for deprecated fromHalfSignedLegacyTransaction method.
Retain tests for fromNetworkFormat which supersedes it.

Consolidate test file and reduce redundancy by combining half-signed
and full-signed test cases into a single parameterized helper.

Issue: BTC-2650

OttoAllmendinger and others added 2 commits April 29, 2026 14:54
Allow PSBT reconstruction from half-signed BCH transactions that
include unsigned replay protection inputs. Previously, inputs without
scriptSig or witness data would error; now they parse as `Unsigned`.

When hydrating from a legacy transaction, use the expected pubkey from
unspents metadata if the input is unsigned, rather than requiring the
pubkey to be extracted from the transaction.

Add comprehensive regression tests for BCH FORKID sighash finalization
and PSBT hydration scenarios. Tests verify that:
- All partial sigs use hashType 0x41 (SIGHASH_ALL|SIGHASH_FORKID)
- utxolib's finalizeAllInputs() succeeds without "Invalid hashType 0"
- Both unsigned and signed p2shP2pk inputs reconstruct correctly
- fromNetworkFormat preserves sigs in half-signed and fully-signed txs
- Wallet-platform hydrate-and-cosign flow completes successfully

Issue: BTC-2650

Co-authored-by: llm-git <llm-git@ttll.de>
Remove tests for deprecated `fromHalfSignedLegacyTransaction` method.
Retain tests for `fromNetworkFormat` which supersedes it.

Consolidate test file and reduce redundancy by combining half-signed
and full-signed test cases into a single parameterized helper.

Issue: BTC-2650

Co-authored-by: llm-git <llm-git@ttll.de>
@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review April 29, 2026 13:12
@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner April 29, 2026 13:12
@OttoAllmendinger OttoAllmendinger merged commit 77b3545 into master Apr 29, 2026
16 checks passed
@OttoAllmendinger OttoAllmendinger deleted the BTC-2650.fix-fromnetworktx-bch-rp branch April 29, 2026 13:58
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