From 3cbe38ed28eae2bf666a5436f628f58c187bc573 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Fri, 1 Mar 2019 22:41:50 +0000 Subject: [PATCH] FIX: increase lock --- class/Lock.js | 2 +- class/Paym.js | 20 ++++++++++++++++++++ class/User.js | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 class/Paym.js diff --git a/class/Lock.js b/class/Lock.js index db0209c..6c6412e 100644 --- a/class/Lock.js +++ b/class/Lock.js @@ -24,7 +24,7 @@ export class Lock { } // success - got lock - await this._redis.expire(this._lock_key, 10 * 60); + await this._redis.expire(this._lock_key, 3600); // lock expires in 5 mins just for any case return true; } diff --git a/class/Paym.js b/class/Paym.js new file mode 100644 index 0000000..d043bfb --- /dev/null +++ b/class/Paym.js @@ -0,0 +1,20 @@ +var crypto = require('crypto'); +var lightningPayReq = require('bolt11'); +import { BigNumber } from 'bignumber.js'; + +export class Paym { + constructor(redis, bitcoindrpc, lightning) { + this._redis = redis; + this._bitcoindrpc = bitcoindrpc; + this._lightning = lightning; + } + + async decodePayReq(invoice) { + return new Promise(function(resolve, reject) { + this._lightning.decodePayReq({ pay_req: invoice }, function(err, info) { + if (err) return reject(err); + return resolve(info); + }); + }); + } +} diff --git a/class/User.js b/class/User.js index 7eb1c3a..629c9d3 100644 --- a/class/User.js +++ b/class/User.js @@ -285,6 +285,7 @@ export class User { let range = await this._redis.lrange('txs_for_' + this._userid, 0, -1); for (let invoice of range) { invoice = JSON.parse(invoice); + // console.log(invoice);process.exit(); invoice.type = 'paid_invoice'; // for internal invoices it might not have properties `payment_route` and `decoded`...