Fix with null result TXs fetcher

This commit is contained in:
Mike Fluff 2019-03-06 11:27:40 +07:00
parent 27ebe36b4b
commit f624ced5ce

View File

@ -282,13 +282,14 @@ export class User {
let txs = await this._bitcoindrpc.request('listtransactions', [addr, 100500, 0, true]); let txs = await this._bitcoindrpc.request('listtransactions', [addr, 100500, 0, true]);
txs = txs.result; txs = txs.result;
let result = []; let result = [];
if(!txs===null) {
for (let tx of txs) { for (let tx of txs) {
if (tx.confirmations >= 3) { if (tx.confirmations >= 3) {
tx.type = 'bitcoind_tx'; tx.type = 'bitcoind_tx';
result.push(tx); result.push(tx);
} }
} }
}
let range = await this._redis.lrange('txs_for_' + this._userid, 0, -1); let range = await this._redis.lrange('txs_for_' + this._userid, 0, -1);
for (let invoice of range) { for (let invoice of range) {
invoice = JSON.parse(invoice); invoice = JSON.parse(invoice);
@ -311,9 +312,7 @@ export class User {
delete invoice.payment_route; delete invoice.payment_route;
delete invoice.pay_req; delete invoice.pay_req;
delete invoice.decoded; delete invoice.decoded;
result.push(invoice);
} }
return result; return result;
} }
@ -332,11 +331,13 @@ export class User {
let txs = await this._bitcoindrpc.request('listtransactions', [addr, 100500, 0, true]); let txs = await this._bitcoindrpc.request('listtransactions', [addr, 100500, 0, true]);
txs = txs.result; txs = txs.result;
let result = []; let result = [];
if(!txs === null) {
for (let tx of txs) { for (let tx of txs) {
if (tx.confirmations < 3) { if (tx.confirmations < 3) {
result.push(tx); result.push(tx);
} }
} }
}
return result; return result;
} }