Skip to content

Commit cae633d

Browse files
tankyleoTheBlueMatt
andcommitted
Delay HTLC txs in 0FC channels until both commit and anchor txs confirm
It is possible to claim HTLCs and the P2A anchor in the same transaction, but we leave aggregating these claims to a follow-up. For now, we imitate the behavior of CSV anchor channels, and wait for the commitment transaction to confirm before broadcasting HTLC transactions. Co-authored-by: Matt Corallo <[email protected]>
1 parent 1671d75 commit cae633d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,10 +3950,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
39503950
// new channel updates.
39513951
self.holder_tx_signed = true;
39523952
let mut watch_outputs = Vec::new();
3953-
// We can't broadcast our HTLC transactions while the commitment transaction is
3954-
// unconfirmed. We'll delay doing so until we detect the confirmed commitment in
3955-
// `transactions_confirmed`.
3956-
if !funding.channel_type_features().supports_anchors_zero_fee_htlc_tx() {
3953+
// In CSV anchor channels, we can't broadcast our HTLC transactions while the commitment transaction is
3954+
// unconfirmed.
3955+
// We'll delay doing so until we detect the confirmed commitment in `transactions_confirmed`.
3956+
//
3957+
// TODO: For now in 0FC channels, we also delay broadcasting any HTLC transactions until the commitment
3958+
// transaction gets confirmed. It is nonetheless possible to add HTLC spends to the P2A spend
3959+
// transaction while the commitment transaction is still unconfirmed.
3960+
let zero_fee_htlcs =
3961+
self.channel_type_features().supports_anchors_zero_fee_htlc_tx();
3962+
let zero_fee_commitments =
3963+
self.channel_type_features().supports_anchor_zero_fee_commitments();
3964+
if !zero_fee_htlcs && !zero_fee_commitments {
39573965
// Because we're broadcasting a commitment transaction, we should construct the package
39583966
// assuming it gets confirmed in the next block. Sadly, we have code which considers
39593967
// "not yet confirmed" things as discardable, so we cannot do that here.

0 commit comments

Comments
 (0)