Skip to content

psbt: misc fixes and add remaining BIP 174 and BIP 370 test vectors - #839

Open
Sjors wants to merge 8 commits into
bitcoin-core:masterfrom
Sjors:2026/07/psbt
Open

psbt: misc fixes and add remaining BIP 174 and BIP 370 test vectors #839
Sjors wants to merge 8 commits into
bitcoin-core:masterfrom
Sjors:2026/07/psbt

Conversation

@Sjors

@Sjors Sjors commented Jul 10, 2026

Copy link
Copy Markdown
Member

Each fix / hardening commit introduces the test vectors that cover it.

Mostly straight-forward, but psbt: parse the global unsigned tx without witness data is worth a closer look. IIUC it catches up with bitcoin/bips#1099.

@Sjors Sjors mentioned this pull request Jul 10, 2026
@Sjors

Sjors commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Ready now that #836 landed.

@Sjors
Sjors marked this pull request as ready for review August 1, 2026 18:22
Comment thread test/test_psbt.py Outdated
self.assertEqual(psbt.tx.vin[0].nSequence, 0xfffffffe)
self.assertEqual(len(psbt.tx.vout), 2)

def test_convert_to_v0_locktime(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 629c9b8 "psbt: set locktime on the transaction, not the PSBT"

Can you combine this with the other test case instead of making a new one? It's basically the same transaction.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dropped test_convert_to_v0_default_sequence and test_convert_to_v0_locktime, using both fields in the generic test_convert_to_v0.

Sjors added 8 commits August 6, 2026 09:11
get_unsigned_tx() assigned the computed locktime to a stray
attribute on the PSBT, so the constructed transaction kept
locktime 0.
get_unsigned_tx() asserted that every input has a sequence number,
crashing on the minimal BIP 370 test vector.
The witness-detecting deserializer accepted witness-serialized
unsigned transactions and misread valid ones with no inputs.
A provided unsigned tx with no inputs and outputs is
indistinguishable from the empty placeholder.
The global PSBTv2 fields were already rejected.
compute_lock_time() was previously untested.
The test data now covers every vector from both BIPs; these all
already pass.
@Sjors

Sjors commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Improved the test, rebased just in case.

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