Skip to content

Commit d228c55

Browse files
committed
Check pending funding in send_htlc
If there are any pending splices when an sending an update_add_htlc message, the HTLC amount must be validated against each pending FundingScope. Otherwise, it may be invalid once the splice is locked.
1 parent e75dbd0 commit d228c55

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9140,10 +9140,13 @@ impl<SP: Deref> FundedChannel<SP> where
91409140
return Err((LocalHTLCFailureReason::ChannelNotReady,
91419141
"Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
91429142
}
9143-
let channel_total_msat = self.funding.get_value_satoshis() * 1000;
9144-
if amount_msat > channel_total_msat {
9145-
return Err((LocalHTLCFailureReason::AmountExceedsCapacity,
9146-
format!("Cannot send amount {}, because it is more than the total value of the channel {}", amount_msat, channel_total_msat)));
9143+
9144+
for funding in core::iter::once(&self.funding).chain(self.pending_funding.iter()) {
9145+
let channel_total_msat = funding.get_value_satoshis() * 1000;
9146+
if amount_msat > channel_total_msat {
9147+
return Err((LocalHTLCFailureReason::AmountExceedsCapacity,
9148+
format!("Cannot send amount {}, because it is more than the total value of the channel {}", amount_msat, channel_total_msat)));
9149+
}
91479150
}
91489151

91499152
if amount_msat == 0 {

0 commit comments

Comments
 (0)