Skip to content

Commit 2b38052

Browse files
committed
Use next_splice_out_maximum_sat to validate funding_contributed
This is equivalent to the previous commit, see the debug assertions added in the previous commit. We now also get to communicate the exact maximum back to the user, instead of some "balance is lower than our reserve" message, which is hard to react to.
1 parent a0573b1 commit 2b38052

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12633,7 +12633,13 @@ where
1263312633
// For splice-out, our_funding_contribution is adjusted to cover fees if there
1263412634
// aren't any inputs.
1263512635
let our_funding_contribution = contribution.net_value();
12636-
self.validate_splice_contributions(our_funding_contribution, SignedAmount::ZERO)
12636+
let next_splice_out_maximum = self.get_next_splice_out_maximum(&self.funding)?;
12637+
if our_funding_contribution.is_negative() && our_funding_contribution.unsigned_abs() > next_splice_out_maximum {
12638+
let unsigned_contribution = our_funding_contribution.unsigned_abs();
12639+
Err(format!("Our splice-out value of {unsigned_contribution} is greater than the maximum {next_splice_out_maximum}"))
12640+
} else {
12641+
Ok(())
12642+
}
1263712643
}) {
1263812644
log_error!(logger, "Channel {} cannot be funded: {}", self.context.channel_id(), e);
1263912645

lightning/src/ln/splicing_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,8 +4155,8 @@ fn do_test_splice_pending_htlcs(config: UserConfig) {
41554155
format!("Channel {} cannot accept funding contribution", channel_id);
41564156
assert_eq!(error, APIError::APIMisuseError { err: cannot_accept_contribution });
41574157
let cannot_be_funded = format!(
4158-
"Channel {} cannot be funded: Channel {} cannot be spliced out; our post-splice channel balance {} is smaller than their selected v2 reserve {}",
4159-
channel_id, channel_id, post_splice_reserve - Amount::ONE_SAT, post_splice_reserve
4158+
"Channel {} cannot be funded: Our splice-out value of {} is greater than the maximum {}",
4159+
channel_id, splice_out_incl_fees + Amount::ONE_SAT, splice_out_incl_fees,
41604160
);
41614161
initiator.logger.assert_log("lightning::ln::channel", cannot_be_funded, 1);
41624162

0 commit comments

Comments
 (0)