FIX: internal invoice wasnt saving record in senders tx list

This commit is contained in:
Overtorment 2018-12-27 00:44:13 +00:00
parent b8bc4dd0cd
commit 5100252ea5
2 changed files with 20 additions and 5 deletions

View File

@ -230,10 +230,18 @@ export class User {
for (let invoice of range) { for (let invoice of range) {
invoice = JSON.parse(invoice); invoice = JSON.parse(invoice);
invoice.type = 'paid_invoice'; invoice.type = 'paid_invoice';
invoice.fee = +invoice.payment_route.total_fees;
invoice.value = +invoice.payment_route.total_fees + +invoice.payment_route.total_amt; // for internal invoices it might not have properties `payment_route` and `decoded`...
invoice.timestamp = invoice.decoded.timestamp; if (invoice.payment_route) {
invoice.memo = invoice.decoded.description; invoice.fee = +invoice.payment_route.total_fees;
invoice.value = +invoice.payment_route.total_fees + +invoice.payment_route.total_amt;
} else {
invoice.fee = 0;
}
if (invoice.decoded) {
invoice.timestamp = invoice.decoded.timestamp;
invoice.memo = invoice.decoded.description;
}
result.push(invoice); result.push(invoice);
} }

View File

@ -130,8 +130,15 @@ router.post('/payinvoice', async function(req, res) {
// sender spent his balance: // sender spent his balance:
userBalance -= info.num_satoshis * 1; userBalance -= info.num_satoshis * 1;
await u.saveBalance(userBalance); await u.saveBalance(userBalance);
await u.savePaidLndInvoice({
timestamp: parseInt(+new Date() / 1000),
type: 'paid_invoice',
value: info.num_satoshis * 1,
fee: 0, // internal invoices are free
memo: decodeURIComponent(info.description),
});
await u.setPaymentHashPaid(info.payment_hash); await UserPayee.setPaymentHashPaid(info.payment_hash);
return res.send(info); return res.send(info);
} }