FIX: fee_limit when paying

This commit is contained in:
Overtorment 2019-03-19 00:11:25 +00:00
parent 067f2aeae4
commit 0fed216b32
3 changed files with 5 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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) {