@@ -1659,7 +1659,8 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1659
1659
/// as long as we examine both the current counterparty commitment transaction and, if it hasn't
1660
1660
/// been revoked yet, the previous one, we we will never "forget" to resolve an HTLC.
1661
1661
macro_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) => { {
1663
1664
macro_rules! check_htlc_fails {
1664
1665
( $txid: expr, $commitment_tx: expr) => {
1665
1666
if let Some ( ref latest_outpoints) = $self. counterparty_claimable_outpoints. get( $txid) {
@@ -1693,7 +1694,7 @@ macro_rules! fail_unbroadcast_htlcs {
1693
1694
}
1694
1695
} ) ;
1695
1696
let entry = OnchainEventEntry {
1696
- txid: * $txid ,
1697
+ txid: $commitment_txid_confirmed ,
1697
1698
height: $commitment_tx_conf_height,
1698
1699
event: OnchainEvent :: HTLCUpdate {
1699
1700
source: ( * * source) . clone( ) ,
@@ -1702,8 +1703,9 @@ macro_rules! fail_unbroadcast_htlcs {
1702
1703
commitment_tx_output_idx: None ,
1703
1704
} ,
1704
1705
} ;
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( ) ) ;
1707
1709
$self. onchain_events_awaiting_threshold_conf. push( entry) ;
1708
1710
}
1709
1711
}
@@ -2100,7 +2102,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2100
2102
}
2101
2103
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2102
2104
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) ;
2104
2107
}
2105
2108
} else if let Some ( per_commitment_data) = per_commitment_option {
2106
2109
// While this isn't useful yet, there is a potential race where if a counterparty
@@ -2116,7 +2119,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2116
2119
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
2117
2120
2118
2121
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) ;
2120
2126
2121
2127
let htlc_claim_reqs = self . get_counterparty_htlc_output_claim_reqs ( commitment_number, commitment_txid, Some ( tx) ) ;
2122
2128
for req in htlc_claim_reqs {
@@ -2272,15 +2278,19 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2272
2278
let res = self . get_broadcasted_holder_claims ( & self . current_holder_commitment_tx , height) ;
2273
2279
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . current_holder_commitment_tx , tx) ;
2274
2280
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) ;
2276
2284
} else if let & Some ( ref holder_tx) = & self . prev_holder_signed_commitment_tx {
2277
2285
if holder_tx. txid == commitment_txid {
2278
2286
is_holder_tx = true ;
2279
2287
log_info ! ( logger, "Got broadcast of previous holder commitment tx {}, searching for available HTLCs to claim" , commitment_txid) ;
2280
2288
let res = self . get_broadcasted_holder_claims ( holder_tx, height) ;
2281
2289
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( holder_tx, tx) ;
2282
2290
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) ;
2284
2294
}
2285
2295
}
2286
2296
@@ -2561,7 +2571,8 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2561
2571
matured_htlcs. push ( source. clone ( ) ) ;
2562
2572
}
2563
2573
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) ;
2565
2576
self . pending_monitor_events . push ( MonitorEvent :: HTLCEvent ( HTLCUpdate {
2566
2577
payment_hash,
2567
2578
payment_preimage : None ,
@@ -2640,7 +2651,10 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2640
2651
F :: Target : FeeEstimator ,
2641
2652
L :: Target : Logger ,
2642
2653
{
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 } ) ;
2644
2658
self . onchain_tx_handler . transaction_unconfirmed ( txid, broadcaster, fee_estimator, logger) ;
2645
2659
}
2646
2660
0 commit comments