@@ -1659,7 +1659,8 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
16591659/// as long as we examine both the current counterparty commitment transaction and, if it hasn't
16601660/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
16611661macro_rules! fail_unbroadcast_htlcs {
1662- ( $self: expr, $commitment_tx_type: expr, $commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
1662+ ( $self: expr, $commitment_tx_type: expr, $commitment_txid_confirmed: expr,
1663+ $commitment_tx_conf_height: expr, $confirmed_htlcs_list: expr, $logger: expr) => { {
16631664 macro_rules! check_htlc_fails {
16641665 ( $txid: expr, $commitment_tx: expr) => {
16651666 if let Some ( ref latest_outpoints) = $self. counterparty_claimable_outpoints. get( $txid) {
@@ -1693,7 +1694,7 @@ macro_rules! fail_unbroadcast_htlcs {
16931694 }
16941695 } ) ;
16951696 let entry = OnchainEventEntry {
1696- txid: * $txid ,
1697+ txid: $commitment_txid_confirmed ,
16971698 height: $commitment_tx_conf_height,
16981699 event: OnchainEvent :: HTLCUpdate {
16991700 source: ( * * source) . clone( ) ,
@@ -1702,8 +1703,9 @@ macro_rules! fail_unbroadcast_htlcs {
17021703 commitment_tx_output_idx: None ,
17031704 } ,
17041705 } ;
1705- log_trace!( $logger, "Failing HTLC with payment_hash {} from {} counterparty commitment tx due to broadcast of {} commitment transaction, waiting for confirmation (at height {})" ,
1706- log_bytes!( htlc. payment_hash. 0 ) , $commitment_tx, $commitment_tx_type, entry. confirmation_threshold( ) ) ;
1706+ log_trace!( $logger, "Failing HTLC with payment_hash {} from {} counterparty commitment tx due to broadcast of {} commitment transaction {}, waiting for confirmation (at height {})" ,
1707+ log_bytes!( htlc. payment_hash. 0 ) , $commitment_tx, $commitment_tx_type,
1708+ $commitment_txid_confirmed, entry. confirmation_threshold( ) ) ;
17071709 $self. onchain_events_awaiting_threshold_conf. push( entry) ;
17081710 }
17091711 }
@@ -2100,7 +2102,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21002102 }
21012103 self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
21022104
2103- fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , height, [ ] . iter( ) . map( |a| * a) , logger) ;
2105+ fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, height,
2106+ [ ] . iter( ) . map( |a| * a) , logger) ;
21042107 }
21052108 } else if let Some ( per_commitment_data) = per_commitment_option {
21062109 // While this isn't useful yet, there is a potential race where if a counterparty
@@ -2116,7 +2119,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21162119 self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
21172120
21182121 log_info ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
2119- fail_unbroadcast_htlcs ! ( self , "counterparty" , height, per_commitment_data. iter( ) . map( |( a, b) | ( a, b. as_ref( ) . map( |b| b. as_ref( ) ) ) ) , logger) ;
2122+ fail_unbroadcast_htlcs ! ( self , "counterparty" , commitment_txid, height,
2123+ per_commitment_data. iter( ) . map( |( htlc, htlc_source) |
2124+ ( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
2125+ ) , logger) ;
21202126
21212127 let htlc_claim_reqs = self . get_counterparty_htlc_output_claim_reqs ( commitment_number, commitment_txid, Some ( tx) ) ;
21222128 for req in htlc_claim_reqs {
@@ -2272,15 +2278,19 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
22722278 let res = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , height) ;
22732279 let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , tx) ;
22742280 append_onchain_update ! ( res, to_watch) ;
2275- fail_unbroadcast_htlcs ! ( self , "latest holder" , height, self . current_holder_commitment_tx. htlc_outputs. iter( ) . map( |( a, _, c) | ( a, c. as_ref( ) ) ) , logger) ;
2281+ fail_unbroadcast_htlcs ! ( self , "latest holder" , commitment_txid, height,
2282+ self . current_holder_commitment_tx. htlc_outputs. iter( )
2283+ . map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) , logger) ;
22762284 } else if let & Some ( ref holder_tx) = & self . prev_holder_signed_commitment_tx {
22772285 if holder_tx. txid == commitment_txid {
22782286 is_holder_tx = true ;
22792287 log_info ! ( logger, "Got broadcast of previous holder commitment tx {}, searching for available HTLCs to claim" , commitment_txid) ;
22802288 let res = self . get_broadcasted_holder_claims ( holder_tx, height) ;
22812289 let mut to_watch = self . get_broadcasted_holder_watch_outputs ( holder_tx, tx) ;
22822290 append_onchain_update ! ( res, to_watch) ;
2283- fail_unbroadcast_htlcs ! ( self , "previous holder" , height, holder_tx. htlc_outputs. iter( ) . map( |( a, _, c) | ( a, c. as_ref( ) ) ) , logger) ;
2291+ fail_unbroadcast_htlcs ! ( self , "previous holder" , commitment_txid, height,
2292+ holder_tx. htlc_outputs. iter( ) . map( |( htlc, _, htlc_source) | ( htlc, htlc_source. as_ref( ) ) ) ,
2293+ logger) ;
22842294 }
22852295 }
22862296
@@ -2561,7 +2571,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
25612571 matured_htlcs. push ( source. clone ( ) ) ;
25622572 }
25632573
2564- log_debug ! ( logger, "HTLC {} failure update has got enough confirmations to be passed upstream" , log_bytes!( payment_hash. 0 ) ) ;
2574+ log_debug ! ( logger, "HTLC {} failure update in {} has got enough confirmations to be passed upstream" ,
2575+ log_bytes!( payment_hash. 0 ) , entry. txid) ;
25652576 self . pending_monitor_events . push ( MonitorEvent :: HTLCEvent ( HTLCUpdate {
25662577 payment_hash,
25672578 payment_preimage : None ,
@@ -2640,7 +2651,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
26402651 F :: Target : FeeEstimator ,
26412652 L :: Target : Logger ,
26422653 {
2643- self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| entry. txid != * txid) ;
2654+ self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| if entry. txid == * txid {
2655+ log_info ! ( logger, "Removing onchain event with txid {}" , txid) ;
2656+ false
2657+ } else { true } ) ;
26442658 self . onchain_tx_handler . transaction_unconfirmed ( txid, broadcaster, fee_estimator, logger) ;
26452659 }
26462660
0 commit comments