Skip to content

Commit 694fe22

Browse files
committed
f - use claimable_htlc.total_msat instead of passing in total_msat
1 parent 97ac9bd commit 694fe22

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,7 +3548,7 @@ where
35483548
}
35493549

35503550
macro_rules! check_total_value {
3551-
($payment_secret: expr, $payment_preimage: expr, $total_msat: expr, $is_keysend: expr) => {{
3551+
($payment_secret: expr, $payment_preimage: expr, $is_keysend: expr) => {{
35523552
let mut payment_claimable_generated = false;
35533553
let purpose = if $is_keysend {
35543554
events::PaymentPurpose::SpontaneousPayment(
@@ -3596,9 +3596,9 @@ where
35963596
for htlc in htlcs.iter() {
35973597
total_value += htlc.sender_intended_value;
35983598
earliest_expiry = cmp::min(earliest_expiry, htlc.cltv_expiry);
3599-
if htlc.total_msat != $total_msat {
3599+
if htlc.total_msat != claimable_htlc.total_msat {
36003600
log_trace!(self.logger, "Failing HTLCs with payment_hash {} as the HTLCs had inconsistent total values (eg {} and {})",
3601-
log_bytes!(payment_hash.0), $total_msat, htlc.total_msat);
3601+
log_bytes!(payment_hash.0), claimable_htlc.total_msat, htlc.total_msat);
36023602
total_value = msgs::MAX_VALUE_MSAT;
36033603
}
36043604
if total_value >= msgs::MAX_VALUE_MSAT { break; }
@@ -3607,11 +3607,11 @@ where
36073607
// match exactly the condition used in `timer_tick_occurred`
36083608
if total_value >= msgs::MAX_VALUE_MSAT {
36093609
fail_htlc!(claimable_htlc, payment_hash);
3610-
} else if total_value - claimable_htlc.sender_intended_value >= $total_msat {
3610+
} else if total_value - claimable_htlc.sender_intended_value >= claimable_htlc.total_msat {
36113611
log_trace!(self.logger, "Failing HTLC with payment_hash {} as payment is already claimable",
36123612
log_bytes!(payment_hash.0));
36133613
fail_htlc!(claimable_htlc, payment_hash);
3614-
} else if total_value >= $total_msat {
3614+
} else if total_value >= claimable_htlc.total_msat {
36153615
#[allow(unused_assignments)] {
36163616
committed_to_claimable = true;
36173617
}
@@ -3670,10 +3670,10 @@ where
36703670
fail_htlc!(claimable_htlc, payment_hash);
36713671
}
36723672
}
3673-
check_total_value!(Some(payment_data.payment_secret), payment_preimage, payment_data.total_msat, false);
3673+
check_total_value!(Some(payment_data.payment_secret), payment_preimage, false);
36743674
},
36753675
OnionPayload::Spontaneous(preimage) => {
3676-
check_total_value!(payment_data.as_ref().map(|d| d.payment_secret), Some(preimage), payment_data.as_ref().map_or(claimable_htlc.value, |d| d.total_msat), true);
3676+
check_total_value!(payment_data.as_ref().map(|d| d.payment_secret), Some(preimage), true);
36773677
}
36783678
}
36793679
},
@@ -3691,7 +3691,7 @@ where
36913691
log_bytes!(payment_hash.0), payment_data.total_msat, inbound_payment.get().min_value_msat.unwrap());
36923692
fail_htlc!(claimable_htlc, payment_hash);
36933693
} else {
3694-
let payment_claimable_generated = check_total_value!(Some(payment_data.payment_secret), inbound_payment.get().payment_preimage, payment_data.total_msat, false);
3694+
let payment_claimable_generated = check_total_value!(Some(payment_data.payment_secret), inbound_payment.get().payment_preimage, false);
36953695
if payment_claimable_generated {
36963696
inbound_payment.remove_entry();
36973697
}

0 commit comments

Comments
 (0)