| 106 | } |
| 107 | |
| 108 | bool WARN_UNUSED_RESULT newaddr_inner(struct command *cmd, struct pubkey *pubkey, enum addrtype addrtype) |
| 109 | { |
| 110 | s64 keyidx; |
| 111 | bool use_bip86_base = (cmd->ld->bip86_base != NULL); |
| 112 | |
| 113 | /* Get new index - wallet_get_newindex now handles both BIP32 and BIP86 */ |
| 114 | keyidx = wallet_get_newindex(cmd->ld, addrtype); |
| 115 | if (keyidx < 0) return false; |
| 116 | |
| 117 | /* Choose derivation method based on wallet type */ |
| 118 | if (use_bip86_base) { |
| 119 | /* Wallet has mnemonic - use BIP86 derivation */ |
| 120 | bip86_pubkey(cmd->ld, pubkey, keyidx); |
| 121 | } else { |
| 122 | /* Legacy wallet - use BIP32 derivation */ |
| 123 | bip32_pubkey(cmd->ld, pubkey, keyidx); |
| 124 | } |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | |
| 129 | static struct command_result *json_newaddr(struct command *cmd, |
no test coverage detected