diff options
| author | Adam Soltys <[email protected]> | 2020-07-17 20:55:47 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-07-17 20:55:59 -0700 |
| commit | 1962a6dcf1bb37bb8beb3fc4c0231d5a504a75fe (patch) | |
| tree | 46ffa53e3f7ebbdb2ea9c9abd1cf64405e1410cd /routes | |
| parent | 4a8abaa2722b629cebebb677249c3fd4f51292fb (diff) | |
| download | coinos-server-1962a6dcf1bb37bb8beb3fc4c0231d5a504a75fe.tar.gz coinos-server-1962a6dcf1bb37bb8beb3fc4c0231d5a504a75fe.zip | |
memos
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/bitcoin/receive.js | 2 | ||||
| -rw-r--r-- | routes/bitcoin/send.js | 3 | ||||
| -rw-r--r-- | routes/lightning/invoice.js | 7 | ||||
| -rw-r--r-- | routes/lightning/receive.js | 3 | ||||
| -rw-r--r-- | routes/lightning/send.js | 5 | ||||
| -rw-r--r-- | routes/liquid/receive.js | 2 | ||||
| -rw-r--r-- | routes/liquid/send.js | 3 | ||||
| -rw-r--r-- | routes/send.js | 4 |
8 files changed, 19 insertions, 10 deletions
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js index 131166bc..f4fd4294 100644 --- a/routes/bitcoin/receive.js +++ b/routes/bitcoin/receive.js @@ -55,6 +55,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => { const currency = invoice ? invoice.currency : user.currency; const rate = invoice ? invoice.rate : app.get("rates")[user.currency]; const tip = invoice ? invoice.tip : 0; + const memo = invoice ? invoice.memo : ''; let confirmed = false; @@ -92,6 +93,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => { user_id: user.id, hash, fee, + memo, amount: value - tip, currency, rate, diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js index 2ab28054..fcdcb298 100644 --- a/routes/bitcoin/send.js +++ b/routes/bitcoin/send.js @@ -3,7 +3,7 @@ const reverse = require("buffer-reverse"); module.exports = async (req, res) => { let { user } = req; - let { address, tx } = req.body; + let { address, memo, tx } = req.body; let { hex } = tx; let fee = toSats(tx.fee); @@ -56,6 +56,7 @@ module.exports = async (req, res) => { params = { amount: -total, fee, + memo, account_id: account.id, user_id: user.id, rate: app.get("rates")[user.currency], diff --git a/routes/lightning/invoice.js b/routes/lightning/invoice.js index 3b453a73..682fe542 100644 --- a/routes/lightning/invoice.js +++ b/routes/lightning/invoice.js @@ -1,14 +1,15 @@ module.exports = async (req, res) => { - const { amount, tip } = req.body; + const { amount, memo, tip } = req.body; l.info("adding lightning invoice", req.user.username, amount, tip); try { if (config.lna.clightning) { - const invoice = await lnb.invoice(`${amount + tip}sat` || "any", new Date(), "", 360); + const invoice = await lnb.invoice(`${amount + tip}sat` || "any", new Date(), memo, 360); res.send(invoice.bolt11); } else { - const invoice = await lnb.addInvoice({ value: amount + tip }); + const invoice = await lnb.addInvoice({ value: amount + tip, memo }); + l.info("invoice", invoice); res.send(invoice.payment_request); } } catch (e) { diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index 292f19e2..34ac1fc3 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -13,7 +13,7 @@ const handlePayment = async msg => { if (!invoice) return l.warn("received lightning with no invoice", msg.payment_request); - const { text: hash, currency, rate, tip, user_id } = invoice; + const { text: hash, currency, memo, rate, tip, user_id } = invoice; const amount = parseInt(msg.amt_paid_sat) - tip; const account = await db.Account.findOne({ @@ -37,6 +37,7 @@ const handlePayment = async msg => { account_id: account.id, user_id, hash, + memo, amount, currency, preimage, diff --git a/routes/lightning/send.js b/routes/lightning/send.js index 9aa4ddaf..be68143e 100644 --- a/routes/lightning/send.js +++ b/routes/lightning/send.js @@ -1,10 +1,9 @@ module.exports = async (req, res) => { - let { payreq } = req.body; - let { amount, route } = req.body; + let { amount, route, memo, payreq } = req.body; let { user } = req; try { - res.send(await send(amount, payreq, user)); + res.send(await send(amount, memo, payreq, user)); } catch (e) { l.error("problem sending lightning payment", user.username, e.message); res.status(500).send(e.message); diff --git a/routes/liquid/receive.js b/routes/liquid/receive.js index f6783eee..45419ecb 100644 --- a/routes/liquid/receive.js +++ b/routes/liquid/receive.js @@ -100,6 +100,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => { const currency = invoice ? invoice.currency : user.currency; const rate = invoice ? invoice.rate : app.get("rates")[user.currency]; const tip = invoice ? invoice.tip : 0; + const memo = invoice ? invoice.memo : ''; let payment = await db.Payment.create({ account_id: account.id, @@ -107,6 +108,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => { hash: blinded.txid, amount: value - tip, currency, + memo, rate, received: true, tip, diff --git a/routes/liquid/send.js b/routes/liquid/send.js index 35a155ec..a443edf3 100644 --- a/routes/liquid/send.js +++ b/routes/liquid/send.js @@ -2,7 +2,7 @@ const reverse = require("buffer-reverse"); module.exports = async (req, res) => { let { user } = req; - let { address, tx } = req.body; + let { address, memo, tx } = req.body; const isChange = async (address) => (await lq.getAddressInfo(address)).ismine && @@ -72,6 +72,7 @@ module.exports = async (req, res) => { amount: -total, account_id: account.id, fee, + memo, user_id: user.id, rate: app.get("rates")[user.currency], currency: user.currency, diff --git a/routes/send.js b/routes/send.js index 8b4137d8..d2ba3e5d 100644 --- a/routes/send.js +++ b/routes/send.js @@ -1,7 +1,7 @@ const axios = require("axios"); module.exports = async (req, res) => { - let { amount, asset, username } = req.body; + let { amount, asset, memo, username } = req.body; let { user } = req; l.info("attempting internal payment", user.username, amount); @@ -32,6 +32,7 @@ module.exports = async (req, res) => { { amount: -amount, account_id: account.id, + memo, user_id: user.id, rate: app.get("rates")[user.currency], currency: user.currency, @@ -111,6 +112,7 @@ module.exports = async (req, res) => { currency: user.currency, confirmed: true, hash: "Internal Transfer", + memo, network: "COINOS", received: true }, |
