Skip to content

Commit df84fa9

Browse files
committed
Add GetVersion helper to PSBT
1 parent c3eb416 commit df84fa9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/psbt.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,11 @@ bool DecodeRawPSBT(PartiallySignedTransaction& psbt, const std::string& tx_data,
401401
}
402402
return true;
403403
}
404+
405+
uint32_t PartiallySignedTransaction::GetVersion() const
406+
{
407+
if (m_version != std::nullopt) {
408+
return *m_version;
409+
}
410+
return 0;
411+
}

src/psbt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ struct PartiallySignedTransaction
405405
std::optional<uint32_t> m_version;
406406

407407
bool IsNull() const;
408+
uint32_t GetVersion() const;
408409

409410
/** Merge psbt into this. The two psbts must have the same underlying CTransaction (i.e. the
410411
* same actual Bitcoin transaction.) Returns true if the merge succeeded, false otherwise. */
@@ -436,7 +437,7 @@ struct PartiallySignedTransaction
436437
SerializeToVector(os, *tx);
437438

438439
// PSBT version
439-
if (m_version != std::nullopt && *m_version > 0) {
440+
if (GetVersion() > 0) {
440441
SerializeToVector(s, CompactSizeWriter(PSBT_GLOBAL_VERSION));
441442
SerializeToVector(s, *m_version);
442443
}

0 commit comments

Comments
 (0)