aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-12-12 06:07:30 +0000
committerAdam Soltys <[email protected]>2023-12-12 06:07:34 +0000
commit74d0ea356c9cdf5b393d4260c1c299c3aaac7ed6 (patch)
treef48e324a93a538d7044e51e3c4cd5f9d03d1b387
parent63fe7c28cc433f211a13634a65b7d9ac17949311 (diff)
downloadcoinos-server-74d0ea356c9cdf5b393d4260c1c299c3aaac7ed6.tar.gz
coinos-server-74d0ea356c9cdf5b393d4260c1c299c3aaac7ed6.zip
default maxfee to 5% of total
-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}`);