aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-02-23 12:56:52 -0800
committerAdam Soltys <[email protected]>2024-02-23 12:56:52 -0800
commit72902b574d1e9ed4669878bc68fd284bf49b6e98 (patch)
treeb77f16cc4307b9fde3e2b193ea4940df1460f310 /lib
parent5fc1a00db108671022cb6cd690e4a0a8932476f5 (diff)
downloadcoinos-server-72902b574d1e9ed4669878bc68fd284bf49b6e98.tar.gz
coinos-server-72902b574d1e9ed4669878bc68fd284bf49b6e98.zip
constrain memo length
Diffstat (limited to 'lib')
-rw-r--r--lib/invoices.js2
-rw-r--r--lib/payments.js1
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/invoices.js b/lib/invoices.js
index 6962898a..89c4f3d6 100644
--- a/lib/invoices.js
+++ b/lib/invoices.js
@@ -28,6 +28,7 @@ export let generate = async ({ invoice, user, sender, }) => {
secret,
} = invoice;
+
amount = parseInt(amount || 0);
tip = parseInt(tip) || null;
@@ -39,6 +40,7 @@ export let generate = async ({ invoice, user, sender, }) => {
if (!rate) rate = store.rates[currency];
if (fiat) amount = Math.round((SATS * fiat) / rate);
if (amount < 0) fail("invalid amount");
+ if (memo && memo.length > 200) fail("memo too long");
let id = v4();
diff --git a/lib/payments.js b/lib/payments.js
index 54c901e6..ea17783b 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -132,6 +132,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
tip = parseInt(tip) || 0;
if (!memo) ({ memo } = inv);
+ if (memo && memo.length > 200) fail("memo too long");
if (amount < 0 || tip < 0) fail("Invalid amount");
if (type === types.internal) amount += tip;