diff options
| author | Adam Soltys <[email protected]> | 2021-08-03 01:52:33 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-08-03 01:52:33 -0700 |
| commit | e5e2bcf015b128c71cacf125d6aea4a0dddd30c3 (patch) | |
| tree | 09af4085f72fa2466cb0f66768be6e882be30f81 /routes/lightning | |
| parent | 2f52a91c5babde9e374dd9c532448f565bcbfeee (diff) | |
| parent | 1fbae57bb9540b1c116efc367809ac01ae2e9df2 (diff) | |
| download | coinos-server-e5e2bcf015b128c71cacf125d6aea4a0dddd30c3.tar.gz coinos-server-e5e2bcf015b128c71cacf125d6aea4a0dddd30c3.zip | |
Merge branch 'prod' into dev
Diffstat (limited to 'routes/lightning')
| -rw-r--r-- | routes/lightning/receive.js | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index 32c54de6..8d2aa750 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -1,20 +1,18 @@ const handlePayment = async msg => { + if (!msg.settled) return; let account, total, user; - try { - await db.transaction(async transaction => { - if (!msg.settled) return; - const invoice = await db.Invoice.findOne({ - where: { - text: msg.payment_request - } - }); + const invoice = await db.Invoice.findOne({ + where: { + text: msg.payment_request + } + }); - if (!invoice) - return l.warn( - "received lightning with no invoice", - msg.payment_request - ); + if (!invoice) + return l.warn("received lightning with no invoice", msg.payment_request); + + try { + await db.transaction(async transaction => { const { text: hash, currency, memo, rate, tip, user_id } = invoice; const amount = parseInt(msg.amt_paid_sat) - tip; @@ -85,7 +83,12 @@ const handlePayment = async msg => { let c = convert[msg.payment_request]; if (msg.payment_request && c) { - l.info("lightning detected for conversion request", msg.payment_request, c.address, user.username); + l.info( + "lightning detected for conversion request", + msg.payment_request, + c.address, + user.username + ); user.account = account; |
