Bitcoind: Push full transactions to address page and RBF mode.
This commit is contained in:
parent
6a58717694
commit
065c21da1f
@ -1,6 +1,7 @@
|
|||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
import * as WebSocket from 'ws';
|
import * as WebSocket from 'ws';
|
||||||
import { BlockExtended, TransactionExtended, WebsocketResponse, MempoolBlock, OptimizedStatistic, ILoadingIndicators, IConversionRates } from '../mempool.interfaces';
|
import { BlockExtended, TransactionExtended, WebsocketResponse, MempoolBlock,
|
||||||
|
OptimizedStatistic, ILoadingIndicators, IConversionRates } from '../mempool.interfaces';
|
||||||
import blocks from './blocks';
|
import blocks from './blocks';
|
||||||
import memPool from './mempool';
|
import memPool from './mempool';
|
||||||
import backendInfo from './backend-info';
|
import backendInfo from './backend-info';
|
||||||
@ -8,6 +9,8 @@ import mempoolBlocks from './mempool-blocks';
|
|||||||
import fiatConversion from './fiat-conversion';
|
import fiatConversion from './fiat-conversion';
|
||||||
import { Common } from './common';
|
import { Common } from './common';
|
||||||
import loadingIndicators from './loading-indicators';
|
import loadingIndicators from './loading-indicators';
|
||||||
|
import config from '../config';
|
||||||
|
import transactionUtils from './transaction-utils';
|
||||||
|
|
||||||
class WebsocketHandler {
|
class WebsocketHandler {
|
||||||
private wss: WebSocket.Server | undefined;
|
private wss: WebSocket.Server | undefined;
|
||||||
@ -195,7 +198,7 @@ class WebsocketHandler {
|
|||||||
const vBytesPerSecond = memPool.getVBytesPerSecond();
|
const vBytesPerSecond = memPool.getVBytesPerSecond();
|
||||||
const rbfTransactions = Common.findRbfTransactions(newTransactions, deletedTransactions);
|
const rbfTransactions = Common.findRbfTransactions(newTransactions, deletedTransactions);
|
||||||
|
|
||||||
this.wss.clients.forEach((client: WebSocket) => {
|
this.wss.clients.forEach(async (client: WebSocket) => {
|
||||||
if (client.readyState !== WebSocket.OPEN) {
|
if (client.readyState !== WebSocket.OPEN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -215,7 +218,14 @@ class WebsocketHandler {
|
|||||||
if (client['track-mempool-tx']) {
|
if (client['track-mempool-tx']) {
|
||||||
const tx = newTransactions.find((t) => t.txid === client['track-mempool-tx']);
|
const tx = newTransactions.find((t) => t.txid === client['track-mempool-tx']);
|
||||||
if (tx) {
|
if (tx) {
|
||||||
response['tx'] = tx;
|
if (config.MEMPOOL.BACKEND !== 'esplora') {
|
||||||
|
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, false, true);
|
||||||
|
if (fullTx) {
|
||||||
|
response['tx'] = fullTx;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response['tx'] = tx;
|
||||||
|
}
|
||||||
client['track-mempool-tx'] = null;
|
client['track-mempool-tx'] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,17 +233,31 @@ class WebsocketHandler {
|
|||||||
if (client['track-address']) {
|
if (client['track-address']) {
|
||||||
const foundTransactions: TransactionExtended[] = [];
|
const foundTransactions: TransactionExtended[] = [];
|
||||||
|
|
||||||
newTransactions.forEach((tx) => {
|
for (const tx of newTransactions) {
|
||||||
const someVin = tx.vin.some((vin) => !!vin.prevout && vin.prevout.scriptpubkey_address === client['track-address']);
|
const someVin = tx.vin.some((vin) => !!vin.prevout && vin.prevout.scriptpubkey_address === client['track-address']);
|
||||||
if (someVin) {
|
if (someVin) {
|
||||||
foundTransactions.push(tx);
|
if (config.MEMPOOL.BACKEND !== 'esplora') {
|
||||||
|
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, false, true);
|
||||||
|
if (fullTx) {
|
||||||
|
foundTransactions.push(fullTx);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foundTransactions.push(tx);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const someVout = tx.vout.some((vout) => vout.scriptpubkey_address === client['track-address']);
|
const someVout = tx.vout.some((vout) => vout.scriptpubkey_address === client['track-address']);
|
||||||
if (someVout) {
|
if (someVout) {
|
||||||
foundTransactions.push(tx);
|
if (config.MEMPOOL.BACKEND !== 'esplora') {
|
||||||
|
const fullTx = await transactionUtils.$getTransactionExtended(tx.txid, false, true);
|
||||||
|
if (fullTx) {
|
||||||
|
foundTransactions.push(fullTx);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foundTransactions.push(tx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
if (foundTransactions.length) {
|
if (foundTransactions.length) {
|
||||||
response['address-transactions'] = foundTransactions;
|
response['address-transactions'] = foundTransactions;
|
||||||
@ -272,7 +296,15 @@ class WebsocketHandler {
|
|||||||
if (client['track-tx'] && rbfTransactions[client['track-tx']]) {
|
if (client['track-tx'] && rbfTransactions[client['track-tx']]) {
|
||||||
for (const rbfTransaction in rbfTransactions) {
|
for (const rbfTransaction in rbfTransactions) {
|
||||||
if (client['track-tx'] === rbfTransaction) {
|
if (client['track-tx'] === rbfTransaction) {
|
||||||
response['rbfTransaction'] = rbfTransactions[rbfTransaction];
|
const rbfTx = rbfTransactions[rbfTransaction];
|
||||||
|
if (config.MEMPOOL.BACKEND !== 'esplora') {
|
||||||
|
const fullTx = await transactionUtils.$getTransactionExtended(rbfTransaction, false, true);
|
||||||
|
if (fullTx) {
|
||||||
|
response['rbfTransaction'] = fullTx;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
response['rbfTransaction'] = rbfTx;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user