From 543d3e1cdcf9e07f99705f935e624cd587fe02b6 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 16 Mar 2026 21:15:26 -0700 Subject: [PATCH] psbt: add PSBTv2 global tx fields When decomposing a transaction into a PSBTv2, the tx version and locktime need to be stored in their respective global fields. Add those fields and fill them when constructing. --- src/psbt.cpp | 2 ++ src/psbt.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/psbt.cpp b/src/psbt.cpp index 1a49d01afcf..3f5e2cde9c2 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -16,6 +16,8 @@ using common::PSBTError; PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx) { + tx_version = tx.version; + fallback_locktime = tx.nLockTime; inputs.reserve(tx.vin.size()); for (const CTxIn& input : tx.vin) { inputs.emplace_back(GetVersion(), input.prevout.hash, input.prevout.n, input.nSequence); diff --git a/src/psbt.h b/src/psbt.h index 3d893194842..2325ca97be9 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -1073,6 +1073,9 @@ public: std::map, std::vector> unknown; std::set m_proprietary; + uint32_t tx_version; + std::optional fallback_locktime; + bool IsNull() const; uint32_t GetVersion() const; @@ -1203,6 +1206,8 @@ public: throw std::ios_base::failure("Unsigned tx does not have empty scriptSigs and scriptWitnesses."); } } + tx_version = tx->version; + fallback_locktime = tx->nLockTime; break; } case PSBT_GLOBAL_XPUB: