From 51413aa3d23260d8c244ed2015a1ca58b24ab5cb Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 8 Oct 2022 04:11:24 +0000 Subject: log payment id --- lib/sync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sync.js b/lib/sync.js index eeff7362..b2020acd 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -251,7 +251,7 @@ const sync = async () => { emit(p.user.username, "account", p.account); emit(p.user.username, "payment", p); } catch (e) { - err("problem confirming payment", p, e.message, e.stack); + err("problem confirming payment", p.id, e.message, e.stack); } } -- cgit v1.2.3 From c8ad07959fe5437064dbcc61bc12b4e52103fff7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 8 Oct 2022 04:12:23 +0000 Subject: check for invoice --- lib/sync.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/sync.js b/lib/sync.js index b2020acd..df7c812f 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -243,7 +243,9 @@ const sync = async () => { l("confirming payment", p.id, p.user_id, p.hash, p.address); await p.save({ transaction }); - await p.invoice.increment({ received: p.amount }, { transaction }); + if (p.invoice) + await p.invoice.increment({ received: p.amount }, { transaction }); + await p.account.increment({ balance: p.amount }, { transaction }); await p.account.decrement({ pending: p.amount }, { transaction }); }); -- cgit v1.2.3 From 6a7b6678f4a1cc562a6c1d82414ed28a91ba4574 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 8 Oct 2022 06:29:24 +0000 Subject: schema --- Caddyfile | 4 ++++ db/schema.sql | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Caddyfile b/Caddyfile index 326054ae..3e41ca11 100644 --- a/Caddyfile +++ b/Caddyfile @@ -3,6 +3,10 @@ reverse_proxy app:3119 } + handle_path /.well-known* { + reverse_proxy app:3119 + } + handle /lnurl* { reverse_proxy app:3118 } diff --git a/db/schema.sql b/db/schema.sql index 22dfcd54..4f7e9b7d 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -70,7 +70,7 @@ CREATE TABLE `accounts` ( `lightning_credits` double NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `asset` (`asset`) -) ENGINE=InnoDB AUTO_INCREMENT=38821 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=38966 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -136,7 +136,7 @@ CREATE TABLE `invoices` ( `rate` double DEFAULT NULL, `currency` varchar(255) NOT NULL, `address` varchar(255) DEFAULT NULL, - `received` double DEFAULT NULL, + `received` bigint(20) DEFAULT NULL, `amount` double DEFAULT NULL, `tip` double DEFAULT NULL, `network` varchar(255) DEFAULT NULL, @@ -147,6 +147,7 @@ CREATE TABLE `invoices` ( `path` varchar(255) DEFAULT NULL, `webhook` text DEFAULT NULL, `status` varchar(255) DEFAULT 'unpaid', + `prompt` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `part_of_unconfidential` (`unconfidential`(10)), KEY `text_index` (`text`(100)), @@ -156,7 +157,7 @@ CREATE TABLE `invoices` ( KEY `invoices_account_id_foreign` (`account_id`), KEY `invoices_time_index` (`createdAt`), KEY `uuid` (`uuid`(10)) -) ENGINE=InnoDB AUTO_INCREMENT=371007 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=372769 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -173,7 +174,7 @@ CREATE TABLE `linkingkeys` ( `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=26671 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=26721 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -304,7 +305,7 @@ CREATE TABLE `payments` ( KEY `payments_time_index` (`createdAt`), KEY `hash` (`hash`(10)), CONSTRAINT `fk_account_id` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=206858 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=208429 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -508,10 +509,11 @@ CREATE TABLE `users` ( `profile` tinyint(1) DEFAULT 0, `banner` tinyint(1) DEFAULT 0, `theme` varchar(255) DEFAULT NULL, + `uuid` varchar(255) NOT NULL DEFAULT uuid(), PRIMARY KEY (`id`), KEY `ip` (`ip`), KEY `username` (`username`) -) ENGINE=InnoDB AUTO_INCREMENT=29734 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=29850 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -570,4 +572,4 @@ CREATE TABLE `withdrawals` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-09-24 16:23:35 +-- Dump completed on 2022-10-08 6:29:13 -- cgit v1.2.3 From 68a4352c18191654eb10e0c976168ac729041d0a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 8 Oct 2022 07:04:28 +0000 Subject: fix lightning conversions --- routes/invoices.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/invoices.js b/routes/invoices.js index 14efdf2a..7c11bac3 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -68,8 +68,8 @@ app.post("/invoice", optionalAuth, async (req, res, next) => { throw new Error("tip amount out of range"); if (liquidAddress) { - l("conversion request for", liquidAddress, invoice.text); - store.convert[invoice.text] = { address: liquidAddress, tx }; + l("conversion request for", liquidAddress, text); + store.convert[text] = { address: liquidAddress, tx }; } if (!user) ({ user } = req); -- cgit v1.2.3 From 11052f0f494707206a9f6a245d6c24a9090ebf78 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 8 Oct 2022 07:06:08 +0000 Subject: fix lightning conversions --- routes/invoices.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/routes/invoices.js b/routes/invoices.js index 7c11bac3..bdb889a2 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -67,11 +67,6 @@ app.post("/invoice", optionalAuth, async (req, res, next) => { if (tip > amount || tip > 1000000 || tip < 0) throw new Error("tip amount out of range"); - if (liquidAddress) { - l("conversion request for", liquidAddress, text); - store.convert[text] = { address: liquidAddress, tx }; - } - if (!user) ({ user } = req); else { user = await db.User.findOne({ @@ -125,6 +120,11 @@ app.post("/invoice", optionalAuth, async (req, res, next) => { invoice.text = bip21(invoice, user.account); } + if (liquidAddress) { + l("conversion request for", liquidAddress, text); + store.convert[text] = { address: liquidAddress, tx }; + } + l( "creating invoice", user.username, -- cgit v1.2.3