psbt: misc fixes and add remaining BIP 174 and BIP 370 test vectors #839
Draft
Sjors wants to merge 13 commits into
Draft
psbt: misc fixes and add remaining BIP 174 and BIP 370 test vectors #839Sjors wants to merge 13 commits into
Sjors wants to merge 13 commits into
Conversation
The rolling nightly toolchain has drifted past what trezor-firmware core/v2.9.6 supports: recent nightlies reject its reexport_test_harness_main attribute with error E0658. Pin the nightly to 2025-04-15, matching the firmware's own shell.nix. Co-authored-by: Claude (Fable 5) <noreply@anthropic.com>
Also drops Python 3.6 dataclasses leftover.
The Ledger bitcoin app repos have moved: - new: from LedgerHQ/app-bitcoin-new to LedgerHQ/app-bitcoin - legacy: from LedgerHQ/app-bitcoin to LedgerHQ/app-bitcoin-legacy
self.tx is never None, for PSBTv2 it's an empty placeholder. Its defaults would overwrite the deserialized tx version and fallback locktime, invalidating any existing signature. Check the PSBT version instead, here and in get_unsigned_tx(). Without this fix all BIP 370 valid test vectors, now added, fail the serialization round-trip.
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.
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 free
to 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.
Based on:
Each fix / hardening commit introduces the test vectors that cover it.
Mostly straight-forward, but
psbt: parse the global unsigned tx without witness datais worth a closer look. IIUC it catches up with bitcoin/bips#1099.