Skip to content

Commit 9a2f1f7

Browse files
committed
fixup finish_psbt change creation for elements
1 parent c6987c4 commit 9a2f1f7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

wallet/reservation.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ static struct command_result *finish_psbt(struct command *cmd,
367367
/* Should we add a change output for the excess? */
368368
if (excess_as_change) {
369369
struct amount_sat change;
370+
struct pubkey pubkey;
370371
s64 keyidx;
371372
u8 *b32script;
372373

@@ -384,7 +385,12 @@ static struct command_result *finish_psbt(struct command *cmd,
384385
"Failed to generate change address."
385386
" Keys exhausted.");
386387

387-
b32script = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
388+
if (chainparams->is_elements) {
389+
bip32_pubkey(cmd->ld, &pubkey, keyidx);
390+
b32script = scriptpubkey_p2wpkh(tmpctx, &pubkey);
391+
} else {
392+
b32script = p2tr_for_keyidx(tmpctx, cmd->ld, keyidx);
393+
}
388394
if (!b32script) {
389395
return command_fail(cmd, LIGHTNINGD,
390396
"Failed to generate change address."

0 commit comments

Comments
 (0)