diff --git a/class/Paym.js b/class/Paym.js index c43db6f..9255583 100644 --- a/class/Paym.js +++ b/class/Paym.js @@ -40,7 +40,7 @@ export class Paym { amt: this._decoded.num_satoshis, num_routes: 1, final_cltv_delta: 144, - fee_limit: { fixed: Math.floor(this._decoded.num_satoshis * 0.01) }, + fee_limit: { fixed: Math.floor(this._decoded.num_satoshis * 0.01) + 1 }, }; let that = this; return new Promise(function(resolve, reject) { @@ -86,7 +86,7 @@ export class Paym { if (this._bolt11) payment.pay_req = this._bolt11; // trying to guess the fee payment.payment_route = payment.payment_route || {}; - payment.payment_route.total_fees = Math.floor(this._decoded.num_satoshis * 0.01); + payment.payment_route.total_fees = Math.floor(this._decoded.num_satoshis * 0.01); // we dont know the exact fee, so we use max (same as fee_limit) payment.payment_route.total_amt = this._decoded.num_satoshis; } } diff --git a/controllers/api.js b/controllers/api.js index 16f6bdb..cfc6078 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -209,7 +209,7 @@ router.post('/payinvoice', async function(req, res) { let inv = { payment_request: req.body.invoice, amt: info.num_satoshis, // amt is used only for 'tip' invoices - fee_limit: { fixed: Math.floor(info.num_satoshis * 0.005) }, + fee_limit: { fixed: Math.floor(info.num_satoshis * 0.005) + 1 }, }; try { await u.lockFunds(req.body.invoice, info); diff --git a/scripts/process-locked-payments.js b/scripts/process-locked-payments.js index 757837a..ff1f87a 100644 --- a/scripts/process-locked-payments.js +++ b/scripts/process-locked-payments.js @@ -30,6 +30,7 @@ let lightning = require('../lightning'); sendResult = await payment.attemptPayToRoute(); } catch (_) { console.log(_); + console.log('evict lock'); await user.unlockFunds(lockedPayment.pay_req); continue; } @@ -38,7 +39,7 @@ let lightning = require('../lightning'); if (payment.getIsPaid() === true) { console.log('paid successfully'); sendResult = payment.processSendPaymentResponse(sendResult); // adds fees - console.log('sendResult=', sendResult); + console.log('saving paid invoice:', sendResult); await user.savePaidLndInvoice(sendResult); await user.unlockFunds(lockedPayment.pay_req); } else if (payment.getIsPaid() === false) {