refactor: [rpc] Remove cast when reporting serialized size
What changed, and why it matters
This is a minor code cleanup in Bitcoin Core's RPC code. It removes three unnecessary type casts when reporting block size values through the JSON-RPC interface. The output values are unchanged, and there is no security issue.
No action required. This is a non-security refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes explicit (int) casts from GetSerializeSize() and GetBlockWeight() return values in blockToJSON(). The commit message states the values fit in an int and that UniValue accepts any integer type, making the casts redundant and confusing. The diff shows a pure refactor with no functional change.
Changed components
src/rpc/blockchain.cppInspect captured patch +3 / −3
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 2ff5f529..831bf5fe 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -185,9 +185,9 @@ UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIn
{
UniValue result = blockheaderToJSON(tip, blockindex, pow_limit);
- result.pushKV("strippedsize", (int)::GetSerializeSize(TX_NO_WITNESS(block)));
- result.pushKV("size", (int)::GetSerializeSize(TX_WITH_WITNESS(block)));
- result.pushKV("weight", (int)::GetBlockWeight(block));
+ result.pushKV("strippedsize", ::GetSerializeSize(TX_NO_WITNESS(block)));
+ result.pushKV("size", ::GetSerializeSize(TX_WITH_WITNESS(block)));
+ result.pushKV("weight", ::GetBlockWeight(block));
UniValue txs(UniValue::VARR);
txs.reserve(block.vtx.size());
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.