REF
This commit is contained in:
parent
0f423817c3
commit
75bfac565c
@ -246,13 +246,14 @@ export class User {
|
||||
}
|
||||
invoice.ispaid = !!(await this.getPaymentHashPaid(invoice.payment_hash));
|
||||
if (!invoice.ispaid) {
|
||||
// TODO: check if expired
|
||||
// attempting to lookup invoice
|
||||
let lookup_info = await this.lookupInvoice(invoice.payment_hash);
|
||||
invoice.ispaid = lookup_info.settled;
|
||||
if (invoice.ispaid) {
|
||||
// so invoice was paid after all
|
||||
await this.setPaymentHashPaid(invoice.payment_hash);
|
||||
await this.saveBalance(await this.getCalculatedBalance());
|
||||
await this.clearBalanceCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ router.post('/addinvoice', postLimiter, async function(req, res) {
|
||||
}
|
||||
logger.log('/addinvoice', [req.id, 'userid: ' + u.getUserId()]);
|
||||
|
||||
if (!req.body.amt) return errorBadArguments(res);
|
||||
if (!req.body.amt || req.body.amt < 1) return errorBadArguments(res);
|
||||
|
||||
lightning.addInvoice({ memo: req.body.memo, value: req.body.amt }, async function(err, info) {
|
||||
if (err) return errorLnd(res);
|
||||
@ -179,6 +179,7 @@ router.post('/payinvoice', async function(req, res) {
|
||||
value: +info.num_satoshis + Math.floor(info.num_satoshis * 0.01),
|
||||
fee: Math.floor(info.num_satoshis * Paym.fee),
|
||||
memo: decodeURIComponent(info.description),
|
||||
pay_req: req.body.invoice,
|
||||
});
|
||||
|
||||
await UserPayee.setPaymentHashPaid(info.payment_hash);
|
||||
|
@ -69,6 +69,7 @@ const pubkey2name = {
|
||||
'02816caed43171d3c9854e3b0ab2cf0c42be086ff1bd4005acc2a5f7db70d83774': 'ln.pizza',
|
||||
'024a2e265cd66066b78a788ae615acdc84b5b0dec9efac36d7ac87513015eaf6ed': 'Bitrefill.com/lightning',
|
||||
'02a0bc43557fae6af7be8e3a29fdebda819e439bea9c0f8eb8ed6a0201f3471ca9': 'LightningPeachHub',
|
||||
'02d4531a2f2e6e5a9033d37d548cff4834a3898e74c3abe1985b493c42ebbd707d': 'coinfinity.co',
|
||||
};
|
||||
|
||||
router.get('/', function(req, res) {
|
||||
|
@ -20,7 +20,7 @@ User storage schema
|
||||
* bitcoin_address_for_{userid} = {address}
|
||||
* balance_for_{userid} = {int}
|
||||
* txs_for_{userid} = [] `serialized paid lnd invoices in a list`
|
||||
* locked_invoices_for_{userod} = [] `serialized attempts to pay invoice. used in calculating user's balance`
|
||||
* locked_payments_for_{userid} = [] `serialized attempts to pay invoice. used in calculating user's balance`
|
||||
: {pay_req:..., amount:666, timestamp:666}
|
||||
* imported_txids_for_{userid} = [] `list of txids processed for this user`
|
||||
* metadata_for_{userid}= {serialized json}
|
||||
|
Loading…
x
Reference in New Issue
Block a user