From a815e3e2629fdcc1331a070a574fba595dac5c9e Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Tue, 31 Mar 2026 11:19:54 +0200 Subject: [PATCH 1/2] rpc: Correct type for tx_sigops Broken out from larger effort to make CAmount more type safe. --- src/rpc/mining.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index dcf5ee26457..2b4745eba68 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -897,7 +897,7 @@ static RPCMethod getblocktemplate() UniValue transactions(UniValue::VARR); std::map setTxIndex; std::vector tx_fees{block_template->getTxFees()}; - std::vector tx_sigops{block_template->getTxSigops()}; + std::vector tx_sigops{block_template->getTxSigops()}; int i = 0; for (const auto& it : block.vtx) { From 0774eaaf0c221b3fed68e866130abafa2890880c Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Thu, 23 Apr 2026 16:58:16 +0200 Subject: [PATCH 2/2] util: Require integers for SaturatingAdd() and AdditionOverflow() Previously we could fall back to using an unspecialized implementation of std::numeric_limits which would compile as long as the numeric operators existed, but would return 0 for min() & max(). --- src/util/overflow.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/overflow.h b/src/util/overflow.h index 274ba0454e3..48732838ac8 100644 --- a/src/util/overflow.h +++ b/src/util/overflow.h @@ -13,10 +13,9 @@ #include #include -template +template [[nodiscard]] bool AdditionOverflow(const T i, const T j) noexcept { - static_assert(std::is_integral_v, "Integral required."); if constexpr (std::numeric_limits::is_signed) { return (i > 0 && j > std::numeric_limits::max() - i) || (i < 0 && j < std::numeric_limits::min() - i); @@ -41,7 +40,7 @@ template return true; } -template +template [[nodiscard]] T SaturatingAdd(const T i, const T j) noexcept { if constexpr (std::numeric_limits::is_signed) {