Skip to content

Commit 69b0a61

Browse files
committed
Exclude HTLC transactions from broadcast on anchor channels
HTLC transactions from anchor channels are constrained by a CSV of 1 block, so broadcasting them along with the unconfirmed commitment tranasction will result in them being immediately rejected as premature.
1 parent 03cb83c commit 69b0a61

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26252625
let commitment_tx = self.onchain_tx_handler.get_fully_signed_holder_tx(&self.funding_redeemscript);
26262626
let txid = commitment_tx.txid();
26272627
let mut holder_transactions = vec![commitment_tx];
2628+
// When anchor outputs are present, the HTLC transactions are only valid once the commitment
2629+
// transaction confirms.
2630+
if self.onchain_tx_handler.opt_anchors() {
2631+
return holder_transactions;
2632+
}
26282633
for htlc in self.current_holder_commitment_tx.htlc_outputs.iter() {
26292634
if let Some(vout) = htlc.0.transaction_output_index {
26302635
let preimage = if !htlc.0.offered {
@@ -2658,6 +2663,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26582663
let commitment_tx = self.onchain_tx_handler.get_fully_signed_copy_holder_tx(&self.funding_redeemscript);
26592664
let txid = commitment_tx.txid();
26602665
let mut holder_transactions = vec![commitment_tx];
2666+
// When anchor outputs are present, the HTLC transactions are only final once the commitment
2667+
// transaction confirms due to the CSV 1 encumberance.
2668+
if self.onchain_tx_handler.opt_anchors() {
2669+
return holder_transactions;
2670+
}
26612671
for htlc in self.current_holder_commitment_tx.htlc_outputs.iter() {
26622672
if let Some(vout) = htlc.0.transaction_output_index {
26632673
let preimage = if !htlc.0.offered {

0 commit comments

Comments
 (0)