]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Exclude HTLC transactions from broadcast on anchor channels
authorWilmer Paulino <wilmer.paulino@gmail.com>
Thu, 25 Aug 2022 20:36:17 +0000 (13:36 -0700)
committerWilmer Paulino <wilmer.paulino@gmail.com>
Tue, 13 Sep 2022 17:58:24 +0000 (10:58 -0700)
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.

lightning/src/chain/channelmonitor.rs

index da30f86149b7b918065de56dfa821267c563f721..857495630259d542af26e96d7cd80a59e90f713e 100644 (file)
@@ -2653,6 +2653,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
                let commitment_tx = self.onchain_tx_handler.get_fully_signed_holder_tx(&self.funding_redeemscript);
                let txid = commitment_tx.txid();
                let mut holder_transactions = vec![commitment_tx];
+               // When anchor outputs are present, the HTLC transactions are only valid once the commitment
+               // transaction confirms.
+               if self.onchain_tx_handler.opt_anchors() {
+                       return holder_transactions;
+               }
                for htlc in self.current_holder_commitment_tx.htlc_outputs.iter() {
                        if let Some(vout) = htlc.0.transaction_output_index {
                                let preimage = if !htlc.0.offered {
@@ -2686,6 +2691,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
                let commitment_tx = self.onchain_tx_handler.get_fully_signed_copy_holder_tx(&self.funding_redeemscript);
                let txid = commitment_tx.txid();
                let mut holder_transactions = vec![commitment_tx];
+               // When anchor outputs are present, the HTLC transactions are only final once the commitment
+               // transaction confirms due to the CSV 1 encumberance.
+               if self.onchain_tx_handler.opt_anchors() {
+                       return holder_transactions;
+               }
                for htlc in self.current_holder_commitment_tx.htlc_outputs.iter() {
                        if let Some(vout) = htlc.0.transaction_output_index {
                                let preimage = if !htlc.0.offered {