refactor: Avoid integer overflow in ApplyStats when activating snapshot

This commit is contained in:
MarcoFalke
2021-11-01 17:03:09 +01:00
parent fac01888d1
commit fa996c58e8
4 changed files with 9 additions and 4 deletions

View File

@@ -1244,7 +1244,8 @@ static RPCHelpMan gettxoutsetinfo()
if (hash_type == CoinStatsHashType::MUHASH) {
ret.pushKV("muhash", stats.hashSerialized.GetHex());
}
ret.pushKV("total_amount", ValueFromAmount(stats.nTotalAmount));
CHECK_NONFATAL(stats.total_amount.has_value());
ret.pushKV("total_amount", ValueFromAmount(stats.total_amount.value()));
if (!stats.index_used) {
ret.pushKV("transactions", static_cast<int64_t>(stats.nTransactions));
ret.pushKV("disk_size", stats.nDiskSize);