diff options
| author | Matt Corallo <[email protected]> | 2019-09-03 10:53:45 -0400 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2019-09-03 10:53:45 -0400 |
| commit | e80259f1976545e4f1ab6a420644be0c32261773 (patch) | |
| tree | a4733981df0b7e7cfad3b08c5d87eaff611a320d | |
| parent | Dump transaction version as an unsigned integer in RPC/TxToUniv (diff) | |
| download | discoin-e80259f1976545e4f1ab6a420644be0c32261773.tar.xz discoin-e80259f1976545e4f1ab6a420644be0c32261773.zip | |
Additionally treat Tx.nVersion as unsigned in joinpsbts
This gets its own release note callout, though doesn't appear to
violate the BIP as the BIP appears to be underspecified. We
probably want to update BIP 174 to mention how version numbers are
combined.
| -rw-r--r-- | doc/release-notes-16525.md | 4 | ||||
| -rw-r--r-- | src/rpc/rawtransaction.cpp | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/doc/release-notes-16525.md b/doc/release-notes-16525.md index f042c875f..220cb78de 100644 --- a/doc/release-notes-16525.md +++ b/doc/release-notes-16525.md @@ -4,4 +4,6 @@ RPC changes Exposed transaction version numbers are now treated as unsigned 32-bit integers instead of signed 32-bit integers. This matches their treatment in consensus logic. Versions greater than 2 continue to be non-standard (matching previous -behavior of smaller than 1 or greater than 2 being non-standard). +behavior of smaller than 1 or greater than 2 being non-standard). Note that +this includes the joinpsbt command, which combines partially-signed +transactions by selecting the highest version number. diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 0ab504de0..0abc2d26b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1566,7 +1566,7 @@ UniValue joinpsbts(const JSONRPCRequest& request) throw JSONRPCError(RPC_INVALID_PARAMETER, "At least two PSBTs are required to join PSBTs."); } - int32_t best_version = 1; + uint32_t best_version = 1; uint32_t best_locktime = 0xffffffff; for (unsigned int i = 0; i < txs.size(); ++i) { PartiallySignedTransaction psbtx; @@ -1576,8 +1576,8 @@ UniValue joinpsbts(const JSONRPCRequest& request) } psbtxs.push_back(psbtx); // Choose the highest version number - if (psbtx.tx->nVersion > best_version) { - best_version = psbtx.tx->nVersion; + if (static_cast<uint32_t>(psbtx.tx->nVersion) > best_version) { + best_version = static_cast<uint32_t>(psbtx.tx->nVersion); } // Choose the lowest lock time if (psbtx.tx->nLockTime < best_locktime) { @@ -1588,7 +1588,7 @@ UniValue joinpsbts(const JSONRPCRequest& request) // Create a blank psbt where everything will be added PartiallySignedTransaction merged_psbt; merged_psbt.tx = CMutableTransaction(); - merged_psbt.tx->nVersion = best_version; + merged_psbt.tx->nVersion = static_cast<int32_t>(best_version); merged_psbt.tx->nLockTime = best_locktime; // Merge |