diff options
| author | Adam Soltys <[email protected]> | 2021-05-13 18:32:50 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-06-04 22:38:18 -0700 |
| commit | dc32621a049467658320e48ffd62ee64d59a71b0 (patch) | |
| tree | 232c01a7589cbb2c063e43c1feb9a69e21c7bd00 | |
| parent | fd758f1afb5f8b18b41a2f924382f0e159bc34be (diff) | |
| download | coinos-server-dc32621a049467658320e48ffd62ee64d59a71b0.tar.gz coinos-server-dc32621a049467658320e48ffd62ee64d59a71b0.zip | |
validate invoice amount
| -rw-r--r-- | routes/invoices.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/routes/invoices.js b/routes/invoices.js index cc8549e1..f7682bfe 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -43,7 +43,8 @@ app.post( if (!user) throw new Error("user not provided"); if (!invoice.currency) invoice.currency = user.currency; if (!invoice.rate) invoice.rate = app.get("rates")[invoice.currency]; - if (invoice.tip > invoice.amount || invoice.tip > 1000000) throw new Error("tip is too large") + if (invoice.tip > invoice.amount || invoice.tip > 1000000) throw new Error("tip is too large"); + if (invoice.tip < 0 || invoice.amount < 0) throw new Error("invalid amount"); invoice.user_id = user.id; invoice.account_id = user.account_id; |
