Skip to content

Commit 1070da9

Browse files
committed
f make get_pending_outbound_htlcs clearer
and always include all resolved HTLCs, which seems more correct
1 parent 905ef44 commit 1070da9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,8 +1816,8 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
18161816
/// `ChannelMonitor`. This is used to determine if an HTLC was removed from the channel prior
18171817
/// to the `ChannelManager` having been persisted.
18181818
///
1819-
/// This is similar to [`Self::get_pending_outbound_htlcs`] except it includes HTLCs which were
1820-
/// resolved by this `ChannelMonitor`.
1819+
/// This is similar to [`Self::get_pending_or_resolved_outbound_htlcs`] except it includes
1820+
/// HTLCs which were resolved by this `ChannelMonitor`.
18211821
pub(crate) fn get_all_current_outbound_htlcs(&self) -> HashMap<HTLCSource, (HTLCOutputInCommitment, Option<PaymentPreimage>)> {
18221822
let mut res = HashMap::new();
18231823
// Just examine the available counterparty commitment transactions. See docs on
@@ -1846,7 +1846,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
18461846

18471847
/// Gets the set of outbound HTLCs which are pending resolution in this channel.
18481848
/// This is used to reconstruct pending outbound payments on restart in the ChannelManager.
1849-
pub(crate) fn get_pending_outbound_htlcs(&self) -> HashMap<HTLCSource, (HTLCOutputInCommitment, Option<PaymentPreimage>)> {
1849+
pub(crate) fn get_pending_or_resolved_outbound_htlcs(&self) -> HashMap<HTLCSource, (HTLCOutputInCommitment, Option<PaymentPreimage>)> {
18501850
let us = self.inner.lock().unwrap();
18511851
// We're only concerned with the confirmation count of HTLC transactions, and don't
18521852
// actually care how many confirmations a commitment transaction may or may not have. Thus,
@@ -1895,10 +1895,8 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
18951895
} else { false }
18961896
});
18971897
if !htlc_update_confd {
1898-
if us.counterparty_fulfilled_htlcs.get(&SentHTLCId::from_source(source)).is_none() {
1899-
res.insert(source.clone(), (htlc.clone(),
1900-
us.counterparty_fulfilled_htlcs.get(&SentHTLCId::from_source(source)).cloned()));
1901-
}
1898+
res.insert(source.clone(), (htlc.clone(),
1899+
us.counterparty_fulfilled_htlcs.get(&SentHTLCId::from_source(source)).cloned()));
19021900
}
19031901
}
19041902
}

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7504,7 +7504,7 @@ where
75047504
// 0.0.102+
75057505
for (_, monitor) in args.channel_monitors.iter() {
75067506
if id_to_peer.get(&monitor.get_funding_txo().0.to_channel_id()).is_none() {
7507-
for (htlc_source, (htlc, _)) in monitor.get_pending_outbound_htlcs() {
7507+
for (htlc_source, (htlc, _)) in monitor.get_pending_or_resolved_outbound_htlcs() {
75087508
if let HTLCSource::OutboundRoute { payment_id, session_priv, path, payment_secret, .. } = htlc_source {
75097509
if path.is_empty() {
75107510
log_error!(args.logger, "Got an empty path for a pending payment");

0 commit comments

Comments
 (0)