diff options
| author | Adam Soltys <[email protected]> | 2022-10-08 00:34:34 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-10-08 00:34:34 -0700 |
| commit | 0fbba88257d0259f59ef86e34d83987d74824030 (patch) | |
| tree | 76c5b023755ede0f9075f5134dd5ff6aff538b06 | |
| parent | 6eb65756c0945c149825f2fbe0f6cf173ffee2ef (diff) | |
| parent | 11052f0f494707206a9f6a245d6c24a9090ebf78 (diff) | |
| download | coinos-server-0fbba88257d0259f59ef86e34d83987d74824030.tar.gz coinos-server-0fbba88257d0259f59ef86e34d83987d74824030.zip | |
Merge remote-tracking branch 'origin/prod'
| -rw-r--r-- | Caddyfile | 4 | ||||
| -rw-r--r-- | db/schema.sql | 16 | ||||
| -rw-r--r-- | lib/sync.js | 6 | ||||
| -rw-r--r-- | routes/invoices.js | 10 |
4 files changed, 22 insertions, 14 deletions
@@ -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 diff --git a/lib/sync.js b/lib/sync.js index eeff7362..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 }); }); @@ -251,7 +253,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); } } diff --git a/routes/invoices.js b/routes/invoices.js index 14efdf2a..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, invoice.text); - store.convert[invoice.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, |
