mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
Merge 7d92a02a7f into 29afce710d
This commit is contained in:
commit
94df10657d
4 changed files with 39 additions and 11 deletions
|
|
@ -4,6 +4,7 @@ import { IBitcoinApi, SubmitPackageResult, TestMempoolAcceptResult } from './bit
|
|||
import { IEsploraApi } from './esplora-api.interface';
|
||||
import blocks from '../blocks';
|
||||
import mempool from '../mempool';
|
||||
import indexer from '../../indexer';
|
||||
import { TransactionExtended } from '../../mempool.interfaces';
|
||||
import transactionUtils from '../transaction-utils';
|
||||
import { Common } from '../common';
|
||||
|
|
@ -235,15 +236,37 @@ class BitcoinApi implements AbstractBitcoinApi {
|
|||
async $getOutspends(txId: string): Promise<IEsploraApi.Outspend[]> {
|
||||
const outSpends: IEsploraApi.Outspend[] = [];
|
||||
const tx = await this.$getRawTransaction(txId, true, false);
|
||||
for (let i = 0; i < tx.vout.length; i++) {
|
||||
if (tx.status && tx.status.block_height === 0) {
|
||||
if (indexer.isCoreIndexReady('txospenderindex') === null) {
|
||||
for (let i = 0; i < tx.vout.length; i++) {
|
||||
if (tx.status && tx.status.block_height === 0) {
|
||||
outSpends.push({
|
||||
spent: false
|
||||
});
|
||||
} else {
|
||||
const txOut = await this.bitcoindClient.getTxOut(txId, i);
|
||||
outSpends.push({
|
||||
spent: txOut === null,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const batchedOutpoints = Array.from(Array(tx.vout.length).keys()).map(x =>({txid: txId, vout:x}));
|
||||
const spendingsResume = await this.bitcoindClient.getTxSpendingPrevOut(batchedOutpoints);
|
||||
for (const outpointStatus of spendingsResume) {
|
||||
if (outpointStatus.spendingtxid === undefined) {
|
||||
outSpends.push({spent: false});
|
||||
continue;
|
||||
}
|
||||
const spendingTx = await this.$getRawTransaction(outpointStatus.spendingtxid, true, false);
|
||||
const inputIndex = spendingTx.vin.findIndex(x => x.txid === txId);
|
||||
outSpends.push({
|
||||
spent: false
|
||||
});
|
||||
} else {
|
||||
const txOut = await this.bitcoindClient.getTxOut(txId, i);
|
||||
outSpends.push({
|
||||
spent: txOut === null,
|
||||
spent: true,
|
||||
txid: outpointStatus.spendingtxid,
|
||||
vin: inputIndex,
|
||||
status: {
|
||||
confirmed: true,
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ module.exports = {
|
|||
getTxOut: 'gettxout', // bitcoind v0.7.0+
|
||||
getTxOutProof: 'gettxoutproof', // bitcoind v0.11.0+
|
||||
getTxOutSetInfo: 'gettxoutsetinfo', // bitcoind v0.7.0+
|
||||
getTxSpendingPrevOut: 'gettxspendingprevout', // bitcoind #24539
|
||||
getUnconfirmedBalance: 'getunconfirmedbalance', // bitcoind v0.9.0+
|
||||
getWalletInfo: 'getwalletinfo', // bitcoind v0.9.2+
|
||||
help: 'help',
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import logger from '../../logger';
|
|||
import channelsApi from '../../api/explorer/channels.api';
|
||||
import bitcoinApi from '../../api/bitcoin/bitcoin-api-factory';
|
||||
import config from '../../config';
|
||||
import indexer from '../../indexer';
|
||||
import { IEsploraApi } from '../../api/bitcoin/esplora-api.interface';
|
||||
import { Common } from '../../api/common';
|
||||
import { ILightningApi } from '../../api/lightning/lightning-api.interface';
|
||||
|
|
@ -28,7 +29,7 @@ class ForensicsService {
|
|||
try {
|
||||
logger.debug(`Running forensics scans`);
|
||||
|
||||
if (config.MEMPOOL.BACKEND === 'esplora') {
|
||||
if (config.MEMPOOL.BACKEND === 'esplora' || indexer.isCoreIndexReady('txospenderindex')) {
|
||||
await this.$runClosedChannelsForensics(false);
|
||||
await this.$runOpenedChannelsForensics();
|
||||
}
|
||||
|
|
@ -64,9 +65,9 @@ class ForensicsService {
|
|||
└──────────────────┘
|
||||
*/
|
||||
|
||||
public async $runClosedChannelsForensics(onlyNewChannels: boolean = false): Promise<void> {
|
||||
public async $runClosedChannelsForensics(onlyNewChannels: boolean = false): Promise<void> {
|
||||
// Only Esplora backend can retrieve spent transaction outputs
|
||||
if (config.MEMPOOL.BACKEND !== 'esplora') {
|
||||
if (config.MEMPOOL.BACKEND !== 'esplora' && indexer.isCoreIndexReady('txospenderindex') !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
3
contributors/pantamis.txt
Normal file
3
contributors/pantamis.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
I hereby accept the terms of the Contributor License Agreement in the CONTRIBUTING.md file of the mempool/mempool git repository as of 03 April, 2023.
|
||||
|
||||
Signed: pantamis
|
||||
Loading…
Add table
Add a link
Reference in a new issue