aboutsummaryrefslogtreecommitdiffstats
path: root/lib/send.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/send.js')
-rw-r--r--lib/send.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/send.js b/lib/send.js
index 77d954f6..9d70b34e 100644
--- a/lib/send.js
+++ b/lib/send.js
@@ -9,6 +9,7 @@ import {
conversionFeeReceiver
} from "../routes/lightning/conversionFee";
import lnd from "$lib/lnd";
+import ln from "$lib/ln";
import { payViaPaymentRequest } from "lightning";
import { l, warn, err } from "$lib/logging";
@@ -89,7 +90,9 @@ export default async (amount, memo, hash, user) => {
let tokens;
if (!payreq.satoshis) tokens = amount;
- let m = await payViaPaymentRequest({
+ let m;
+ if (config.lnd) {
+ m = await payViaPaymentRequest({
lnd,
request: hash,
max_fee: Math.min(10000, account.balance)
@@ -97,8 +100,19 @@ export default async (amount, memo, hash, user) => {
if (!m) throw new Error(`lightning payment failed ${amount} ${hash}`);
if (m.payment_error) throw new Error(m.payment_error);
-
({ fee, secret: preimage, tokens: total } = m);
+ } else {
+ m = await ln.pay(hash, tokens ? `${tokens}sats` : undefined);
+ let sent;
+ ({
+ msatoshi: total,
+ msatoshi_sent: sent,
+ payment_preimage: preimage
+ } = m);
+
+ fee = parseInt((sent - total) / 1000);
+ total = parseInt(total / 1000);
+ }
preimage = preimage.toString("hex");