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
Disallow sending an HTLC when the balance needed is pending removal
While its nice to be able to push an HTLC which spends balance that
is removed in our local commitment transaction but awaiting an RAA
from our peer for final removal its by no means a critical feature.
Because peers should really be sending RAAs quickly after we send
a commitment, this should be an exceedingly rare case, and we
already don't expose this as available balance when routing, so
this isn't even made available when sending, only forwarding.
Note that `test_pending_claimed_htlc_no_balance_underflow` is
removed as it tested a case which was only possible because of this
and now is no longer possible.
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)));
5858
5858
}
5859
5859
5860
-
let keys = self.build_holder_transaction_keys(self.cur_holder_commitment_transaction_number);
5861
-
let commitment_stats = self.build_commitment_transaction(self.cur_holder_commitment_transaction_number,&keys,true,true, logger);
5862
5860
if !self.is_outbound(){
5863
5861
// Check that we won't violate the remote channel reserve by adding this HTLC.
5864
5862
let htlc_candidate = HTLCCandidate::new(amount_msat,HTLCInitiator::LocalOffered);
5865
5863
let counterparty_commit_tx_fee_msat = self.next_remote_commit_tx_fee_msat(htlc_candidate,None);
5866
5864
let holder_selected_chan_reserve_msat = self.holder_selected_channel_reserve_satoshis*1000;
5867
-
if commitment_stats.remote_balance_msat < counterparty_commit_tx_fee_msat + holder_selected_chan_reserve_msat {
5865
+
let remote_balance_msat = (self.channel_value_satoshis*1000 - self.value_to_self_msat).saturating_sub(inbound_stats.pending_htlcs_value_msat);
5866
+
if remote_balance_msat < counterparty_commit_tx_fee_msat + holder_selected_chan_reserve_msat {
5868
5867
returnErr(ChannelError::Ignore("Cannot send value that would put counterparty balance under holder-announced channel reserve value".to_owned()));
returnErr(ChannelError::Ignore(format!("Cannot send value that would overdraw remaining funds. Amount: {}, pending value to self {}", amount_msat, holder_balance_msat)));
returnErr(ChannelError::Ignore(format!("Cannot send value that would put our balance under counterparty-announced channel reserve value ({})", chan_reserve_msat)));
0 commit comments