diff options
| author | Adam Soltys <[email protected]> | 2020-06-30 16:22:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-06-30 16:22:44 -0700 |
| commit | 5e3846b7b8ad2e0fe11cade9c28a1fb0a3322b5d (patch) | |
| tree | f62a6976c4d619f6fb7448217b77f919e9f03ff6 | |
| parent | cf4e234edd9aa01bf99019e209ddd512c8cf2607 (diff) | |
| download | coinos-server-5e3846b7b8ad2e0fe11cade9c28a1fb0a3322b5d.tar.gz coinos-server-5e3846b7b8ad2e0fe11cade9c28a1fb0a3322b5d.zip | |
track unconfidential addresses for liquid invoices
| -rw-r--r-- | db/models/invoices.js | 9 | ||||
| -rw-r--r-- | routes/invoices.js | 5 | ||||
| -rw-r--r-- | routes/payments.js | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/db/models/invoices.js b/db/models/invoices.js index a2485ec5..229f92b8 100644 --- a/db/models/invoices.js +++ b/db/models/invoices.js @@ -73,6 +73,15 @@ const attributes = { comment: null, field: "currency" }, + unconfidential: { + type: DataTypes.STRING(255), + allowNull: true, + defaultValue: null, + primaryKey: false, + autoIncrement: false, + comment: null, + field: "unconfidential" + }, address: { type: DataTypes.STRING(255), allowNull: true, diff --git a/routes/invoices.js b/routes/invoices.js index c6bf4b6e..bb2673cc 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -6,6 +6,10 @@ app.post("/invoice", auth, async (req, res) => { l.info("creating invoice", invoice.text, req.user.username, invoice.network, invoice.amount, invoice.tip, invoice.currency, invoice.rate.toFixed(2)); + if (invoice.network === 'LBTC') { + invoice.unconfidential = (await lq.getAddressInfo(invoice.address)).unconfidential; + } + const exists = await db.Invoice.findOne({ where: { [Op.or]: { @@ -15,6 +19,7 @@ app.post("/invoice", auth, async (req, res) => { } }); + res.send( exists ? await exists.update(invoice) : await db.Invoice.create(invoice) ); diff --git a/routes/payments.js b/routes/payments.js index f82262df..63ecb70b 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -21,6 +21,7 @@ const { join } = require("path"); as: 'user'}] }).map(i => { if (i.address && i.user) addresses[i.address] = i.user.username; + if (i.unconfidential && i.user) addresses[i.unconfidential] = i.user.username; }); payments = ( |
