From 9fa4076b20a55fc1c142ffde891ca76f5cd416e6 Mon Sep 17 00:00:00 2001 From: w0xlt <94266259+w0xlt@users.noreply.github.com> Date: Tue, 28 Apr 2026 13:32:27 -0700 Subject: [PATCH] test: Test merging implicit PSBTv0 with explicit PSBTv0 --- test/functional/rpc_psbt.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 9a75a35d25d..4703ee3be11 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