aboutsummaryrefslogtreecommitdiff
path: root/src/core_write.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2019-08-01 17:54:48 -0400
committerMatt Corallo <git@bluematt.me>2019-08-02 15:37:13 -0400
commit970de70bdd3542e75b73c79b06f143168c361494 (patch)
tree727c0319bc969dea20689051dcb7999b3fb1c0b0 /src/core_write.cpp
parente653eeff7651d823407e2e31a89176cc0b240c62 (diff)
downloadbitcoin-970de70bdd3542e75b73c79b06f143168c361494.tar.xz
Dump transaction version as an unsigned integer in RPC/TxToUniv
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
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 4d64446d7b..c7049eb16c 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));