diff --git a/lib/bitcoind-rpc/transactions.js b/lib/bitcoind-rpc/transactions.js index 275dab8..0990a64 100644 --- a/lib/bitcoind-rpc/transactions.js +++ b/lib/bitcoind-rpc/transactions.js @@ -53,9 +53,11 @@ class Transactions { * @returns {Promise} */ async getTransaction(txid, fees) { + const keyCache = `${txid}-${fees ? '1' : '0'}` + // Return transaction from cache when possible - if (this.txCache.has(txid)) - return this.txCache.get(txid) + if (this.txCache.has(keyCache)) + return this.txCache.get(keyCache) try { const tx = await this.rpcClient.getrawtransaction(txid, true) @@ -107,7 +109,7 @@ class Transactions { // Store in cache if (ret.block && ret.block.hash) - this.txCache.set(txid, ret) + this.txCache.set(keyCache, ret) return ret