What changed, and why it matters
This is a small cleanup change in Bitcoin Core that removes leftover null checks after a previous refactor made database cursors always return a valid object. There is no security issue in the diff itself.
No security action required. Review as normal code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes stale null checks and assertions from CCoinsViewDB::Cursor() call sites in coinstats.cpp and rpc/blockchain.cpp. The underlying Cursor() implementation was changed so it directly constructs and returns a non-null cursor, making the old nullable-cursor contract obsolete. The change is purely a code-quality refactor with no functional security impact.
Changed components
src/kernel/coinstats.cppsrc/rpc/blockchain.cppInspect captured patch +1 / −5
diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp
index 8e96cdb3..bc4986f3 100644
--- a/src/kernel/coinstats.cpp
+++ b/src/kernel/coinstats.cpp
@@ -118,7 +118,6 @@ static std::optional<CCoinsStats> ComputeUTXOStats(T hash_obj, const CCoinsViewD
pcursor = view.Cursor();
pindex = blockman.LookupBlockIndex(pcursor->GetBestBlock());
}
- assert(pcursor);
CCoinsStats stats{Assert(pindex)->nHeight, pindex->GetBlockHash()};
Txid prevkey;
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index ce7adf6d..f3e1330b 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -2441,7 +2441,7 @@ static RPCMethod scantxoutset()
LOCK(cs_main);
Chainstate& active_chainstate = chainman.ActiveChainstate();
active_chainstate.ForceFlushStateToDisk(/*wipe_cache=*/false);
- pcursor = CHECK_NONFATAL(active_chainstate.CoinsDB().Cursor());
+ pcursor = active_chainstate.CoinsDB().Cursor();
tip = CHECK_NONFATAL(active_chainstate.m_chain.Tip());
}
bool res = FindScriptPubKey(g_scan_progress, g_should_abort_scan, count, pcursor.get(), needles, coins, node.rpc_interruption_point);
@@ -3328,9 +3328,6 @@ UniValue CreateRolledBackUTXOSnapshot(
}
std::unique_ptr<CCoinsViewCursor> pcursor{temp_db->Cursor()};
- if (!pcursor) {
- throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to create UTXO cursor");
- }
LogInfo("Writing snapshot to disk.");
return WriteUTXOSnapshot(chainstate,
Why this scored 13/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.