REF: listtransactions from bitcoind

This commit is contained in:
Overtorment 2020-10-12 17:57:03 +01:00
parent ff23e41be7
commit 999f0534e0
2 changed files with 23 additions and 15 deletions

View File

@ -390,6 +390,7 @@ export class User {
} }
} }
try {
let txs = await this._bitcoindrpc.request('listtransactions', ['*', 100500, 0, true]); let txs = await this._bitcoindrpc.request('listtransactions', ['*', 100500, 0, true]);
// now, compacting response a bit // now, compacting response a bit
let ret = { result: [] }; let ret = { result: [] };
@ -404,8 +405,14 @@ export class User {
} }
_listtransactions_cache = JSON.stringify(ret); _listtransactions_cache = JSON.stringify(ret);
_listtransactions_cache_expiry_ts = +new Date() + 5 * 60 * 1000; // 5 min _listtransactions_cache_expiry_ts = +new Date() + 5 * 60 * 1000; // 5 min
this._redis.set('listtransactions', _listtransactions_cache); // backup, will use later TODO this._redis.set('listtransactions', _listtransactions_cache);
return ret; return ret;
} catch (error) {
console.warn('listtransactions error:', error);
let _listtransactions_cache = await this._redis.get('listtransactions');
if (!_listtransactions_cache) return { result: [] };
return JSON.parse(_listtransactions_cache);
}
} }
/** /**

View File

@ -11,6 +11,7 @@ User storage schema
* refresh_token_for_{userid} = {access_token} * refresh_token_for_{userid} = {access_token}
* importing_{txid} = 1 `atomic lock when processing topup tx` * importing_{txid} = 1 `atomic lock when processing topup tx`
* invoice_paying_for_{userid} = 1 `lock for when payinvoice is in progress` * invoice_paying_for_{userid} = 1 `lock for when payinvoice is in progress`
* generating_address_{userid} = 1 `lock for address generation`
* preimage_for_{payment_hash_hex} = {preimage_hex} `ttl 1 month` * preimage_for_{payment_hash_hex} = {preimage_hex} `ttl 1 month`