Skip to content

Commit

Permalink
Max fee
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabrozzoni committed Apr 28, 2024
1 parent 56c1599 commit 2ddbb71
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const OPENCHANNEL_MIN_RGB_AMT: u64 = 1;
const DUST_LIMIT_MSAT: u64 = 546000;

pub(crate) const HTLC_MIN_MSAT: u64 = 3000000;
pub(crate) const MAX_SWAP_FEE_MSAT: u64 = HTLC_MIN_MSAT;

const INVOICE_MIN_MSAT: u64 = HTLC_MIN_MSAT;

Expand Down Expand Up @@ -1653,6 +1654,21 @@ pub(crate) async fn maker_execute(
}))
.collect::<Vec<_>>();

// Skip last fee because it's equal to the payment amount
let total_fee = fullpaths
.iter()
.rev()
.skip(1)
.map(|hop| hop.fee_msat)
.sum::<u64>();

if total_fee >= MAX_SWAP_FEE_MSAT {
return Err(APIError::FailedPayment(format!(
"Fee too high: {}",
total_fee
)));
}

let route = Route {
paths: vec![LnPath {
hops: fullpaths,
Expand Down

0 comments on commit 2ddbb71

Please sign in to comment.