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.