Backend: Bumping Typescript version to 4.4.2 (#748)

* Backend: Bumping Typescript version to 4.4.2

* Replacing any types with instanceOf checks.
This commit is contained in:
softsimon 2021-08-31 15:09:33 +03:00 committed by GitHub
parent 2e8ecc7277
commit ec12f21113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 73 additions and 63 deletions

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"editor.tabSize": 2,
"typescript.tsdk": "./backend/node_modules/typescript/lib"
}

4
backend/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"editor.tabSize": 2,
"typescript.tsdk": "../backend/node_modules/typescript/lib"
}

View File

@ -26,7 +26,7 @@
"@types/locutus": "^0.0.6", "@types/locutus": "^0.0.6",
"@types/ws": "^7.4.4", "@types/ws": "^7.4.4",
"tslint": "^6.1.0", "tslint": "^6.1.0",
"typescript": "^4.1.5" "typescript": "4.4.2"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
@ -1473,10 +1473,11 @@
"integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.2.3", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==", "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==",
"dev": true, "dev": true,
"license": "Apache-2.0",
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@ -2770,9 +2771,9 @@
"integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
}, },
"typescript": { "typescript": {
"version": "4.2.3", "version": "4.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==", "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==",
"dev": true "dev": true
}, },
"unpipe": { "unpipe": {
@ -2820,7 +2821,8 @@
"ws": { "ws": {
"version": "7.4.6", "version": "7.4.6",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==" "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"requires": {}
}, },
"yallist": { "yallist": {
"version": "4.0.0", "version": "4.0.0",

View File

@ -45,6 +45,6 @@
"@types/locutus": "^0.0.6", "@types/locutus": "^0.0.6",
"@types/ws": "^7.4.4", "@types/ws": "^7.4.4",
"tslint": "^6.1.0", "tslint": "^6.1.0",
"typescript": "^4.1.5" "typescript": "4.4.2"
} }
} }

View File

@ -30,7 +30,7 @@ class BackendInfo {
try { try {
this.gitCommitHash = fs.readFileSync('../.git/refs/heads/master').toString().trim(); this.gitCommitHash = fs.readFileSync('../.git/refs/heads/master').toString().trim();
} catch (e) { } catch (e) {
logger.err('Could not load git commit info: ' + e.message || e); logger.err('Could not load git commit info: ' + (e instanceof Error ? e.message : e));
} }
} }
@ -39,7 +39,7 @@ class BackendInfo {
const packageJson = fs.readFileSync('package.json').toString(); const packageJson = fs.readFileSync('package.json').toString();
this.version = JSON.parse(packageJson).version; this.version = JSON.parse(packageJson).version;
} catch (e) { } catch (e) {
throw new Error(e); throw new Error(e instanceof Error ? e.message : 'Error');
} }
} }
} }

View File

@ -162,7 +162,7 @@ class Bisq {
this.buildIndex(); this.buildIndex();
this.calculateStats(); this.calculateStats();
} catch (e) { } catch (e) {
logger.info('loadBisqDumpFile() error.' + e.message || e); logger.info('loadBisqDumpFile() error.' + (e instanceof Error ? e.message : e));
} }
} }

View File

@ -102,7 +102,7 @@ class Bisq {
logger.debug('Bisq market data updated in ' + time + ' ms'); logger.debug('Bisq market data updated in ' + time + ' ms');
} }
} catch (e) { } catch (e) {
logger.err('loadBisqMarketDataDumpFile() error.' + e.message || e); logger.err('loadBisqMarketDataDumpFile() error.' + (e instanceof Error ? e.message : e));
} }
} }

View File

@ -93,7 +93,7 @@ class BitcoindElectrsApi extends BitcoinApi implements AbstractBitcoinApi {
if (e === 'failed to get confirmed status') { if (e === 'failed to get confirmed status') {
e = 'The number of transactions on this address exceeds the Electrum server limit'; e = 'The number of transactions on this address exceeds the Electrum server limit';
} }
throw new Error(e); throw new Error(e instanceof Error ? e.message : 'Error');
} }
} }
@ -131,7 +131,7 @@ class BitcoindElectrsApi extends BitcoinApi implements AbstractBitcoinApi {
if (e === 'failed to get confirmed status') { if (e === 'failed to get confirmed status') {
e = 'The number of transactions on this address exceeds the Electrum server limit'; e = 'The number of transactions on this address exceeds the Electrum server limit';
} }
throw new Error(e); throw new Error(e instanceof Error ? e.message : 'Error');
} }
} }

View File

