Skip to content

Commit

Permalink
f Streamline max_total_opening_fee_msat calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Feb 6, 2024
1 parent 5d20cfa commit 6beb61c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,17 @@ where
return;
}

let max_total_opening_fee_msat = if let Some(max_total_opening_fee_msat) =
info.lsp_fee_limits.and_then(|l| l.max_total_opening_fee_msat)
{
max_total_opening_fee_msat
} else if let Some(max_proportional_opening_fee_ppm_msat) =
info.lsp_fee_limits.and_then(|l| l.max_proportional_opening_fee_ppm_msat)
{
// If it's a variable amount payment, compute the actual total opening fee.
compute_opening_fee(amount_msat, 0, max_proportional_opening_fee_ppm_msat)
.unwrap_or(0)
} else {
0
};
let max_total_opening_fee_msat = info
.lsp_fee_limits
.and_then(|l| {
l.max_total_opening_fee_msat.or_else(|| {
l.max_proportional_opening_fee_ppm_msat.and_then(|max_prop_fee| {
// If it's a variable amount payment, compute the actual fee.
compute_opening_fee(amount_msat, 0, max_prop_fee)
})
})
})
.unwrap_or(0);

if counterparty_skimmed_fee_msat > max_total_opening_fee_msat {
log_info!(
Expand Down

0 comments on commit 6beb61c

Please sign in to comment.