Skip to content

Commit e80259f

Browse files
committed
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.
1 parent 970de70 commit e80259f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

doc/release-notes-16525.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ RPC changes
44
Exposed transaction version numbers are now treated as unsigned 32-bit integers
55
instead of signed 32-bit integers. This matches their treatment in consensus
66
logic. Versions greater than 2 continue to be non-standard (matching previous
7-
behavior of smaller than 1 or greater than 2 being non-standard).
7+
behavior of smaller than 1 or greater than 2 being non-standard). Note that
8+
this includes the joinpsbt command, which combines partially-signed
9+
transactions by selecting the highest version number.

src/rpc/rawtransaction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ UniValue joinpsbts(const JSONRPCRequest& request)
15661566
throw JSONRPCError(RPC_INVALID_PARAMETER, "At least two PSBTs are required to join PSBTs.");
15671567
}
15681568

1569-
int32_t best_version = 1;
1569+
uint32_t best_version = 1;
15701570
uint32_t best_locktime = 0xffffffff;
15711571
for (unsigned int i = 0; i < txs.size(); ++i) {
15721572
PartiallySignedTransaction psbtx;
@@ -1576,8 +1576,8 @@ UniValue joinpsbts(const JSONRPCRequest& request)
15761576
}
15771577
psbtxs.push_back(psbtx);
15781578
// Choose the highest version number
1579-
if (psbtx.tx->nVersion > best_version) {
1580-
best_version = psbtx.tx->nVersion;
1579+
if (static_cast<uint32_t>(psbtx.tx->nVersion) > best_version) {
1580+
best_version = static_cast<uint32_t>(psbtx.tx->nVersion);
15811581
}
15821582
// Choose the lowest lock time
15831583
if (psbtx.tx->nLockTime < best_locktime) {
@@ -1588,7 +1588,7 @@ UniValue joinpsbts(const JSONRPCRequest& request)
15881588
// Create a blank psbt where everything will be added
15891589
PartiallySignedTransaction merged_psbt;
15901590
merged_psbt.tx = CMutableTransaction();
1591-
merged_psbt.tx->nVersion = best_version;
1591+
merged_psbt.tx->nVersion = static_cast<int32_t>(best_version);
15921592
merged_psbt.tx->nLockTime = best_locktime;
15931593

15941594
// Merge

0 commit comments

Comments
 (0)