From 2d0dcd8a34fe4bc641c0d0653458edb215e572ed Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 19 Feb 2021 13:09:38 -0500 Subject: check for high fee hints --- lib/send.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/send.js') diff --git a/lib/send.js b/lib/send.js index 6aff80c4..6952368c 100644 --- a/lib/send.js +++ b/lib/send.js @@ -3,6 +3,12 @@ const { Op } = require("sequelize"); send = async (amount, memo, hash, user) => { let payreq = bolt11.decode(hash); + let routingInfo = payreq.tags.find(t => t.tagName === "routing_info"); + if ( + routingInfo && + routingInfo.data.find(d => d.fee_proportional_millionths > 100) + ) + throw new Error("Fee rate too high"); if (!amount || payreq.satoshis > amount) amount = payreq.satoshis; @@ -21,7 +27,7 @@ send = async (amount, memo, hash, user) => { pubkey: null, balance: { [Op.gte]: amount - }, + } }, lock: transaction.LOCK.UPDATE, transaction -- cgit v1.2.3