Skip to content

Commit 90a026d

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 872337e commit 90a026d

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

91549157
if amount_msat == 0 {

0 commit comments

Comments
 (0)