From e19fd5d62c1a90a434a1f70b024e2ca044bf501f Mon Sep 17 00:00:00 2001 From: Sangbida Chaudhuri <101164840+sangbida@users.noreply.github.com> Date: Wed, 14 Jan 2026 08:24:22 +1030 Subject: [PATCH] wallet: change dev_listaddrs to also list bip86 addresses listaddrs is dev only and used in tests so it's okay if we change the API here, the usage is by positional arguments in tests so we're okay. Also changing est_option_upfront_shutdown_script to handle both old hsmsecret and the newer mnemonic one. --- wallet/walletrpc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 0a5308639..4ea6b3b00 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;