Skip to content

Commit 13af9bc

Browse files
committed
lightningd: use P2TR for onchain tx spends.
Both for HTLC txs and the to-self outputs. Signed-off-by: Rusty Russell <[email protected]> Changelog-Changed: Wallet: Taproot addresses are used for unilateral-close change addresses.
1 parent 836204b commit 13af9bc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lightningd/onchain_control.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,15 @@ static struct bitcoin_tx *onchaind_tx_unsigned(const tal_t *ctx,
882882
bitcoin_tx_add_input(tx, &info->out, info->to_self_delay,
883883
NULL, info->out_sats, NULL, info->wscript);
884884

885-
/* FIXME should this be p2tr now? */
886-
bitcoin_tx_add_output(
887-
tx, scriptpubkey_p2wpkh(tmpctx, &final_key), NULL, info->out_sats);
888-
psbt_add_keypath_to_last_output(tx, channel->final_key_idx, &final_wallet_ext_key, false /* is_taproot */);
885+
if (chainparams->is_elements) {
886+
bitcoin_tx_add_output(
887+
tx, scriptpubkey_p2wpkh(tmpctx, &final_key), NULL, info->out_sats);
888+
psbt_add_keypath_to_last_output(tx, channel->final_key_idx, &final_wallet_ext_key, false /* is_taproot */);
889+
} else {
890+
bitcoin_tx_add_output(
891+
tx, scriptpubkey_p2tr(tmpctx, &final_key), NULL, info->out_sats);
892+
psbt_add_keypath_to_last_output(tx, channel->final_key_idx, &final_wallet_ext_key, true /* is_taproot */);
893+
}
889894

890895
/* Worst-case sig is 73 bytes */
891896
weight = bitcoin_tx_weight(tx) + 1 + 3 + 73 + 0 + tal_count(info->wscript);
@@ -1117,7 +1122,7 @@ static bool consider_onchain_htlc_tx_rebroadcast(struct channel *channel,
11171122
struct pubkey final_key;
11181123
bip32_pubkey(ld, &final_key, channel->final_key_idx);
11191124
psbt_append_output(psbt,
1120-
scriptpubkey_p2wpkh(tmpctx, &final_key),
1125+
scriptpubkey_p2tr(tmpctx, &final_key),
11211126
change);
11221127
}
11231128

0 commit comments

Comments
 (0)