Fix crash issues related to new unconfirmed transactions in bitcoind mode.

fixes #391
This commit is contained in:
softsimon
2021-04-27 02:13:48 +04:00
parent 628906f172
commit 885be5579b
3 changed files with 47 additions and 20 deletions

View File

@@ -147,6 +147,9 @@ class BitcoinApi implements AbstractBitcoinApi {
esploraTransaction = await this.$calculateFeeFromInputs(esploraTransaction, addPrevout);
} else {
esploraTransaction = await this.$appendMempoolFeeData(esploraTransaction);
if (addPrevout) {
esploraTransaction = await this.$calculateFeeFromInputs(esploraTransaction, addPrevout);
}
}
return esploraTransaction;

View File

@@ -34,7 +34,7 @@ class WebsocketHandler {
this.wss.on('connection', (client: WebSocket) => {
client.on('error', logger.info);
client.on('message', (message: string) => {
client.on('message', async (message: string) => {
try {
const parsedMessage: WebsocketResponse = JSON.parse(message);
const response = {};
@@ -53,7 +53,16 @@ class WebsocketHandler {
if (parsedMessage['watch-mempool']) {
const tx = memPool.getMempool()[client['track-tx']];
if (tx) {
response['tx'] = tx;
if (config.MEMPOOL.BACKEND !== 'esplora') {
try {
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, true);
response['tx'] = fullTx;
} catch (e) {
logger.debug('Error finding transaction in mempool: ' + e.message || e);
}
} else {
response['tx'] = tx;
}
} else {
client['track-mempool-tx'] = parsedMessage['track-tx'];
}