wallet: change dev_listaddrs to also list bip86 addresses
What changed, and why it matters
This is a small developer-only change to a wallet debugging command. It makes the internal `dev_listaddrs` tool also work with newer BIP86-style wallets (mnemonic/seed-based), instead of only older BIP32-style wallets. There is no direct evidence this fixes an exploitable security bug; it appears to be a compatibility/API improvement for tests.
No immediate security action required. Reviewers should verify that callers of `dev_listaddrs` in tests and any developer tooling are updated to use the renamed `max_index` parameter, and that `bip86_pubkey` and `bip86_max_index` are correctly initialized for BIP86 wallets.
Security signals we found
Developer-only RPC command changed (dev_listaddrs)
Adds BIP86 derivation path support alongside legacy BIP32
Parameter renamed, potentially breaking for callers using the old name
No input validation, memory, or authorization changes visible
Evidence from the diff
The patch modifies json_listaddrs in wallet/walletrpc.c. It renames the optional parameter from bip32_max_index to max_index, selects bip86_max_index from the database when cmd->ld->bip86_base is set, and calls bip86_pubkey instead of bip32_pubkey for BIP86 wallets. The commit message frames this as a developer-only API change to support tests and to make est_option_upfront_shutdown_script handle both old hsmsecret and newer mnemonic setups. No vulnerability, overflow, or authorization flaw is visible in the diff.
Changed components
wallet/walletrpc.cjson_listaddrs RPC commandBIP86 wallet address derivationlegacy BIP32 wallet address derivationInspect captured patch +20 / −8
diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c
index 0a530863..4ea6b3b0 100644
--- a/wallet/walletrpc.c
+++ b/wallet/walletrpc.c
@@ -292,28 +292,40 @@ static struct command_result *json_listaddrs(struct command *cmd,
{
struct json_stream *response;
struct pubkey pubkey;
- u64 *bip32_max_index;
+ u64 *max_index;
+ bool use_bip86 = (cmd->ld->bip86_base != NULL);
if (!param(cmd, buffer, params,
- p_opt("bip32_max_index", param_u64, &bip32_max_index),
+ p_opt("max_index", param_u64, &max_index),
NULL))
return command_param_failed();
- if (!bip32_max_index) {
- bip32_max_index = tal(cmd, u64);
- *bip32_max_index = db_get_intvar(cmd->ld->wallet->db,
- "bip32_max_index", 0);
+ 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);
+ }
}
response = json_stream_success(cmd);
json_array_start(response, "addresses");
- for (s64 keyidx = 1; keyidx <= *bip32_max_index; keyidx++) {
+ for (s64 keyidx = 1; keyidx <= *max_index; keyidx++) {
if (keyidx == BIP32_INITIAL_HARDENED_CHILD){
break;
}
- bip32_pubkey(cmd->ld, &pubkey, keyidx);
+ /* Use BIP86 derivation for BIP86 wallets, BIP32 for legacy */
+ if (use_bip86) {
+ bip86_pubkey(cmd->ld, &pubkey, keyidx);
+ } else {
+ bip32_pubkey(cmd->ld, &pubkey, keyidx);
+ }
// bech32 : p2wpkh
u8 *redeemscript_p2wpkh;
Why this scored 17/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.