Skip to content

Commit 7a38617

Browse files
committed
f - add missing balance check
1 parent 8e00cb2 commit 7a38617

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11023,6 +11023,22 @@ where
1102311023
)));
1102411024
}
1102511025

11026+
let their_channel_balance = Amount::from_sat(self.funding.get_value_satoshis())
11027+
- Amount::from_sat(self.funding.get_value_to_self_msat() / 1000);
11028+
let post_channel_balance = AddSigned::checked_add_signed(
11029+
their_channel_balance.to_sat(),
11030+
their_funding_contribution.to_sat(),
11031+
);
11032+
11033+
if post_channel_balance.is_none() {
11034+
return Err(ChannelError::WarnAndDisconnect(format!(
11035+
"Channel {} cannot be spliced out; their {} contribution exhausts their channel balance: {}",
11036+
self.context.channel_id(),
11037+
their_funding_contribution,
11038+
their_channel_balance,
11039+
)));
11040+
}
11041+
1102611042
let splice_funding = FundingScope::for_splice(
1102711043
&self.funding,
1102811044
&self.context,

0 commit comments

Comments
 (0)