diff options
| -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 = ( |
