Skip to content

Commit

Permalink
f swap u128 for u64
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinewallace committed Aug 24, 2023
1 parent d787d36 commit ca2753c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
pub(super) fn compute_payinfo(
intermediate_nodes: &[(PublicKey, ForwardTlvs)], payee_tlvs: &ReceiveTlvs
) -> Result<BlindedPayInfo, ()> {
let mut curr_base_fee: u128 = 0;
let mut curr_prop_mil: u128 = 0;
let mut curr_base_fee: u64 = 0;
let mut curr_prop_mil: u64 = 0;
let mut cltv_expiry_delta: u16 = 0;
for (_, tlvs) in intermediate_nodes.iter().rev() {
// In the future, we'll want to take the intersection of all supported features for the
// `BlindedPayInfo`, but there are no features in that context right now.
if tlvs.features.requires_unknown_bits() { return Err(()) }

let next_base_fee = tlvs.payment_relay.fee_base_msat as u128;
let next_prop_mil = tlvs.payment_relay.fee_proportional_millionths as u128;
let next_base_fee = tlvs.payment_relay.fee_base_msat as u64;
let next_prop_mil = tlvs.payment_relay.fee_proportional_millionths as u64;
// Use integer arithmetic to compute `ceil(a/b)` as `(a+b-1)/b`
// ((next_base_fee * 1_000_000 + (curr_base_fee * (1_000_000 + next_prop_mil))) + 1_000_000 - 1) / 1_000_000
curr_base_fee = next_prop_mil.checked_add(1_000_000)
Expand Down

0 comments on commit ca2753c

Please sign in to comment.