diff options
| author | Adam Soltys <[email protected]> | 2023-03-11 10:20:46 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-11 10:20:46 -0800 |
| commit | 5955ff6969a5301c4413631b76cf2300d193f8ed (patch) | |
| tree | 92d1269a098cb7c764ca92f7a40af9ee236ae5b1 /routes/payments.js | |
| parent | 7fec7cc3e7c51a9892869732b5bfe65922ee7818 (diff) | |
| download | coinos-server-5955ff6969a5301c4413631b76cf2300d193f8ed.tar.gz coinos-server-5955ff6969a5301c4413631b76cf2300d193f8ed.zip | |
separate tips from amounts
Diffstat (limited to 'routes/payments.js')
| -rw-r--r-- | routes/payments.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/routes/payments.js b/routes/payments.js index f62eaa6e..a180d0a3 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -36,21 +36,23 @@ export default { }) .json(); } else if (payreq) { + let total = amount; let { msatoshi, payment_hash } = await ln.decode(payreq); - if (msatoshi) amount = Math.round(msatoshi / 1000); + if (msatoshi) total = Math.round(msatoshi / 1000); let invoice = await g(`invoice:${payment_hash}`); if (invoice) { if (invoice.uid === user.id) fail("Cannot send to self"); hash = payment_hash; } else { - p = await debit(hash, amount, maxfee, memo, user, types.lightning); + p = await debit(hash, total, maxfee, memo, user, types.lightning); let r; try { r = await ln.pay(payreq, msatoshi ? undefined : `${amount}sats`); p.amount = -amount; + p.tip = total - amount; p.hash = r.payment_hash; p.fee = Math.round((r.msatoshi_sent - r.msatoshi) / 1000); p.ref = r.payment_preimage; @@ -280,8 +282,6 @@ export default { total = total - change + fee; let amount = total - fee; - console.log("AMOUNT", amount); - if (change && !amount) fail("Cannot send to unregistered coinos address"); await debit(txid, amount, fee, null, user, types.bitcoin, txid); |
