diff --git a/src/coins.h b/src/coins.h index a1658e0b32..cf6cf08c81 100644 --- a/src/coins.h +++ b/src/coins.h @@ -58,7 +58,7 @@ public: template void Serialize(Stream &s) const { assert(!IsSpent()); - uint32_t code = nHeight * 2 + fCoinBase; + uint32_t code = nHeight * uint32_t{2} + fCoinBase; ::Serialize(s, VARINT(code)); ::Serialize(s, Using(out)); } diff --git a/src/undo.h b/src/undo.h index 91656ce904..bb5a129888 100644 --- a/src/undo.h +++ b/src/undo.h @@ -24,7 +24,7 @@ struct TxInUndoFormatter { template void Ser(Stream &s, const Coin& txout) { - ::Serialize(s, VARINT(txout.nHeight * 2 + (txout.fCoinBase ? 1u : 0u))); + ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); if (txout.nHeight > 0) { // Required to maintain compatibility with older undo format. ::Serialize(s, (unsigned char)0); @@ -34,9 +34,9 @@ struct TxInUndoFormatter template void Unser(Stream &s, Coin& txout) { - unsigned int nCode = 0; + uint32_t nCode = 0; ::Unserialize(s, VARINT(nCode)); - txout.nHeight = nCode / 2; + txout.nHeight = nCode >> 1; txout.fCoinBase = nCode & 1; if (txout.nHeight > 0) { // Old versions stored the version number for the last spend of