Skip to content

Commit 0fcd61d

Browse files
committed
(XXX: TESTME) Move pending payment tracking to after the new HTLC flies
If we attempt to send a payment, but the HTLC cannot be send due to local channel limits, we'll provide the user an error but end up with an entry in our pending payment map. This will result in the user not being able to retry their payment as we'll consider it still "in-flight".
1 parent 7aa2cac commit 0fcd61d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19601960
starting_block_height: self.best_block.read().unwrap().height(),
19611961
total_msat: total_value,
19621962
});
1963-
assert!(payment.insert(session_priv_bytes, path.last().unwrap().fee_msat));
19641963

19651964
let err: Result<(), _> = loop {
19661965
let mut channel_lock = self.channel_state.lock().unwrap();
@@ -1978,12 +1977,17 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19781977
if !chan.get().is_live() {
19791978
return Err(APIError::ChannelUnavailable{err: "Peer for first hop currently disconnected/pending monitor update!".to_owned()});
19801979
}
1981-
break_chan_entry!(self, chan.get_mut().send_htlc_and_commit(htlc_msat, payment_hash.clone(), htlc_cltv, HTLCSource::OutboundRoute {
1982-
path: path.clone(),
1983-
session_priv: session_priv.clone(),
1984-
first_hop_htlc_msat: htlc_msat,
1985-
payment_id,
1986-
}, onion_packet, &self.logger), channel_state, chan)
1980+
let send_res =
1981+
break_chan_entry!(self, chan.get_mut().send_htlc_and_commit(
1982+
htlc_msat, payment_hash.clone(), htlc_cltv, HTLCSource::OutboundRoute {
1983+
path: path.clone(),
1984+
session_priv: session_priv.clone(),
1985+
first_hop_htlc_msat: htlc_msat,
1986+
payment_id,
1987+
}, onion_packet, &self.logger),
1988+
channel_state, chan);
1989+
assert!(payment.insert(session_priv_bytes, path.last().unwrap().fee_msat));
1990+
send_res
19871991
} {
19881992
Some((update_add, commitment_signed, monitor_update)) => {
19891993
if let Err(e) = self.chain_monitor.update_channel(chan.get().get_funding_txo().unwrap(), monitor_update) {

0 commit comments

Comments
 (0)