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.
This commit is contained in:
Ava Chow
2026-03-16 21:15:26 -07:00
parent c01c7f068c
commit 543d3e1cdc
2 changed files with 7 additions and 0 deletions

View File

@@ -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);

View File

@@ -1073,6 +1073,9 @@ public:
std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
std::set<PSBTProprietary> m_proprietary;
uint32_t tx_version;
std::optional<uint32_t> 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: