test: Test merging implicit PSBTv0 with explicit PSBTv0
What changed, and why it matters
This commit adds a new test case to Bitcoin Core's functional test suite. It verifies that two PSBT (Partially Signed Bitcoin Transaction) version 0 encodings—one with the version field explicitly set to 0 and one with it omitted—can be merged together correctly. There is no code change to the actual Bitcoin Core node software, only a new regression test.
No action required. This is a benign test-only commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/rpc_psbt.py to import PSBT_GLOBAL_VERSION and add a test that constructs an explicit v0 PSBT by setting the global version field to 0, then calls combinepsbt with an implicit v0 PSBT and asserts the merged result preserves both unknown input keys. This is purely test coverage for PSBT merging behavior.
Changed components
test/functional/rpc_psbt.pyInspect captured patch +10 / −0
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index 9a75a35d..4703ee3b 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -25,6 +25,7 @@ from test_framework.psbt import (
PSBT,
PSBTMap,
PSBT_GLOBAL_UNSIGNED_TX,
+ PSBT_GLOBAL_VERSION,
PSBT_IN_RIPEMD160,
PSBT_IN_SHA256,
PSBT_IN_SIGHASH_TYPE,
@@ -876,6 +877,15 @@ class PSBTTest(BitcoinTestFramework):
assert_equal(merged_unknown_psbt.i[0].map[unknown_key], unknown_value)
assert_equal(merged_unknown_psbt.i[0].map[unknown_key2], unknown_value)
+ # The explicit PSBT_GLOBAL_VERSION=0 encoding is equivalent to omitting the
+ # version field, and both accepted v0 encodings can be merged.
+ explicit_v0_psbt = self.create_psbt(inputs={unknown_key2: unknown_value})
+ explicit_v0_psbt.g.map[PSBT_GLOBAL_VERSION] = (0).to_bytes(4, "little")
+ merged_v0_versions = self.nodes[0].combinepsbt([unknown_psbt, explicit_v0_psbt.to_base64()])
+ merged_v0_versions_psbt = PSBT.from_base64(merged_v0_versions)
+ assert_equal(merged_v0_versions_psbt.i[0].map[unknown_key], unknown_value)
+ assert_equal(merged_v0_versions_psbt.i[0].map[unknown_key2], unknown_value)
+
# BIP 174 Test Vectors
# Open the data file
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.