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?
This commit is contained in:
Sangbida Chaudhuri
2026-01-14 08:24:29 +10:30
committed by Rusty Russell
parent e19fd5d62c
commit 0269d0c0c9

View File

@@ -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!");
}