BIP375: check SegWit versions in non-witness UTXOs #2310

pull zjubiology wants to merge 1 commits into bitcoin:master from zjubiology:master changing 3 files +23 −7
  1. zjubiology commented at 1:07 PM on September 26, 2026: contributor

    BIP375 requires constructors and signers to reject PSBTs that combine silent payment outputs with inputs spending SegWit v2+ outputs.

    The reference validator currently performs this check only when the prevout is provided through PSBT_IN_WITNESS_UTXO. BIP174 also permits SegWit inputs to provide the full previous transaction through PSBT_IN_NON_WITNESS_UTXO, so an input containing only that field can currently bypass the SegWit-version check.

    Reuse the existing _script_pubkey_from_psbt_input() helper when validating input eligibility. This extracts the referenced scriptPubKey from either UTXO field.

    Also add an invalid test vector containing:

    • a silent payment output;
    • a SegWit v2 prevout supplied only through PSBT_IN_NON_WITNESS_UTXO;
    • a matching previous transaction ID and output index.
  2. yenimillet835-crypto commented at 12:55 AM on September 27, 2026: none

    🤩🤩

  3. zjubiology commented at 5:36 AM on September 28, 2026: contributor

    @achow101 @andrewtoth Could you please take a look when you have a chance? Thanks!

  4. fametrano commented at 7:53 PM on October 3, 2026: contributor

    The validator change holds: at ea1192c98800f3157fa6b22307e608362a07b7d2, master (927b6de) accepts the new vector under input_eligibility, this branch rejects it with "Input 0 uses segwit version > 1 with silent payments", and all 43 vectors pass.

    The vector's PSBT_IN_PREVIOUS_TXID is byte-reversed. The field holds 9630266b…0c73c9; the double-SHA256 of the PSBT_IN_NON_WITNESS_UTXO transaction is c9730c1b…263096. BIP 174 requires the two to match ("its hash must match the hash specified in the prevout"), and the six existing vectors with a non-witness UTXO store the hash as computed, so a parser that checks this rejects the PSBT for the wrong reason. Reversing the 32 bytes of PSBT_IN_PREVIOUS_TXID, and of prevout_txid in supplementary to match the other vectors, fixes it.

  5. in bip-0375/bip375_test_vectors.json:389 in ea1192c988
     383 | @@ -384,6 +384,25 @@
     384 |          "input_eligibility"
     385 |        ]
     386 |      },
     387 | +    {
     388 | +      "description": "input eligibility: segwit version greater than 1 supplied via PSBT_IN_NON_WITNESS_UTXO with sp output",
     389 | +      "psbt": "cHNidP8B+wQCAAAAAQIEAgAAAAEEAQEBBQEBAQYBAAABDiCWMCZrG0dm0WcLF8uVyI6AOAwflR+auv+KO1+SGwxzyQEPBAAAAAAiAgLIF7t1Ia/DXqlvO/snDm61Dd/6VWBie5Yf7ADymWUIv0cwRAIgcvN4hS+4Q3JgcvJQdvDndWDtTC4EcWbuamJsdb/bOdYCICEqrl8JV040H1iG9f/zL1cW6rkDCkpTeeYBa2pNQtwkAQEDBAEAAAAiBgLIF7t1Ia/DXqlvO/snDm61Dd/6VWBie5Yf7ADymWUIvwgAAACAAAAAAAEQBP7///8iHQJ6SH/Bn7dph3uHQtbqGBGPPE5yseqMbeYCp61KQdvgaCED7KT/Ebco4uD2DOYiKUOm/1W52V9ie/mpnQhLyHLVClsiHgJ6SH/Bn7dph3uHQtbqGBGPPE5yseqMbeYCp61KQdvgaECKE7OYVUX3K9bolxSuuQmz41SoQqm7i1bNDt7SHfihmVmLMSKKSeC9fpXOEFP3xbKKy1Q6aHB2AOPOiYIu4yAhAQBSAgAAAAH0whLVrtHn9v9jPyzgnGR8V77dkwMU2Y3ndQPVjpQLMwAAAAAA/////wGghgEAAAAAABZSFCKactNKZFvTSWu79Qu7gckGP0+UAAAAAAABAwgYcwEAAAAAAAEEIlEgMm31D+Cge3rLcgcL6ztjLrmtFbppXMHlqmqgB7YUb9gBCUICekh/wZ+3aYd7h0LW6hgRjzxOcrHqjG3mAqetSkHb4GgDYeGx6d5eQssgB/fKVLng1X7ROTj61W0/GeV1E6j84DkA",
    


    fametrano commented at 7:53 PM on October 3, 2026:
          "psbt": "cHNidP8B+wQCAAAAAQIEAgAAAAEEAQEBBQEBAQYBAAABDiDJcwwbkl87iv+6mh+VHww4gI7IlcsXC2fRZkcbayYwlgEPBAAAAAAiAgLIF7t1Ia/DXqlvO/snDm61Dd/6VWBie5Yf7ADymWUIv0cwRAIgcvN4hS+4Q3JgcvJQdvDndWDtTC4EcWbuamJsdb/bOdYCICEqrl8JV040H1iG9f/zL1cW6rkDCkpTeeYBa2pNQtwkAQEDBAEAAAAiBgLIF7t1Ia/DXqlvO/snDm61Dd/6VWBie5Yf7ADymWUIvwgAAACAAAAAAAEQBP7///8iHQJ6SH/Bn7dph3uHQtbqGBGPPE5yseqMbeYCp61KQdvgaCED7KT/Ebco4uD2DOYiKUOm/1W52V9ie/mpnQhLyHLVClsiHgJ6SH/Bn7dph3uHQtbqGBGPPE5yseqMbeYCp61KQdvgaECKE7OYVUX3K9bolxSuuQmz41SoQqm7i1bNDt7SHfihmVmLMSKKSeC9fpXOEFP3xbKKy1Q6aHB2AOPOiYIu4yAhAQBSAgAAAAH0whLVrtHn9v9jPyzgnGR8V77dkwMU2Y3ndQPVjpQLMwAAAAAA/////wGghgEAAAAAABZSFCKactNKZFvTSWu79Qu7gckGP0+UAAAAAAABAwgYcwEAAAAAAAEEIlEgMm31D+Cge3rLcgcL6ztjLrmtFbppXMHlqmqgB7YUb9gBCUICekh/wZ+3aYd7h0LW6hgRjzxOcrHqjG3mAqetSkHb4GgDYeGx6d5eQssgB/fKVLng1X7ROTj61W0/GeV1E6j84DkA",
    

    zjubiology commented at 10:34 PM on October 3, 2026:

    Thanks, good catch. I had written the human-readable txid byte order directly into PSBT_IN_PREVIOUS_TXID.

    I updated the field to use the raw double-SHA256 byte order and changed the supplementary prevout_txid accordingly. I also checked all seven vectors containing PSBT_IN_NON_WITNESS_UTXO; their previous transaction hashes now match their PSBT_IN_PREVIOUS_TXID fields.

    The corrected vector is still rejected by input eligibility with:

    Input 0 uses segwit version > 1 with silent payments

  6. in bip-0375/bip375_test_vectors.json:394 in ea1192c988
     389 | +      "psbt": "cHNidP8B+wQCAAAAAQIEAgAAAAEEAQEBBQEBAQYBAAABDiCWMCZrG0dm0WcLF8uVyI6AOAwflR+auv+KO1+SGwxzyQEPBAAAAAAiAgLIF7t1Ia/DXqlvO/snDm61Dd/6VWBie5Yf7ADymWUIv0cwRAIgcvN4hS+4Q3JgcvJQdvDndWDtTC4EcWbuamJsdb/bOdYCICEqrl8JV040H1iG9f/zL1cW6rkDCkpTeeYBa2pNQtwkAQEDBAEAAAAiBgLIF7t1Ia/DXqlvO/snDm61Dd/6VWBie5Yf7ADymWUIvwgAAACAAAAAAAEQBP7///8iHQJ6SH/Bn7dph3uHQtbqGBGPPE5yseqMbeYCp61KQdvgaCED7KT/Ebco4uD2DOYiKUOm/1W52V9ie/mpnQhLyHLVClsiHgJ6SH/Bn7dph3uHQtbqGBGPPE5yseqMbeYCp61KQdvgaECKE7OYVUX3K9bolxSuuQmz41SoQqm7i1bNDt7SHfihmVmLMSKKSeC9fpXOEFP3xbKKy1Q6aHB2AOPOiYIu4yAhAQBSAgAAAAH0whLVrtHn9v9jPyzgnGR8V77dkwMU2Y3ndQPVjpQLMwAAAAAA/////wGghgEAAAAAABZSFCKactNKZFvTSWu79Qu7gckGP0+UAAAAAAABAwgYcwEAAAAAAAEEIlEgMm31D+Cge3rLcgcL6ztjLrmtFbppXMHlqmqgB7YUb9gBCUICekh/wZ+3aYd7h0LW6hgRjzxOcrHqjG3mAqetSkHb4GgDYeGx6d5eQssgB/fKVLng1X7ROTj61W0/GeV1E6j84DkA",
     390 | +      "supplementary": {
     391 | +        "inputs": [
     392 | +          {
     393 | +            "input_index": 0,
     394 | +            "prevout_txid": "9630266b1b4766d1670b17cb95c88e80380c1f951f9abaff8a3b5f921b0c73c9",
    


    fametrano commented at 7:53 PM on October 3, 2026:
                "prevout_txid": "c9730c1b925f3b8affba9a1f951f0c38808ec895cb170b67d166471b6b263096",
    

    zjubiology commented at 10:35 PM on October 3, 2026:

    Updated the supplementary prevout_txid to match the serialized hash as well. Please review it again.

  7. zjubiology force-pushed on Oct 3, 2026
  8. fametrano commented at 7:19 AM on October 4, 2026: contributor

    ACK 242bfbe9cb2011733c16aea82de2227ba6fb2bc7

    The new vector's PSBT_IN_PREVIOUS_TXID now matches its non-witness UTXO, the test runner passes 43/43, and the vector is still rejected for the segwit version.

  9. zjubiology commented at 11:10 PM on October 4, 2026: contributor

    ACK 242bfbe

    The new vector's PSBT_IN_PREVIOUS_TXID now matches its non-witness UTXO, the test runner passes 43/43, and the vector is still rejected for the segwit version.

    Thanks for the review and ACK!

  10. zjubiology commented at 12:15 AM on October 10, 2026: contributor

    @fametrano Thanks for your review! If there's anything need I to do, please feel free to let me know.

  11. jonatack added the label Proposed BIP modification on Oct 18, 2026
  12. jonatack added the label Pending acceptance on Oct 18, 2026
  13. in bip-0375/bip375_test_vectors.json:404 in 242bfbe9cb
     399 | +          }
     400 | +        ]
     401 | +      },
     402 | +      "checks": [
     403 | +        "input_eligibility"
     404 | +      ]
    


    macgyver13 commented at 8:31 PM on November 6, 2026:

    nit: the validator would still fail on "Input 0 uses segwit version > 1 with silent payments" without "checks": ["input_eligibility"] specified here.


    murchandamus commented at 11:43 PM on November 6, 2026:

    I’m not sure I follow. It does seem to be specified at the point that you are commenting on. Could you explain what fix you propose? Would you prefer that it be fixed in this PR or in a follow-up?


    macgyver13 commented at 12:01 AM on November 7, 2026:

    Sorry, I should have been clearer. The "checks": ["input_eligibility"] field is not needed here. Without it, the runner runs every validation check and still fails with the same message.

    My suggestion is just to delete that line from the vector. It does not need to block this PR. If @zjubiology wants to drop it here, great; otherwise I'll pick it up in a follow-up.


    zjubiology commented at 2:21 PM on November 7, 2026:

    Thanks for clarifying! I removed the checks field in 97b6274. With the default checks, the vector is still rejected with Input 0 uses segwit version > 1 with silent payments, and all 43 test vectors pass.

  14. macgyver13 commented at 10:49 PM on November 6, 2026: contributor

    ACK 242bfbe

  15. BIP375: check SegWit versions in non-witness UTXOs
    Signed-off-by: zjubiology <zjubiology@outlook.com>
    97b6274626
  16. zjubiology force-pushed on Nov 7, 2026
  17. zjubiology commented at 2:21 PM on November 7, 2026: contributor

    @macgyver13 Please review it again.

  18. murchandamus commented at 3:41 PM on November 7, 2026: member

    The only change was the nit by the BIP owner who had acked it before, so I think this is good to go. Thanks everyone.

  19. murchandamus merged this on Nov 7, 2026
  20. murchandamus closed this on Nov 7, 2026

  21. macgyver13 commented at 4:40 PM on November 7, 2026: contributor

    Thank you @zjubiology!

  22. murchandamus removed the label Pending acceptance on Nov 7, 2026

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-11-14 21:10 UTC

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