From c9e175a0cc2d769d1c036531d5a198006731aef8 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 24 Jan 2021 23:56:51 +0700 Subject: [PATCH] Always fetch at least the coinbase transaction of blocks, and throw error if failed. --- backend/src/api/blocks.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 3e4d3466e..7f9581ea9 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -70,13 +70,16 @@ class Blocks { if (mempool[txIds[i]]) { transactions.push(mempool[txIds[i]]); transactionsFound++; - } else if (config.MEMPOOL.BACKEND === 'esplora' || memPool.isInSync()) { + } else if (config.MEMPOOL.BACKEND === 'esplora' || memPool.isInSync() || i === 0) { logger.debug(`Fetching block tx ${i} of ${txIds.length}`); try { const tx = await transactionUtils.$getTransactionExtended(txIds[i]); transactions.push(tx); } catch (e) { logger.debug('Error fetching block tx: ' + e.message || e); + if (i === 0) { + throw new Error('Failed to fetch Coinbase transaction: ' + txIds[i]); + } } } }