aboutsummaryrefslogtreecommitdiff
path: root/src/core_write.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-07-16 21:33:13 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-07-16 21:38:09 +0200
commitc57dc566b06034ce7bdb29da0db4d65e0accb382 (patch)
tree556c3ad3fe9c244eb84edf7e5318647f82bbe028 /src/core_write.cpp
parent1148f3d63094eab788993a9417e5038cfbe5aa77 (diff)
parente80259f1976545e4f1ab6a420644be0c32261773 (diff)
downloadbitcoin-c57dc566b06034ce7bdb29da0db4d65e0accb382.tar.xz
Merge #16525: Dump transaction version as an unsigned integer in RPC/TxToUniv
e80259f1976545e4f1ab6a420644be0c32261773 Additionally treat Tx.nVersion as unsigned in joinpsbts (Matt Corallo) 970de70bdd3542e75b73c79b06f143168c361494 Dump transaction version as an unsigned integer in RPC/TxToUniv (Matt Corallo) Pull request description: Consensus-wise we already treat it as an unsigned integer (the only rules around it are in CSV/locktime handling), but changing the underlying data type means touching consensus code for a simple cleanup change, which isn't really worth it. See-also, https://github.com/rust-bitcoin/rust-bitcoin/pull/299 ACKs for top commit: sipa: ACK e80259f1976545e4f1ab6a420644be0c32261773 practicalswift: ACK e80259f1976545e4f1ab6a420644be0c32261773 ajtowns: ACK e80259f1976545e4f1ab6a420644be0c32261773 code review -- checked all other uses of tx.nVersion treat it as unsigned (except for policy.cpp:IsStandard anyway), so looks good. naumenkogs: ACK e80259f Tree-SHA512: 6760a2c77e24e9e1f79a336ca925f9bbca3a827ce02003c71d7f214b82ed3dea13fa7d9f87df9b9445cd58dff8b44a15571d821c876f22f8e5a372a014c9976b
Diffstat (limited to 'src/core_write.cpp')
-rw-r--r--src/core_write.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp
index 69b62df901..34cfeecc6f 100644
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -179,7 +179,9 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
{
entry.pushKV("txid", tx.GetHash().GetHex());
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
- entry.pushKV("version", tx.nVersion);
+ // Transaction version is actually unsigned in consensus checks, just signed in memory,
+ // so cast to unsigned before giving it to the user.
+ entry.pushKV("version", static_cast<int64_t>(static_cast<uint32_t>(tx.nVersion)));
entry.pushKV("size", (int)::GetSerializeSize(tx, PROTOCOL_VERSION));
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
entry.pushKV("weight", GetTransactionWeight(tx));