aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/nostr.js7
-rw-r--r--lib/payments.js8
-rw-r--r--routes/lnurl.js1
-rw-r--r--routes/payments.js2
4 files changed, 11 insertions, 7 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))
diff --git a/routes/lnurl.js b/routes/lnurl.js
index 011db286..fa1c1944 100644
--- a/routes/lnurl.js
+++ b/routes/lnurl.js
@@ -47,6 +47,7 @@ export default {
async lnurlp({ params: { username } }, res) {
try {
+ l("lnurlp request", username);
let { id: uid, pubkey: nostrPubkey } = await getUser(username);
let metadata = JSON.stringify([
diff --git a/routes/payments.js b/routes/payments.js
index 9df9abb6..98c24b33 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -79,7 +79,7 @@ export default {
res.send(p);
} catch (e) {
warn(e.message);
- warn("failed to create payment", username, amount, hash, payreq);
+ warn("failed to create payment", user.username, amount, hash, payreq);
bail(res, e.message);
}
},