aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-09-03 20:48:31 -0700
committerAdam Soltys <[email protected]>2023-09-03 20:48:35 -0700
commit3aa200db295438827bfff48f80e3f4b25f44e8ea (patch)
treea5520366ec430ed0b2cdf86f971bb006ffd5b0da /lib
parent0d7574597d33bad78f4ebad3c38b956debb0e699 (diff)
downloadcoinos-server-3aa200db295438827bfff48f80e3f4b25f44e8ea.tar.gz
coinos-server-3aa200db295438827bfff48f80e3f4b25f44e8ea.zip
use bolt11 for invoice hash
Diffstat (limited to 'lib')
-rw-r--r--lib/invoices.js20
-rw-r--r--lib/lightning.js9
2 files changed, 12 insertions, 17 deletions
diff --git a/lib/invoices.js b/lib/invoices.js
index b4583ea1..2e5a8e64 100644
--- a/lib/invoices.js
+++ b/lib/invoices.js
@@ -38,19 +38,15 @@ export let generate = async ({ invoice, user, sender, memo }) => {
let hash, text;
if (type === types.lightning) {
- let r = await ln.invoice(
- amount ? `${amount + tip}sat` : "any",
- new Date(),
- memo || "",
- expiry || 3600,
- undefined,
- undefined,
- undefined,
- undefined,
- true
- );
+ let r = await ln.invoice({
+ amount_msat: amount ? `${amount + tip}sat` : "any",
+ label: new Date(),
+ description: memo || "",
+ expiry: expiry || 3600,
+ deschashonly: true
+ });
- hash = r.payment_hash;
+ hash = r.bolt11;
text = r.bolt11;
} else if (type === types.bitcoin) {
hash = await bc.getNewAddress();
diff --git a/lib/lightning.js b/lib/lightning.js
index 1ccdbaa4..0c5fd75e 100644
--- a/lib/lightning.js
+++ b/lib/lightning.js
@@ -10,7 +10,6 @@ import { credit, types } from "$lib/payments";
export async function listenForLightning() {
let event = await ln.waitanyinvoice(await g("pay_index"));
let {
- payment_hash: hash,
bolt11,
pay_index,
status,
@@ -28,13 +27,13 @@ export async function listenForLightning() {
if (!preimage) return;
- let invoice = await g(`invoice:${hash}`);
+ let invoice = await g(`invoice:${bolt11}`);
if (!invoice) return warn("received lightning with no invoice", bolt11);
- let payment = await g(`payment:${hash}`);
- if (payment) return warn("already processed", hash);
+ let payment = await g(`payment:${bolt11}`);
+ if (payment) return warn("already processed", bolt11);
- await credit(hash, received, invoice.memo, preimage, types.lightning);
+ await credit(bolt11, received, invoice.memo, preimage, types.lightning);
} catch (e) {
console.log(e);
err("problem receiving lightning payment", e.message);