Skip to content

Commit

Permalink
Accomodate routing fees while calculating min clear wallet amount (#1113
Browse files Browse the repository at this point in the history
)
  • Loading branch information
andrei-21 authored Jun 21, 2024
1 parent 0140506 commit fb59134
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2363,9 +2363,12 @@ impl LightningNode {
.as_msats()
.sats_round_down();
let exchange_rate = self.get_exchange_rate();

// Accomodating lightning network routing fees.
let min = limits.min + limits.min * (MAX_FEE_PERMYRIAD as u64) / 10000;
let range_hit = match balance_sat {
balance_sat if balance_sat < limits.min => RangeHit::Below {
min: limits.min.as_sats().to_amount_up(&exchange_rate),
balance_sat if balance_sat < min => RangeHit::Below {
min: min.as_sats().to_amount_up(&exchange_rate),
},
balance_sat if balance_sat <= limits.max => RangeHit::In,
balance_sat if limits.max < balance_sat => RangeHit::Above {
Expand Down

0 comments on commit fb59134

Please sign in to comment.