@ -89,7 +89,7 @@ class Blocks {
const tx = await transactionUtils.$getTransactionExtended(txIds[i]); const tx = await transactionUtils.$getTransactionExtended(txIds[i]);
transactions.push(tx); transactions.push(tx);
} catch (e) { } catch (e) {
logger.debug('Error fetching block tx: ' + e.message || e); logger.debug('Error fetching block tx: ' + (e instanceof Error ? e.message : e));
if (i === 0) { if (i === 0) {
throw new Error('Failed to fetch Coinbase transaction: ' + txIds[i]); throw new Error('Failed to fetch Coinbase transaction: ' + txIds[i]);
} }

View File

@ -52,7 +52,7 @@ class DiskCache {
logger.debug('Mempool and blocks data saved to disk cache'); logger.debug('Mempool and blocks data saved to disk cache');
this.isWritingCache = false; this.isWritingCache = false;
} catch (e) { } catch (e) {
logger.warn('Error writing to cache file: ' + e.message || e); logger.warn('Error writing to cache file: ' + (e instanceof Error ? e.message : e));
this.isWritingCache = false; this.isWritingCache = false;
} }
} }

View File

@ -36,7 +36,7 @@ class FiatConversion {
this.ratesChangedCallback(this.conversionRates); this.ratesChangedCallback(this.conversionRates);
} }
} catch (e) { } catch (e) {
logger.err('Error updating fiat conversion rates: ' + e); logger.err('Error updating fiat conversion rates: ' + (e instanceof Error ? e.message : e));
} }
} }
} }

View File

@ -124,7 +124,7 @@ class Mempool {
} }
newTransactions.push(transaction); newTransactions.push(transaction);
} catch (e) { } catch (e) {
logger.debug('Error finding transaction in mempool: ' + e.message || e); logger.debug('Error finding transaction in mempool: ' + (e instanceof Error ? e.message : e));
} }
} }

View File

@ -255,7 +255,7 @@ class Statistics {
connection.release(); connection.release();
return result.insertId; return result.insertId;
} catch (e) { } catch (e) {
logger.err('$create() error' + e.message || e); logger.err('$create() error' + (e instanceof Error ? e.message : e));
} }
} }
@ -313,7 +313,7 @@ class Statistics {
return this.mapStatisticToOptimizedStatistic([rows[0]])[0]; return this.mapStatisticToOptimizedStatistic([rows[0]])[0];
} }
} catch (e) { } catch (e) {
logger.err('$list2H() error' + e.message || e); logger.err('$list2H() error' + (e instanceof Error ? e.message : e));
} }
} }
@ -325,7 +325,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list2H() error' + e.message || e); logger.err('$list2H() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }
@ -338,7 +338,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list24h() error' + e.message || e); logger.err('$list24h() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }
@ -351,7 +351,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list1W() error' + e); logger.err('$list1W() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }
@ -364,7 +364,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list1M() error' + e); logger.err('$list1M() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }
@ -377,7 +377,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list3M() error' + e); logger.err('$list3M() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }
@ -390,7 +390,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list6M() error' + e); logger.err('$list6M() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }
@ -403,7 +403,7 @@ class Statistics {
connection.release(); connection.release();
return this.mapStatisticToOptimizedStatistic(rows); return this.mapStatisticToOptimizedStatistic(rows);
} catch (e) { } catch (e) {
logger.err('$list6M() error' + e); logger.err('$list6M() error' + (e instanceof Error ? e.message : e));
return []; return [];
} }
} }

View File

