MCPcopy Create free account
hub / github.com/ElementsProject/lightning / compute_opening_fee

Function compute_opening_fee

plugins/lsps-plugin/src/proto/lsps2.rs:356–366  ·  view source on GitHub ↗

Computes the opening fee in millisatoshis as described in LSPS2. Returns None if an arithmetic overflow occurs during calculation. # Arguments `payment_size_msat` - The size of the payment for which the channel is being opened. `opening_fee_min_fee_msat` - The minimum fee to be paid by the client to the LSP `opening_fee_proportional` - The proportional fee charged by the LSP

(
    payment_size_msat: u64,
    opening_fee_min_fee_msat: u64,
    opening_fee_proportional: u64,
)

Source from the content-addressed store, hash-verified

354/// the LSP
355/// * `opening_fee_proportional` - The proportional fee charged by the LSP
356pub fn compute_opening_fee(
357 payment_size_msat: u64,
358 opening_fee_min_fee_msat: u64,
359 opening_fee_proportional: u64,
360) -> Option<u64> {
361 payment_size_msat
362 .checked_mul(opening_fee_proportional)
363 .and_then(|f| f.checked_add(999999))
364 .and_then(|f| f.checked_div(1000000))
365 .map(|f| std::cmp::max(f, opening_fee_min_fee_msat))
366}
367
368#[cfg(test)]
369mod tests {

Callers 5

on_lsps_lsps2_buyFunction · 0.85
on_lsps_lsps2_invoiceFunction · 0.85
validateMethod · 0.85
handleMethod · 0.85
handleMethod · 0.85

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected