Remove BIP 174’s claim that Combine is commutative #2075

pull shesek wants to merge 1 commits into bitcoin:master from shesek:patch-4 changing 1 files +1 −1
  1. shesek commented at 4:16 am on January 7, 2026: contributor

    The BIP asserts that fA(fB(psbt)) == fB(fA(psbt)), however the explanatory text before this doesn’t actually say this and even hints that the ordering does matter: “processing [..] A and then B in a sequence”. It seems that the BIP text only supports the Combine(fA(psbt), fB(psbt)) == fB(fA(psbt)) part, and that fA(fB(psbt)) slipped in by accident?

    In practice, Bitcoin Core’s combinepsbt isn’t commutative and gives precedence to latter PSBTs in the array. Here’s a quick example demonstrating this:

    0PSBT_A="cHNidP8BADMCAAAAAa83fnb+Vw0gR7jZBeABQNh2dFx8F+MbmvHAM8N5+O07AAAAAAD/////AAAAAAAAAQUBUQA="
    1PSBT_B="cHNidP8BADMCAAAAAa83fnb+Vw0gR7jZBeABQNh2dFx8F+MbmvHAM8N5+O07AAAAAAD/////AAAAAAAAAQUBUgA="
    2$ bitcoin-cli decodepsbt $(bitcoin-cli combinepsbt [\"$PSBT_A\",\"$PSBT_B\"]) | jq -r .inputs[0].witness_script.asm
    31
    4$ bitcoin-cli decodepsbt $(bitcoin-cli combinepsbt [\"$PSBT_B\",\"$PSBT_A\"]) | jq -r .inputs[0].witness_script.asm
    52
    

    And here’s a related discussion about rust-bitcoin’s Psbt::combine(), which isn’t commutative either but documented as “In accordance with BIP 174 this function is commutative”: https://github.com/rust-bitcoin/rust-bitcoin/issues/5486

  2. Remove BIP 174's claim that Combine is commutative 6699d99c2f
  3. murchandamus commented at 4:46 pm on January 7, 2026: contributor
    cc: @achow101
  4. murchandamus added the label Proposed BIP modification on Jan 7, 2026
  5. murchandamus added the label Pending acceptance on Jan 7, 2026
  6. achow101 commented at 6:44 pm on January 14, 2026: member

    It’s supposed to be commutative, although I suppose that is contradictory with “The Combiner must remove any duplicate key-value pairs, in accordance with the specification. It can pick arbitrarily when conflicts occur.”

    Will need to think on this a bit more.

  7. shesek commented at 1:01 am on January 15, 2026: contributor

    It’s supposed to be commutative

    Thanks for clarifying this and apologies for the confusion. I would consider updating the BIP text to say that explicitly, it is kind of confusing that its in the formula but not mentioned anywhere in the text.

    One option for making Combine commutative, brought up by @apoelstra in https://github.com/rust-bitcoin/rust-bitcoin/issues/5486#issuecomment-3712793427, is to fail it entirely in case of conflicts.

    This is already mentioned in the BIP, as a may: “For every type that a Combiner understands, it may refuse to combine PSBTs if it detects that there will be inconsistencies or conflicts for that type in the combined PSBT.”

    “It can pick arbitrarily when conflicts occur.”

    Other than implying non-commutativity, this is also contradictory with “The resulting PSBT must contain all of the key-value pairs from each of the PSBTs” (which basically seems impossible to comply with if there are conflicts and should probably be removed?).


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-16 16:10 UTC

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