From 0269d0c0c903661471328d264cbaf845a1dbfe86 Mon Sep 17 00:00:00 2001 From: Sangbida Chaudhuri <101164840+sangbida@users.noreply.github.com> Date: Wed, 14 Jan 2026 08:24:29 +1030 Subject: [PATCH] jsonrpc: fix recover command for BIP86 wallets The recover command checks if a node has already issued bitcoin addresses before allowing recovery. This check only looked at bip32_max_index, but with BIP86 wallets, newaddr() increments bip86_max_index instead. Also, the recover test asserted on hex but now it's asserting on codex32 instead. We should probably go in and fix the end point. @rustyrussell what do you think? --- lightningd/jsonrpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index de8748942..cb73246e0 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -293,7 +293,8 @@ static struct command_result *json_recover(struct command *cmd, "Only sqlite3 supported for recover command"); /* Check this is an empty node! */ - if (db_get_intvar(cmd->ld->wallet->db, "bip32_max_index", 0) != 0) { + if (db_get_intvar(cmd->ld->wallet->db, "bip32_max_index", 0) != 0 + || db_get_intvar(cmd->ld->wallet->db, "bip86_max_index", 0) != 0) { return command_fail(cmd, RECOVER_NODE_IN_USE, "Node has already issued bitcoin addresses!"); }