test: check `PSBT_GLOBAL_VERSION` validation on decode #36626

pull nebula-21 wants to merge 1 commits into bitcoin:master from nebula-21:test-psbt-version-field changing 1 files +16 −0
  1. nebula-21 commented at 4:06 PM on October 23, 2026: contributor

    This PR adds coverage for the global PSBT version field validation on decode.

    test_psbt_unsupported_version_field checks that the PSBT has supported version number into the PSBT_GLOBAL_VERSION field. The test can be triggered with this diff:

    <details> <summary>Diff</summary>

    diff --git a/src/psbt.h b/src/psbt.h
    index 5eb5e81428..d90528e01d 100644
    --- a/src/psbt.h
    +++ b/src/psbt.h
    @@ -94,7 +94,7 @@ inline constexpr uint8_t PSBT_SEPARATOR = 0x00;
     inline constexpr std::streamsize MAX_FILE_SIZE_PSBT{100'000'000}; // 100 MB
     
     // PSBT version number
    -inline constexpr uint32_t PSBT_HIGHEST_VERSION = 2;
    +inline constexpr uint32_t PSBT_HIGHEST_VERSION = 4;
     
     /** A structure for PSBT proprietary types */
     struct PSBTProprietary
    

    </details>

    test_psbt_missing_version_field checks that a PSBT without the PSBT_GLOBAL_VERSION field is interpreted as a v0. I've created a v2 and removed the field to check the correct behavior (fails beacuse it was originally a v2 and now is misinterpreted as a v0). The test can be triggered with this diff:

    <details> <summary>Diff</summary>

    diff --git a/src/psbt.h b/src/psbt.h
    index 5eb5e81428..ea11267e0f 100644
    --- a/src/psbt.h
    +++ b/src/psbt.h
    @@ -1515,7 +1515,7 @@ public:
             if (psbt_ver == 0) {
                 // Make sure that we got an unsigned tx for PSBTv0
                 if (!tx) {
    -                throw std::ios_base::failure("No unsigned transaction was provided");
    +                //throw std::ios_base::failure("No unsigned transaction was provided");
                 }
                 // Make sure no PSBTv2 fields are present
                 if (found_tx_version) {
    

    </details>

    Prior to this PR, no test would be triggered with this diffs.

  2. test: check `PSBT_GLOBAL_VERSION` validation on decode eeb4782bda
  3. DrahtBot added the label Tests on Oct 23, 2026
  4. DrahtBot commented at 4:06 PM on October 23, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36343 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36343.svg"></sub> (psbt: verify final scripts in FinalizePSBT by Bruce039)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

Contributors
Labels

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-10-29 06:51 UTC

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