aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-10 22:17:27 -0700
committerAdam Soltys <[email protected]>2024-10-10 22:17:27 -0700
commitc8adb5633c75d1767f54bac9e9d025d6efa2eb87 (patch)
tree8fe2327986ae6d59897531bc3482bc36edc4a848
parentc6de0ae7abe22d23bb72e2bcbcfc9c08dca93018 (diff)
downloadcoinos-server-c8adb5633c75d1767f54bac9e9d025d6efa2eb87.tar.gz
coinos-server-c8adb5633c75d1767f54bac9e9d025d6efa2eb87.zip
check for internal payments
-rw-r--r--routes/payments.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/routes/payments.ts b/routes/payments.ts
index d8213e2a..fdeecde6 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -444,12 +444,16 @@ export default {
let r: any = await got(`${callback}?amount=${amount * 1000}`).json();
if (r.reason) fail(r.reason);
let { pr } = r;
- let p = await sendLightning({ user, pr, amount, maxfee, memo });
- if (!p) {
+ let { payee } = await ln.decode(pr);
+ let { id } = await ln.getinfo();
+
+ let p;
+ if (payee === id){
p = await debit({ hash: pr, amount, memo, user });
await credit({ hash: pr, amount, memo, ref: user.id });
- }
+ } else p = await sendLightning({ user, pr, amount, maxfee, memo });
+
res.send(p);
} catch (e) {