@ -61,7 +61,7 @@ class WebsocketHandler {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true); const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
response['tx'] = fullTx; response['tx'] = fullTx;
} catch (e) { } catch (e) {
logger.debug('Error finding transaction: ' + e.message || e); logger.debug('Error finding transaction: ' + (e instanceof Error ? e.message : e));
} }
} }
} else { } else {
@ -69,7 +69,7 @@ class WebsocketHandler {
const fullTx = await transactionUtils.$getTransactionExtended(client['track-tx'], true); const fullTx = await transactionUtils.$getTransactionExtended(client['track-tx'], true);
response['tx'] = fullTx; response['tx'] = fullTx;
} catch (e) { } catch (e) {
logger.debug('Error finding transaction. ' + e.message || e); logger.debug('Error finding transaction. ' + (e instanceof Error ? e.message : e));
client['track-mempool-tx'] = parsedMessage['track-tx']; client['track-mempool-tx'] = parsedMessage['track-tx'];
} }
} }
@ -124,7 +124,7 @@ class WebsocketHandler {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
} }
} catch (e) { } catch (e) {
logger.debug('Error parsing websocket message: ' + e.message || e); logger.debug('Error parsing websocket message: ' + (e instanceof Error ? e.message : e));
} }
}); });
}); });
@ -252,7 +252,7 @@ class WebsocketHandler {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true); const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
response['tx'] = fullTx; response['tx'] = fullTx;
} catch (e) { } catch (e) {
logger.debug('Error finding transaction in mempool: ' + e.message || e); logger.debug('Error finding transaction in mempool: ' + (e instanceof Error ? e.message : e));
} }
} else { } else {
response['tx'] = tx; response['tx'] = tx;
@ -272,7 +272,7 @@ class WebsocketHandler {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true); const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
foundTransactions.push(fullTx); foundTransactions.push(fullTx);
} catch (e) { } catch (e) {
logger.debug('Error finding transaction in mempool: ' + e.message || e); logger.debug('Error finding transaction in mempool: ' + (e instanceof Error ? e.message : e));
} }
} else { } else {
foundTransactions.push(tx); foundTransactions.push(tx);
@ -286,7 +286,7 @@ class WebsocketHandler {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true); const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
foundTransactions.push(fullTx); foundTransactions.push(fullTx);
} catch (e) { } catch (e) {
logger.debug('Error finding transaction in mempool: ' + e.message || e); logger.debug('Error finding transaction in mempool: ' + (e instanceof Error ? e.message : e));
} }
} else { } else {
foundTransactions.push(tx); foundTransactions.push(tx);
@ -337,7 +337,7 @@ class WebsocketHandler {
const fullTx = await transactionUtils.$getTransactionExtended(rbfTransaction, true); const fullTx = await transactionUtils.$getTransactionExtended(rbfTransaction, true);
response['rbfTransaction'] = fullTx; response['rbfTransaction'] = fullTx;
} catch (e) { } catch (e) {
logger.debug('Error finding transaction in mempool: ' + e.message || e); logger.debug('Error finding transaction in mempool: ' + (e instanceof Error ? e.message : e));
} }
} else { } else {
response['rbfTransaction'] = rbfTx; response['rbfTransaction'] = rbfTx;

View File

@ -20,7 +20,7 @@ export async function checkDbConnection() {
logger.info('Database connection established.'); logger.info('Database connection established.');
connection.release(); connection.release();
} catch (e) { } catch (e) {
logger.err('Could not connect to database: ' + e.message || e); logger.err('Could not connect to database: ' + (e instanceof Error ? e.message : e));
process.exit(1); process.exit(1);
} }
} }

View File

