Skip to content

Commit c4d1e49

Browse files
committed
Avoid Bolt11 claim amount underflow
Use saturating arithmetic when accounting for skimmed JIT-channel fees while validating manually claimed payments. This prevents an oversized skimmed fee from underflowing the expected claimable amount. This commit was created with assistance from OpenAI Codex.
1 parent 588ae2f commit c4d1e49

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/payment/bolt11.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ impl Bolt11Payment {
539539
_ => 0,
540540
};
541541
if let Some(invoice_amount_msat) = details.amount_msat {
542-
if claimable_amount_msat < invoice_amount_msat - skimmed_fee_msat {
542+
if claimable_amount_msat < invoice_amount_msat.saturating_sub(skimmed_fee_msat) {
543543
log_error!(
544544
self.logger,
545545
"Failed to manually claim payment {} as the claimable amount is less than expected",

0 commit comments

Comments
 (0)