Skip to content

Commit 1e06a4b

Browse files
committed
wallet: use correct derivation for elements when using mnemonic hsm_secret.
Even though we don't do taproot addresses on elements yet, use the same scheme for simplicity and for future when we *do* do taproot. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 891a205 commit 1e06a4b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

wallet/reservation.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ static struct command_result *finish_psbt(struct command *cmd,
359359
/* Should we add a change output? (Iff it can pay for itself!) */
360360
change = change_amount(change, feerate_per_kw, weight);
361361
if (amount_sat_greater(change, AMOUNT_SAT(0))) {
362-
struct pubkey pubkey;
363362
s64 keyidx;
364363
u8 *b32script;
365364
enum addrtype type;
@@ -378,8 +377,7 @@ static struct command_result *finish_psbt(struct command *cmd,
378377
" Keys exhausted.");
379378

380379
if (chainparams->is_elements) {
381-
bip32_pubkey(cmd->ld, &pubkey, keyidx);
382-
b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey);
380+
b32script = p2wpkh_for_keyidx(tmpctx, cmd->ld, keyidx);
383381
} else {
384382
b32script = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
385383
}
@@ -658,7 +656,6 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
658656
u32 *locktime;
659657
ssize_t outnum;
660658
u32 weight;
661-
struct pubkey pubkey;
662659
s64 keyidx;
663660
const u8 *b32script;
664661
bool *add_initiator_serial_ids;
@@ -718,8 +715,7 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
718715
" Keys exhausted.");
719716

720717
if (chainparams->is_elements) {
721-
bip32_pubkey(cmd->ld, &pubkey, keyidx);
722-
b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey);
718+
b32script = p2wpkh_for_keyidx(tmpctx, cmd->ld, keyidx);
723719
} else {
724720
b32script = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
725721
}

0 commit comments

Comments
 (0)