aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/payments.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/payments.js b/lib/payments.js
index f53fc2c4..e7674f4e 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -236,13 +236,14 @@ export let payLightning = async (user, payreq, amount, maxfee, memo) => {
if (amount < 0 || amount > SATS || isNaN(amount)) fail("Invalid amount");
}
- maxfee = maxfee ? parseInt(maxfee) : 0;
- if (maxfee < 0) fail("Max fee cannot be negative");
let total = amount;
let { amount_msat, payment_hash } = await ln.decode(payreq);
if (amount_msat) total = Math.round(amount_msat / 1000);
+ maxfee = maxfee ? parseInt(maxfee) : Math.round(total * 0.05);
+ if (maxfee < 0) fail("Max fee cannot be negative");
+
let iid = await g(`invoice:${hash}`);
if (iid && iid.hash) iid = iid.hash;
let invoice = await g(`invoice:${iid}`);