Skip to content

Commit 8ad0b83

Browse files
committed
f - add missing balance check
1 parent 930694b commit 8ad0b83

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
@@ -11014,6 +11014,22 @@ where
1101411014
)));
1101511015
}
1101611016

11017+
let their_channel_balance = Amount::from_sat(self.funding.get_value_satoshis())
11018+
- Amount::from_sat(self.funding.get_value_to_self_msat() / 1000);
11019+
let post_channel_balance = AddSigned::checked_add_signed(
11020+
their_channel_balance.to_sat(),
11021+
their_funding_contribution.to_sat(),
11022+
);
11023+
11024+
if post_channel_balance.is_none() {
11025+
return Err(ChannelError::WarnAndDisconnect(format!(
11026+
"Channel {} cannot be spliced out; their {} contribution exhausts their channel balance: {}",
11027+
self.context.channel_id(),
11028+
their_funding_contribution,
11029+
their_channel_balance,
11030+
)));
11031+
}
11032+
1101711033
let splice_funding = FundingScope::for_splice(
1101811034
&self.funding,
1101911035
&self.context,

0 commit comments

Comments
 (0)