refactor: [rpc] Remove confusing and brittle integral casts (take 3)
What changed, and why it matters
This is a tiny code cleanup in a Bitcoin Core RPC command. It removes an unnecessary cast to uint64_t when reporting how many bytes were written to a file. The actual value being reported does not change, and there is no security issue.
No security action needed. Treat as a normal refactoring/review change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes one line in src/rpc/net.cpp inside the exportasmap RPC handler. Previously node::data::ip_asn.size() was explicitly cast to uint64_t before being passed to result.pushKV(“bytes_written”, …). The patch removes the cast. The size() member of a std::vector or similar container returns a size_t, which is already an unsigned integer type and is safely convertible for JSON serialization. The cast was stylistically confusing and brittle, not a security boundary.
Changed components
src/rpc/net.cppexportasmap RPC methodInspect captured patch +1 / −1
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 49c8a10c..20bb1cb4 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -1167,7 +1167,7 @@ static RPCMethod exportasmap()
UniValue result(UniValue::VOBJ);
result.pushKV("path", export_path.utf8string());
- result.pushKV("bytes_written", (uint64_t)node::data::ip_asn.size());
+ result.pushKV("bytes_written", node::data::ip_asn.size());
result.pushKV("file_hash", HexStr(hasher.GetSHA256()));
return result;
#endif
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.