aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-12-05 04:05:02 +0000
committerAdam Soltys <[email protected]>2023-12-05 04:05:26 +0000
commitece2e424fb00a5480b1cf0630ee6c237ec1c170a (patch)
tree466814b6582e9d0fbfe0746ec4d07cfd38bcd45f /lib
parent7709c1efde9a1f3078171ee56985cd25511d6f7b (diff)
downloadcoinos-server-ece2e424fb00a5480b1cf0630ee6c237ec1c170a.tar.gz
coinos-server-ece2e424fb00a5480b1cf0630ee6c237ec1c170a.zip
logs
Diffstat (limited to 'lib')
-rw-r--r--lib/nostr.js7
-rw-r--r--lib/payments.js8
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/nostr.js b/lib/nostr.js
index f75da37c..31fc450b 100644
--- a/lib/nostr.js
+++ b/lib/nostr.js
@@ -1,4 +1,5 @@
import config from "$config";
+import { l } from "$lib/logging";
import { Relay, RelayPool, calculateId, signId, getPublicKey } from "nostr";
import { broadcast, emit } from "$lib/sockets";
import store from "$lib/store";
@@ -208,7 +209,7 @@ function send(ev, url, opts) {
}
export async function handleZap(invoice) {
- let privkey = nip19.decode(config.nostrKey);
+ let { data: privkey } = nip19.decode(config.nostrKey);
let pubkey = getPublicKey(privkey);
let keypair = { privkey, pubkey };
let zapreq = JSON.parse(invoice.description);
@@ -260,5 +261,7 @@ export async function handleZap(invoice) {
ev.id = await calculateId(ev);
ev.sig = await signId(privkey, ev.id);
- await Promise.all(relays.map((r) => send(ev, r)));
+ l("sending receipt", JSON.stringify(ev), relays);
+
+ await Promise.allSettled(relays.map(r => send(ev, r)));
}
diff --git a/lib/payments.js b/lib/payments.js
index 5152806a..8d7a7ff0 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -23,7 +23,7 @@ export const types = {
bitcoin: "bitcoin",
lightning: "lightning",
fund: "fund",
- classic: "classic"
+ classic: "classic",
};
export let debit = async (
@@ -91,7 +91,7 @@ export let debit = async (
type,
ref,
tip,
- created: Date.now()
+ created: Date.now(),
};
await s(`payment:${id}`, p);
@@ -153,7 +153,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
tip,
type,
confirmed: true,
- created: Date.now()
+ created: Date.now(),
};
if (type === types.bitcoin) invoice.pending += amount;
@@ -291,7 +291,7 @@ export let payLightning = async (user, payreq, amount, maxfee, memo) => {
bolt11: payreq.replace(/\s/g, "").toLowerCase(),
amount_msat: amount_msat ? undefined : amount * 1000,
maxfee: maxfee * 1000,
- retry_for: 5
+ retry_for: 5,
});
if (!(r.status === "complete" && r.payment_preimage))