ADD: fees
This commit is contained in:
parent
8f2d98774b
commit
91f552ca7e
@ -169,8 +169,8 @@ router.post('/payinvoice', async function(req, res) {
|
|||||||
await u.savePaidLndInvoice({
|
await u.savePaidLndInvoice({
|
||||||
timestamp: parseInt(+new Date() / 1000),
|
timestamp: parseInt(+new Date() / 1000),
|
||||||
type: 'paid_invoice',
|
type: 'paid_invoice',
|
||||||
value: info.num_satoshis * 1,
|
value: +info.num_satoshis + Math.floor(info.num_satoshis * 0.01),
|
||||||
fee: 0, // internal invoices are free
|
fee: Math.floor(info.num_satoshis * 0.01),
|
||||||
memo: decodeURIComponent(info.description),
|
memo: decodeURIComponent(info.description),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,6 +187,7 @@ router.post('/payinvoice', async function(req, res) {
|
|||||||
// payment callback
|
// payment callback
|
||||||
await u.unlockFunds(req.body.invoice);
|
await u.unlockFunds(req.body.invoice);
|
||||||
if (payment && payment.payment_route && payment.payment_route.total_amt_msat) {
|
if (payment && payment.payment_route && payment.payment_route.total_amt_msat) {
|
||||||
|
payment.payment_route.total_fees += Math.floor(+payment.payment_route.total_amt * 0.01);
|
||||||
userBalance -= +payment.payment_route.total_fees + +payment.payment_route.total_amt;
|
userBalance -= +payment.payment_route.total_fees + +payment.payment_route.total_amt;
|
||||||
u.saveBalance(userBalance);
|
u.saveBalance(userBalance);
|
||||||
payment.pay_req = req.body.invoice;
|
payment.pay_req = req.body.invoice;
|
||||||
@ -205,7 +206,11 @@ router.post('/payinvoice', async function(req, res) {
|
|||||||
await lock.releaseLock();
|
await lock.releaseLock();
|
||||||
return errorBadArguments(res);
|
return errorBadArguments(res);
|
||||||
}
|
}
|
||||||
let inv = { payment_request: req.body.invoice, amt: info.num_satoshis }; // amt is used only for 'tip' invoices
|
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) },
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
await u.lockFunds(req.body.invoice, info);
|
await u.lockFunds(req.body.invoice, info);
|
||||||
call.write(inv);
|
call.write(inv);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user