wallet: Read the max_index for addresses from the in-memory cache
What changed, and why it matters
This small change makes the wallet's address-listing command read a cached value from memory instead of querying the database each time. It appears to be a performance or consistency cleanup rather than a security fix. There is no direct evidence in the commit that it repairs a vulnerability.
No immediate security action required. Treat as a normal code-quality/performance change. If reviewing further, verify that the in-memory cache is kept consistent with the database after writes and startup loading.
Security signals we found
No security framing in commit title or message
No input validation, memory, or authorization changes
Change is a data-source substitution (DB query -> cached field)
No explicit bug, crash, or vulnerability described
Evidence from the diff
The patch modifies json_listaddrs in wallet/walletrpc.c to read bip86_max_index/bip32_max_index from cmd->ld->wallet->* fields (in-memory cache) rather than calling db_get_intvar against the database. The commit message frames this as a cache-read change. No security relevance, attacker-controlled inputs, or boundary/authorization changes are visible in the diff.
Changed components
wallet/walletrpc.cjson_listaddrs RPC handlerInspect captured patch +4 / −7
diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c
index 045ce715..4a0e2385 100644
--- a/wallet/walletrpc.c
+++ b/wallet/walletrpc.c
@@ -290,13 +290,10 @@ static struct command_result *json_listaddrs(struct command *cmd,
if (!max_index) {
max_index = tal(cmd, u64);
/* Use bip86_max_index for BIP86 wallets, bip32_max_index for legacy */
- if (use_bip86) {
- *max_index = db_get_intvar(cmd->ld->wallet->db,
- "bip86_max_index", 0);
- } else {
- *max_index = db_get_intvar(cmd->ld->wallet->db,
- "bip32_max_index", 0);
- }
+ if (use_bip86)
+ *max_index = cmd->ld->wallet->bip86_max_index;
+ else
+ *max_index = cmd->ld->wallet->bip32_max_index;
}
response = json_stream_success(cmd);
json_array_start(response, "addresses");
Why this scored 16/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.