@@ -1518,7 +1518,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
15181518
15191519 /// Gets the set of outbound HTLCs which are pending resolution in this channel.
15201520 /// This is used to reconstruct pending outbound payments on restart in the ChannelManager.
1521- pub ( crate ) fn get_pending_htlcs ( & self ) -> HashMap < HTLCSource , HTLCOutputInCommitment > {
1521+ pub ( crate ) fn get_pending_outbound_htlcs ( & self ) -> HashMap < HTLCSource , HTLCOutputInCommitment > {
15221522 let mut res = HashMap :: new ( ) ;
15231523 let us = self . inner . lock ( ) . unwrap ( ) ;
15241524
@@ -1562,7 +1562,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
15621562
15631563 // We're only concerned with the confirmation count of HTLC transactions, and don't
15641564 // actually care how many confirmations a commitment transaction may or may not have. Thus,
1565- // we look for both a FundingSpendConfirmation event, or a funding_spend_confirmed.
1565+ // we look for either a FundingSpendConfirmation event or a funding_spend_confirmed.
15661566 let confirmed_txid = us. funding_spend_confirmed . or_else ( || {
15671567 us. onchain_events_awaiting_threshold_conf . iter ( ) . find_map ( |event| {
15681568 if let OnchainEvent :: FundingSpendConfirmation { .. } = event. event {
@@ -1572,25 +1572,28 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
15721572 } ) ;
15731573 if let Some ( txid) = confirmed_txid {
15741574 if Some ( txid) == us. current_counterparty_commitment_txid || Some ( txid) == us. prev_counterparty_commitment_txid {
1575- walk_htlcs ! ( false , us. counterparty_claimable_outpoints. get( & txid) . unwrap( ) . iter( ) . find_map ( |( a, b) | {
1575+ walk_htlcs ! ( false , us. counterparty_claimable_outpoints. get( & txid) . unwrap( ) . iter( ) . filter_map ( |( a, b) | {
15761576 if let & Some ( ref source) = b {
15771577 Some ( ( a, & * * source) )
15781578 } else { None }
15791579 } ) ) ;
15801580 } else if txid == us. current_holder_commitment_tx . txid {
1581- walk_htlcs ! ( true , us. current_holder_commitment_tx. htlc_outputs. iter( ) . find_map ( |( a, _, c) | {
1581+ walk_htlcs ! ( true , us. current_holder_commitment_tx. htlc_outputs. iter( ) . filter_map ( |( a, _, c) | {
15821582 if let Some ( source) = c { Some ( ( a, source) ) } else { None }
15831583 } ) ) ;
15841584 } else if let Some ( prev_commitment) = & us. prev_holder_signed_commitment_tx {
15851585 if txid == prev_commitment. txid {
1586- walk_htlcs ! ( true , prev_commitment. htlc_outputs. iter( ) . find_map ( |( a, _, c) | {
1586+ walk_htlcs ! ( true , prev_commitment. htlc_outputs. iter( ) . filter_map ( |( a, _, c) | {
15871587 if let Some ( source) = c { Some ( ( a, source) ) } else { None }
15881588 } ) ) ;
15891589 }
15901590 }
15911591 } else {
1592- macro_rules! check_htlc_fails {
1593- ( $txid: expr, $commitment_tx: expr) => {
1592+ // If we have not seen a commitment transaction on-chain (ie the channel is not yet
1593+ // closed), just examine the available counterparty commitment transactions. See docs
1594+ // on `fail_unbroadcast_htlcs`, below, for justification.
1595+ macro_rules! walk_counterparty_commitment {
1596+ ( $txid: expr) => {
15941597 if let Some ( ref latest_outpoints) = us. counterparty_claimable_outpoints. get( $txid) {
15951598 for & ( ref htlc, ref source_option) in latest_outpoints. iter( ) {
15961599 if let & Some ( ref source) = source_option {
@@ -1601,10 +1604,10 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
16011604 }
16021605 }
16031606 if let Some ( ref txid) = us. current_counterparty_commitment_txid {
1604- check_htlc_fails ! ( txid, "current" ) ;
1607+ walk_counterparty_commitment ! ( txid) ;
16051608 }
16061609 if let Some ( ref txid) = us. prev_counterparty_commitment_txid {
1607- check_htlc_fails ! ( txid, "previous" ) ;
1610+ walk_counterparty_commitment ! ( txid) ;
16081611 }
16091612 }
16101613
0 commit comments