diff options
| -rw-r--r-- | lib/sendInternal.js | 7 | ||||
| -rw-r--r-- | routes/invoices.js | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/sendInternal.js b/lib/sendInternal.js index 640587b5..7204f769 100644 --- a/lib/sendInternal.js +++ b/lib/sendInternal.js @@ -13,7 +13,7 @@ import { fail } from "$lib/utils"; const { HOSTNAME: hostname } = process.env; export default async ( - { amount, address, payreq, unconfidential, asset, memo, username }, + { amount, address, payreq, unconfidential, asset, memo, username, tip }, user ) => { amount = parseInt(amount); @@ -144,7 +144,12 @@ export default async ( }; if (invoice) { + let { tip } = invoice; params.invoice_id = invoice.id; + if (tip) { + params.tip = tip; + params.amount -= tip; + } await invoice.increment({ received: amount }, { transaction }); await invoice.reload({ transaction }); diff --git a/routes/invoices.js b/routes/invoices.js index 16abab84..6e0fe358 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -64,7 +64,7 @@ app.post("/invoice", optionalAuth, async (req, res, next) => { let address, unconfidential, text; if (amount < 0) throw new Error("amount out of range"); - if (tip > 5 * amount || tip > 1000000 || tip < 0) + if (tip > 5 * amount || tip < 0) throw new Error("tip amount out of range"); if (!user) ({ user } = req); |
