You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace send_htlc amount checking with available balances
Now that the `get_available_balances` min/max bounds are exact, we
can stop doing all the explicit checks in `send_htlc` entirely,
instead comparing against the `get_available_balances` bounds and
failing if the amount is out of those bounds.
This breaks support for sending amounts below the dust limit if
there is some amount of dust exposure remaining before we hit our
cap, however we will no longer generate such routes anyway.
returnErr(ChannelError::Ignore(format!("Cannot send value that would put us over the max HTLC value in flight our peer will accept ({})",self.counterparty_max_htlc_value_in_flight_msat)));
5964
-
}
5965
-
5966
-
if !self.is_outbound(){
5967
-
// Check that we won't violate the remote channel reserve by adding this HTLC.
5968
-
let htlc_candidate = HTLCCandidate::new(amount_msat,HTLCInitiator::LocalOffered);
5969
-
let counterparty_commit_tx_fee_msat = self.next_remote_commit_tx_fee_msat(htlc_candidate,None);
5970
-
let holder_selected_chan_reserve_msat = self.holder_selected_channel_reserve_satoshis*1000;
5971
-
let remote_balance_msat = (self.channel_value_satoshis*1000 - self.value_to_self_msat).saturating_sub(inbound_stats.pending_htlcs_value_msat);
5972
-
if remote_balance_msat < counterparty_commit_tx_fee_msat + holder_selected_chan_reserve_msat {
returnErr(ChannelError::Ignore(format!("Cannot send value that would put our exposure to dust HTLCs at {} over the limit {} on counterparty commitment tx",
returnErr(ChannelError::Ignore(format!("Cannot send value that would overdraw remaining funds. Amount: {}, pending value to self {}", amount_msat, holder_balance_msat)));
6012
-
}
6013
-
6014
-
// `2 *` and extra HTLC are for the fee spike buffer.
6015
-
let commit_tx_fee_msat = ifself.is_outbound(){
6016
-
let htlc_candidate = HTLCCandidate::new(amount_msat,HTLCInitiator::LocalOffered);
returnErr(ChannelError::Ignore(format!("Cannot send value that would not leave enough to pay for fees. Pending value to self: {}. local_commit_tx_fee {}", holder_balance_msat, commit_tx_fee_msat)));
6022
-
}
6023
-
6024
-
// Check self.counterparty_selected_channel_reserve_satoshis (the amount we must keep as
6025
-
// reserve for the remote to have something to claim if we misbehave)
6026
-
let chan_reserve_msat = self.counterparty_selected_channel_reserve_satoshis.unwrap()*1000;
6027
-
if holder_balance_msat - amount_msat - commit_tx_fee_msat < chan_reserve_msat {
returnErr(ChannelError::Ignore(format!("Cannot send value that would put our balance under counterparty-announced channel reserve value ({})", chan_reserve_msat)));
assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)),
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager","Cannot send value that would put our balance under counterparty-announced channel reserve value",1);
nodes[1].logger.assert_log("lightning::ln::channelmanager".to_string(),"Cannot send value that would put counterparty balance under holder-announced channel reserve value".to_string(),1);
assert!(regex::Regex::new(r"Cannot send value that would put us over the max HTLC value in flight our peer will accept \(\d+\)").unwrap().is_match(err)));
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager","Cannot send value that would put us over the max HTLC value in flight our peer will accept",1);
1851
1840
}
1852
1841
1853
1842
// channel reserve is bigger than their_max_htlc_value_in_flight_msat so loop to deplete
assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)));
assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)));
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager","Cannot send value that would put our balance under counterparty-announced channel reserve value",2);
nodes[0].logger.assert_log("lightning::ln::channel".to_string(),format!("Freeing holding cell with 1 HTLC updates in channel {}", hex::encode(chan.2)),1);
5738
-
let failure_log = format!("Failed to send HTLC with payment_hash {} due to Cannot send value that would put our balance under counterparty-announced channel reserve value ({}) in channel {}",
nodes[0].logger.assert_log("lightning::ln::channel".to_string(),format!("Freeing holding cell with 2 HTLC updates in channel {}", hex::encode(chan.2)),1);
5829
-
let failure_log = format!("Failed to send HTLC with payment_hash {} due to Cannot send value that would put our balance under counterparty-announced channel reserve value ({}) in channel {}",
assert!(regex::Regex::new(r"Cannot send value that would put us over the max HTLC value in flight our peer will accept \(\d+\)").unwrap().is_match(err)));
nodes[0].logger.assert_log_contains("lightning::ln::channelmanager","Cannot send value that would put us over the max HTLC value in flight our peer will accept",1);
assert_eq!(err,&format!("Cannot send value that would put our exposure to dust HTLCs at {} over the limit {} on holder commitment tx",if dust_outbound_balance { dust_outbound_overflow } else { dust_inbound_overflow }, config.channel_config.max_dust_htlc_exposure_msat)));
0 commit comments