FIX: internal invoice wasnt saving record in senders tx list
This commit is contained in:
parent
b8bc4dd0cd
commit
5100252ea5
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user