Skip to content

Commit 1e2ca52

Browse files
committed
Clean up fee_insufficient computation
1 parent f5abc93 commit 1e2ca52

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lightning/src/ln/onion_utils.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,12 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(secp_ctx: &
404404
let is_chan_update_invalid = match error_code & 0xff {
405405
7 => false,
406406
11 => amt_to_forward > chan_update.contents.htlc_minimum_msat,
407-
12 => {
408-
let new_fee = amt_to_forward.checked_mul(chan_update.contents.fee_proportional_millionths as u64).and_then(|prop_fee| { (prop_fee / 1000000).checked_add(chan_update.contents.fee_base_msat as u64) });
409-
new_fee.is_some() && route_hop.fee_msat >= new_fee.unwrap()
410-
}
407+
12 => amt_to_forward
408+
.checked_mul(chan_update.contents.fee_proportional_millionths as u64)
409+
.map(|prop_fee| prop_fee / 1_000_000)
410+
.and_then(|prop_fee| prop_fee.checked_add(chan_update.contents.fee_base_msat as u64))
411+
.map(|fee_msats| route_hop.fee_msat >= fee_msats)
412+
.unwrap_or(false),
411413
13 => route_hop.cltv_expiry_delta as u16 >= chan_update.contents.cltv_expiry_delta,
412414
14 => false, // expiry_too_soon; always valid?
413415
20 => chan_update.contents.flags & 2 == 0,

0 commit comments

Comments
 (0)