diff options
| author | Adam Soltys <[email protected]> | 2021-05-13 18:32:50 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-05-13 20:03:27 -0400 |
| commit | 8ede8b87045655c79c389fdc312c7ca01b1140da (patch) | |
| tree | 3a588fd0e44638386a9cc0aa65851d8c52ea3668 | |
| parent | 3eec4e9440933202e8410044cee2962f5def0e2d (diff) | |
| download | coinos-server-8ede8b87045655c79c389fdc312c7ca01b1140da.tar.gz coinos-server-8ede8b87045655c79c389fdc312c7ca01b1140da.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 a1928287..9ab52de3 100644 --- a/routes/invoices.js +++ b/routes/invoices.js @@ -40,7 +40,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; |
