Merge branch 'master' into ops/linux-no-patch-electrs
This commit is contained in:
		
						commit
						351d9864fe
					
				@ -4,6 +4,7 @@ export interface AbstractBitcoinApi {
 | 
			
		||||
  $getRawMempool(): Promise<IEsploraApi.Transaction['txid'][]>;
 | 
			
		||||
  $getRawTransaction(txId: string, skipConversion?: boolean, addPrevout?: boolean, lazyPrevouts?: boolean): Promise<IEsploraApi.Transaction>;
 | 
			
		||||
  $getBlockHeightTip(): Promise<number>;
 | 
			
		||||
  $getBlockHashTip(): Promise<string>;
 | 
			
		||||
  $getTxIdsForBlock(hash: string): Promise<string[]>;
 | 
			
		||||
  $getBlockHash(height: number): Promise<string>;
 | 
			
		||||
  $getBlockHeader(hash: string): Promise<string>;
 | 
			
		||||
 | 
			
		||||
@ -64,6 +64,13 @@ class BitcoinApi implements AbstractBitcoinApi {
 | 
			
		||||
      });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $getBlockHashTip(): Promise<string> {
 | 
			
		||||
    return this.bitcoindClient.getChainTips()
 | 
			
		||||
      .then((result: IBitcoinApi.ChainTips[]) => {
 | 
			
		||||
        return result.find(tip => tip.status === 'active')!.hash;
 | 
			
		||||
      });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $getTxIdsForBlock(hash: string): Promise<string[]> {
 | 
			
		||||
    return this.bitcoindClient.getBlock(hash, 1)
 | 
			
		||||
      .then((rpcBlock: IBitcoinApi.Block) => rpcBlock.tx);
 | 
			
		||||
 | 
			
		||||
@ -25,6 +25,11 @@ class ElectrsApi implements AbstractBitcoinApi {
 | 
			
		||||
      .then((response) => response.data);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $getBlockHashTip(): Promise<string> {
 | 
			
		||||
    return axios.get<string>(config.ESPLORA.REST_API_URL + '/blocks/tip/hash', this.axiosConfig)
 | 
			
		||||
      .then((response) => response.data);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $getTxIdsForBlock(hash: string): Promise<string[]> {
 | 
			
		||||
    return axios.get<string[]>(config.ESPLORA.REST_API_URL + '/block/' + hash + '/txids', this.axiosConfig)
 | 
			
		||||
      .then((response) => response.data);
 | 
			
		||||
 | 
			
		||||
@ -300,12 +300,8 @@ class Blocks {
 | 
			
		||||
   * [INDEXING] Index all blocks metadata for the mining dashboard
 | 
			
		||||
   */
 | 
			
		||||
  public async $generateBlockDatabase(): Promise<boolean> {
 | 
			
		||||
    const blockchainInfo = await bitcoinClient.getBlockchainInfo();
 | 
			
		||||
    if (blockchainInfo.blocks !== blockchainInfo.headers) { // Wait for node to sync
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      const blockchainInfo = await bitcoinClient.getBlockchainInfo();
 | 
			
		||||
      let currentBlockHeight = blockchainInfo.blocks;
 | 
			
		||||
 | 
			
		||||
      let indexingBlockAmount = Math.min(config.MEMPOOL.INDEXING_BLOCKS_AMOUNT, blockchainInfo.blocks);
 | 
			
		||||
 | 
			
		||||
@ -332,6 +332,7 @@ class Server {
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', routes.getTransactionOutspends)
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/header', routes.getBlockHeader)
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'blocks/tip/height', routes.getBlockTipHeight)
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'blocks/tip/hash', routes.getBlockTipHash)
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/txs', routes.getBlockTransactions)
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/txs/:index', routes.getBlockTransactions)
 | 
			
		||||
        .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/txids', routes.getTxIdsForBlock)
 | 
			
		||||
 | 
			
		||||
@ -4,6 +4,7 @@ import mempool from './api/mempool';
 | 
			
		||||
import mining from './api/mining';
 | 
			
		||||
import logger from './logger';
 | 
			
		||||
import HashratesRepository from './repositories/HashratesRepository';
 | 
			
		||||
import bitcoinClient from './api/bitcoin/bitcoin-client';
 | 
			
		||||
 | 
			
		||||
class Indexer {
 | 
			
		||||
  runIndexer = true;
 | 
			
		||||
@ -25,6 +26,12 @@ class Indexer {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Do not attempt to index anything unless Bitcoin Core is fully synced
 | 
			
		||||
    const blockchainInfo = await bitcoinClient.getBlockchainInfo();
 | 
			
		||||
    if (blockchainInfo.blocks !== blockchainInfo.headers) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.runIndexer = false;
 | 
			
		||||
    this.indexerRunning = true;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -925,6 +925,16 @@ class Routes {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async getBlockTipHash(req: Request, res: Response) {
 | 
			
		||||
    try {
 | 
			
		||||
      const result = await bitcoinApi.$getBlockHashTip();
 | 
			
		||||
      res.setHeader('content-type', 'text/plain');
 | 
			
		||||
      res.send(result);
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      res.status(500).send(e instanceof Error ? e.message : e);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public async getTxIdsForBlock(req: Request, res: Response) {
 | 
			
		||||
    try {
 | 
			
		||||
      const result = await bitcoinApi.$getTxIdsForBlock(req.params.hash);
 | 
			
		||||
 | 
			
		||||
@ -1218,7 +1218,7 @@ fi
 | 
			
		||||
# Bitcoin instance for Testnet #
 | 
			
		||||
################################
 | 
			
		||||
 | 
			
		||||
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
 | 
			
		||||
if [ "${BITCOIN_TESTNET_ENABLE}" = ON ];then
 | 
			
		||||
    echo "[*] Installing Bitcoin Testnet service"
 | 
			
		||||
    case $OS in
 | 
			
		||||
 | 
			
		||||
@ -1236,7 +1236,7 @@ fi
 | 
			
		||||
# Bitcoin instance for Signet #
 | 
			
		||||
###############################
 | 
			
		||||
 | 
			
		||||
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
 | 
			
		||||
if [ "${BITCOIN_SIGNET_ENABLE}" = ON ];then
 | 
			
		||||
    echo "[*] Installing Bitcoin Signet service"
 | 
			
		||||
    case $OS in
 | 
			
		||||
 | 
			
		||||
@ -1254,7 +1254,7 @@ fi
 | 
			
		||||
# Bitcoin instance for Liquid #
 | 
			
		||||
###############################
 | 
			
		||||
 | 
			
		||||
if [ "${BITCOIN_MAINNET_ENABLE}" = ON ];then
 | 
			
		||||
if [ "${ELEMENTS_LIQUID_ENABLE}" = ON ];then
 | 
			
		||||
    echo "[*] Installing Bitcoin Liquid service"
 | 
			
		||||
    case $OS in
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -3,9 +3,7 @@ Description=Bitcoind-signet
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
#ExecStart=/usr/local/bin/bitcoind -daemon -printtoconsole -pid=/bitcoin/bitcoind.pid
 | 
			
		||||
# torv2 active
 | 
			
		||||
ExecStart=/usr/local/bin/bitcoind -conf=bitcoin-signet.conf -daemon -signet -torpassword=off -printtoconsole -pid=/bitcoin/bitcoind-signet.pid
 | 
			
		||||
ExecStart=/usr/local/bin/bitcoind -conf=bitcoin-signet.conf -daemon -signet -printtoconsole -pid=/bitcoin/bitcoind-signet.pid
 | 
			
		||||
ExecStop=/usr/local/bin/bitcoin-cli -signet stop
 | 
			
		||||
 | 
			
		||||
Type=forking
 | 
			
		||||
 | 
			
		||||
@ -3,9 +3,7 @@ Description=Bitcoind-testnet
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
#ExecStart=/usr/local/bin/bitcoind -daemon -printtoconsole -pid=/bitcoin/bitcoind.pid
 | 
			
		||||
# torv2 active
 | 
			
		||||
ExecStart=/usr/local/bin/bitcoind -conf=bitcoin-testnet.conf -daemon -testnet -torpassword=off -printtoconsole -pid=/bitcoin/bitcoind-testnet.pid
 | 
			
		||||
ExecStart=/usr/local/bin/bitcoind -conf=bitcoin-testnet.conf -daemon -testnet -printtoconsole -pid=/bitcoin/bitcoind-testnet.pid
 | 
			
		||||
ExecStop=/usr/local/bin/bitcoin-cli -testnet stop
 | 
			
		||||
 | 
			
		||||
Type=forking
 | 
			
		||||
 | 
			
		||||
@ -3,8 +3,6 @@ Description=Liquid
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
#ExecStart=/usr/local/bin/bitcoind -daemon -printtoconsole -pid=/bitcoin/bitcoind.pid
 | 
			
		||||
# torv2 active
 | 
			
		||||
ExecStart=/usr/local/bin/elementsd -daemon -printtoconsole -pid=/liquid/liquid.pid
 | 
			
		||||
ExecStop=/usr/local/bin/elements-cli stop
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user