psbt: preserve proprietary fields when combining PSBTs #34893

pull w0xlt wants to merge 2 commits into bitcoin:master from w0xlt:psbt-proprietary-merge-fix changing 4 files +131 −0
  1. w0xlt commented at 7:56 am on March 22, 2026: contributor

    BIP 174 proprietary fields are currently parsed, serialized, and exposed by decodepsbt, but they are not preserved by combinepsbt.

    The reason is that the merge paths in PartiallySignedTransaction::Merge(), PSBTInput::Merge(), and PSBTOutput::Merge() union unknown, but never union m_proprietary.

    This means application-specific PSBT metadata can be lost during combination, even though BIP 174 treats proprietary records as normal PSBT key-value pairs for private or application-specific use.

    This PR fixes that by preserving proprietary fields in all three merge paths.

  2. psbt: preserve proprietary fields when combining PSBTs
    CombinePSBTs currently preserves unknown records but drops proprietary records at the global, input, and output levels because the Merge() paths never union m_proprietary.
    
    Preserve proprietary records in PartiallySignedTransaction::Merge(), PSBTInput::Merge(), and PSBTOutput::Merge() so combine/merge keeps all PSBT key-value data.
    7eceaf82e1
  3. test: add PSBT proprietary merge regression coverage
    Add generic unit and functional regression tests asserting that combine/merge preserves proprietary fields at the global, input, and output scopes.
    
    These tests document the expected behavior before the implementation fix, so the follow-up commit can be reviewed by dropping it and observing the failure.
    8cd41daf9a
  4. DrahtBot added the label PSBT on Mar 22, 2026
  5. DrahtBot commented at 7:56 am on March 22, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    LLM Linter (✨ experimental)

    Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

    • MakeProprietary(PSBT_GLOBAL_PROPRIETARY, 1, 0xaa) in src/test/psbt_tests.cpp
    • MakeProprietary(PSBT_GLOBAL_PROPRIETARY, 2, 0xbb) in src/test/psbt_tests.cpp
    • MakeProprietary(PSBT_IN_PROPRIETARY, 3, 0xcc) in src/test/psbt_tests.cpp
    • MakeProprietary(PSBT_IN_PROPRIETARY, 4, 0xdd) in src/test/psbt_tests.cpp
    • MakeProprietary(PSBT_OUT_PROPRIETARY, 5, 0xee) in src/test/psbt_tests.cpp
    • MakeProprietary(PSBT_OUT_PROPRIETARY, 6, 0xff) in src/test/psbt_tests.cpp
    • proprietary_key(PSBT_GLOBAL_PROPRIETARY, b"gc", 1, b"\x01") in test/functional/rpc_psbt.py
    • proprietary_key(PSBT_GLOBAL_PROPRIETARY, b"gc", 2, b"\x02") in test/functional/rpc_psbt.py
    • proprietary_key(PSBT_IN_PROPRIETARY, b"in", 3, b"\x03") in test/functional/rpc_psbt.py
    • proprietary_key(PSBT_IN_PROPRIETARY, b"in", 4, b"\x04") in test/functional/rpc_psbt.py
    • proprietary_key(PSBT_OUT_PROPRIETARY, b"out", 5, b"\x05") in test/functional/rpc_psbt.py
    • proprietary_key(PSBT_OUT_PROPRIETARY, b"out", 6, b"\x06") in test/functional/rpc_psbt.py
    • proprietary_entry(global_key_a, b"\xaa", b"gc", 1) in test/functional/rpc_psbt.py
    • proprietary_entry(global_key_b, b"\xdd", b"gc", 2) in test/functional/rpc_psbt.py
    • proprietary_entry(input_key_a, b"\xbb", b"in", 3) in test/functional/rpc_psbt.py
    • proprietary_entry(input_key_b, b"\xee", b"in", 4) in test/functional/rpc_psbt.py
    • proprietary_entry(output_key_a, b"\xcc", b"out", 5) in test/functional/rpc_psbt.py
    • proprietary_entry(output_key_b, b"\xff", b"out", 6) in test/functional/rpc_psbt.py

    2026-03-22 07:56:31


w0xlt DrahtBot

Labels
PSBT


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-23 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me