This commit is contained in:
Overtorment 2019-02-28 22:23:21 +00:00
parent ef9cc6d388
commit 1a740d6b06
4 changed files with 8 additions and 4 deletions

View File

@ -24,7 +24,7 @@ export class Lock {
}
// success - got lock
await this._redis.expire(this._lock_key, 5 * 60);
await this._redis.expire(this._lock_key, 10 * 60);
// lock expires in 5 mins just for any case
return true;
}

View File

@ -261,6 +261,7 @@ export class User {
/**
* User's onchain txs that are >= 3 confs
* Queries bitcoind RPC.
*
* @returns {Promise<Array>}
*/

View File

@ -109,7 +109,7 @@ router.post('/payinvoice', async function(req, res) {
return errorBadAuth(res);
}
logger.log('/payinvoice', [req.id, 'userid: ' + u.getUserId()]);
logger.log('/payinvoice', [req.id, 'userid: ' + u.getUserId(), 'invoice: ' + req.body.invoice]);
if (!req.body.invoice) return errorBadArguments(res);
let freeAmount = false;
@ -137,6 +137,8 @@ router.post('/payinvoice', async function(req, res) {
info.num_satoshis = freeAmount;
}
logger.log('/payinvoice', [req.id, 'userBalance: ' + userBalance, 'num_satoshis: ' + info.num_satoshis]);
if (userBalance >= info.num_satoshis) {
// got enough balance
@ -181,14 +183,14 @@ router.post('/payinvoice', async function(req, res) {
// else - regular lightning network payment:
var call = lightning.sendPayment();
call.on('data', function(payment) {
call.on('data', async function(payment) {
// payment callback
if (payment && payment.payment_route && payment.payment_route.total_amt_msat) {
userBalance -= +payment.payment_route.total_fees + +payment.payment_route.total_amt;
u.saveBalance(userBalance);
payment.pay_req = req.body.invoice;
payment.decoded = info;
u.savePaidLndInvoice(payment);
await u.savePaidLndInvoice(payment);
lock.releaseLock();
res.send(payment);
} else {

View File

@ -67,6 +67,7 @@ const pubkey2name = {
'036a54f02d2186de192e4bcec3f7b47adb43b1fa965793387cd2471990ce1d236b': 'capacity.network',
'026c7d28784791a4b31a64eb34d9ab01552055b795919165e6ae886de637632efb': 'LivingRoomOfSatoshi.com_LND_1',
'02816caed43171d3c9854e3b0ab2cf0c42be086ff1bd4005acc2a5f7db70d83774': 'ln.pizza',
'024a2e265cd66066b78a788ae615acdc84b5b0dec9efac36d7ac87513015eaf6ed': 'Bitrefill.com/lightning',
};
router.get('/', function(req, res) {