Skip to content

Commit bc3ede2

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 a3018cb commit bc3ede2

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
@@ -9141,10 +9141,13 @@ impl<SP: Deref> FundedChannel<SP> where
91419141
return Err((LocalHTLCFailureReason::ChannelNotReady,
91429142
"Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
91439143
}
9144-
let channel_total_msat = self.funding.get_value_satoshis() * 1000;
9145-
if amount_msat > channel_total_msat {
9146-
return Err((LocalHTLCFailureReason::AmountExceedsCapacity,
9147-
format!("Cannot send amount {}, because it is more than the total value of the channel {}", amount_msat, channel_total_msat)));
9144+
9145+
for funding in core::iter::once(&self.funding).chain(self.pending_funding.iter()) {
9146+
let channel_total_msat = funding.get_value_satoshis() * 1000;
9147+
if amount_msat > channel_total_msat {
9148+
return Err((LocalHTLCFailureReason::AmountExceedsCapacity,
9149+
format!("Cannot send amount {}, because it is more than the total value of the channel {}", amount_msat, channel_total_msat)));
9150+
}
91489151
}
91499152

91509153
if amount_msat == 0 {

0 commit comments

Comments
 (0)