@ -111,7 +111,7 @@ class Server {
try { try {
await memPool.$updateMemPoolInfo(); await memPool.$updateMemPoolInfo();
} catch (e) { } catch (e) {
const msg = `updateMempoolInfo: ${(e.message || e)}`; const msg = `updateMempoolInfo: ${(e instanceof Error ? e.message : e)}`;
if (config.CORE_RPC_MINFEE.ENABLED) { if (config.CORE_RPC_MINFEE.ENABLED) {
logger.warn(msg); logger.warn(msg);
} else { } else {
@ -123,7 +123,7 @@ class Server {
setTimeout(this.runMainUpdateLoop.bind(this), config.MEMPOOL.POLL_RATE_MS); setTimeout(this.runMainUpdateLoop.bind(this), config.MEMPOOL.POLL_RATE_MS);
this.currentBackendRetryInterval = 5; this.currentBackendRetryInterval = 5;
} catch (e) { } catch (e) {
const loggerMsg = `runMainLoop error: ${(e.message || e)}. Retrying in ${this.currentBackendRetryInterval} sec.`; const loggerMsg = `runMainLoop error: ${(e instanceof Error ? e.message : e)}. Retrying in ${this.currentBackendRetryInterval} sec.`;
if (this.currentBackendRetryInterval > 5) { if (this.currentBackendRetryInterval > 5) {
logger.warn(loggerMsg); logger.warn(loggerMsg);
mempool.setOutOfSync(); mempool.setOutOfSync();

View File

@ -55,7 +55,7 @@ class Routes {
const result = websocketHandler.getInitData(); const result = websocketHandler.getInitData();
res.json(result); res.json(result);
} catch (e) { } catch (e) {
res.status(500).send(e.message); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -74,7 +74,7 @@ class Routes {
const result = mempoolBlocks.getMempoolBlocks(); const result = mempoolBlocks.getMempoolBlocks();
res.json(result); res.json(result);
} catch (e) { } catch (e) {
res.status(500).send(e.message); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -477,10 +477,10 @@ class Routes {
res.json(transaction); res.json(transaction);
} catch (e) { } catch (e) {
let statusCode = 500; let statusCode = 500;
if (e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) { if (e instanceof Error && e instanceof Error && e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) {
statusCode = 404; statusCode = 404;
} }
res.status(statusCode).send(e.message || e); res.status(statusCode).send(e instanceof Error ? e.message : e);
} }
} }
@ -491,10 +491,10 @@ class Routes {
res.send(transaction.hex); res.send(transaction.hex);
} catch (e) { } catch (e) {
let statusCode = 500; let statusCode = 500;
if (e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) { if (e instanceof Error && e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) {
statusCode = 404; statusCode = 404;
} }
res.status(statusCode).send(e.message || e); res.status(statusCode).send(e instanceof Error ? e.message : e);
} }
} }
@ -504,10 +504,10 @@ class Routes {
res.json(transaction.status); res.json(transaction.status);
} catch (e) { } catch (e) {
let statusCode = 500; let statusCode = 500;
if (e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) { if (e instanceof Error && e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) {
statusCode = 404; statusCode = 404;
} }
res.status(statusCode).send(e.message || e); res.status(statusCode).send(e instanceof Error ? e.message : e);
} }
} }
@ -516,7 +516,7 @@ class Routes {
const result = await bitcoinApi.$getBlock(req.params.hash); const result = await bitcoinApi.$getBlock(req.params.hash);
res.json(result); res.json(result);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -526,7 +526,7 @@ class Routes {
res.setHeader('content-type', 'text/plain'); res.setHeader('content-type', 'text/plain');
res.send(blockHeader); res.send(blockHeader);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -563,7 +563,7 @@ class Routes {
res.json(returnBlocks); res.json(returnBlocks);
} catch (e) { } catch (e) {
loadingIndicators.setProgress('blocks', 100); loadingIndicators.setProgress('blocks', 100);
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -582,13 +582,13 @@ class Routes {
transactions.push(transaction); transactions.push(transaction);
loadingIndicators.setProgress('blocktxs-' + req.params.hash, (i + 1) / endIndex * 100); loadingIndicators.setProgress('blocktxs-' + req.params.hash, (i + 1) / endIndex * 100);
} catch (e) { } catch (e) {
logger.debug('getBlockTransactions error: ' + e.message || e); logger.debug('getBlockTransactions error: ' + (e instanceof Error ? e.message : e));
} }
} }
res.json(transactions); res.json(transactions);
} catch (e) { } catch (e) {
loadingIndicators.setProgress('blocktxs-' + req.params.hash, 100); loadingIndicators.setProgress('blocktxs-' + req.params.hash, 100);
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -597,7 +597,7 @@ class Routes {
const blockHash = await bitcoinApi.$getBlockHash(parseInt(req.params.height, 10)); const blockHash = await bitcoinApi.$getBlockHash(parseInt(req.params.height, 10));
res.send(blockHash); res.send(blockHash);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -611,10 +611,10 @@ class Routes {
const addressData = await bitcoinApi.$getAddress(req.params.address); const addressData = await bitcoinApi.$getAddress(req.params.address);
res.json(addressData); res.json(addressData);
} catch (e) { } catch (e) {
if (e.message && e.message.indexOf('exceeds') > 0) { if (e instanceof Error && e.message && e.message.indexOf('exceeds') > 0) {
return res.status(413).send(e.message); return res.status(413).send(e instanceof Error ? e.message : e);
} }
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -628,10 +628,10 @@ class Routes {
const transactions = await bitcoinApi.$getAddressTransactions(req.params.address, req.params.txId); const transactions = await bitcoinApi.$getAddressTransactions(req.params.address, req.params.txId);
res.json(transactions); res.json(transactions);
} catch (e) { } catch (e) {
if (e.message && e.message.indexOf('exceeds') > 0) { if (e instanceof Error && e.message && e.message.indexOf('exceeds') > 0) {
return res.status(413).send(e.message); return res.status(413).send(e instanceof Error ? e.message : e);
} }
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -644,7 +644,7 @@ class Routes {
const blockHash = await bitcoinApi.$getAddressPrefix(req.params.prefix); const blockHash = await bitcoinApi.$getAddressPrefix(req.params.prefix);
res.send(blockHash); res.send(blockHash);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -665,7 +665,7 @@ class Routes {
const rawMempool = await bitcoinApi.$getRawMempool(); const rawMempool = await bitcoinApi.$getRawMempool();
res.send(rawMempool); res.send(rawMempool);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -674,7 +674,7 @@ class Routes {
const result = await bitcoinApi.$getBlockHeightTip(); const result = await bitcoinApi.$getBlockHeightTip();
res.json(result); res.json(result);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -683,7 +683,7 @@ class Routes {
const result = await bitcoinApi.$getTxIdsForBlock(req.params.hash); const result = await bitcoinApi.$getTxIdsForBlock(req.params.hash);
res.json(result); res.json(result);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
@ -741,7 +741,7 @@ class Routes {
res.json(result); res.json(result);
} catch (e) { } catch (e) {
res.status(500).send(e.message || e); res.status(500).send(e instanceof Error ? e.message : e);
} }
} }
} }