Remove old batched outspends API
This commit is contained in:
		
							parent
							
								
									09f208484a
								
							
						
					
					
						commit
						7ec7ae7b95
					
				@ -24,7 +24,6 @@ class BitcoinRoutes {
 | 
				
			|||||||
  public initRoutes(app: Application) {
 | 
					  public initRoutes(app: Application) {
 | 
				
			||||||
    app
 | 
					    app
 | 
				
			||||||
      .get(config.MEMPOOL.API_URL_PREFIX + 'transaction-times', this.getTransactionTimes)
 | 
					      .get(config.MEMPOOL.API_URL_PREFIX + 'transaction-times', this.getTransactionTimes)
 | 
				
			||||||
      .get(config.MEMPOOL.API_URL_PREFIX + 'outspends', this.$getBatchedOutspends)
 | 
					 | 
				
			||||||
      .get(config.MEMPOOL.API_URL_PREFIX + 'cpfp/:txId', this.$getCpfpInfo)
 | 
					      .get(config.MEMPOOL.API_URL_PREFIX + 'cpfp/:txId', this.$getCpfpInfo)
 | 
				
			||||||
      .get(config.MEMPOOL.API_URL_PREFIX + 'difficulty-adjustment', this.getDifficultyChange)
 | 
					      .get(config.MEMPOOL.API_URL_PREFIX + 'difficulty-adjustment', this.getDifficultyChange)
 | 
				
			||||||
      .get(config.MEMPOOL.API_URL_PREFIX + 'fees/recommended', this.getRecommendedFees)
 | 
					      .get(config.MEMPOOL.API_URL_PREFIX + 'fees/recommended', this.getRecommendedFees)
 | 
				
			||||||
@ -112,7 +111,7 @@ class BitcoinRoutes {
 | 
				
			|||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/hex', this.getRawTransaction)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/hex', this.getRawTransaction)
 | 
				
			||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/status', this.getTransactionStatus)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/status', this.getTransactionStatus)
 | 
				
			||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', this.getTransactionOutspends)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', this.getTransactionOutspends)
 | 
				
			||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'txs/outspends', this.$getOutspends)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'txs/outspends', this.$getBatchedOutspends)
 | 
				
			||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/header', this.getBlockHeader)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/header', this.getBlockHeader)
 | 
				
			||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'blocks/tip/hash', this.getBlockTipHash)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'blocks/tip/hash', this.getBlockTipHash)
 | 
				
			||||||
          .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/raw', this.getRawBlock)
 | 
					          .get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash/raw', this.getRawBlock)
 | 
				
			||||||
@ -175,31 +174,7 @@ class BitcoinRoutes {
 | 
				
			|||||||
    res.json(times);
 | 
					    res.json(times);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private async $getBatchedOutspends(req: Request, res: Response) {
 | 
					  private async $getBatchedOutspends(req: Request, res: Response): Promise<IEsploraApi.Outspend[][] | void> {
 | 
				
			||||||
    if (!Array.isArray(req.query.txId)) {
 | 
					 | 
				
			||||||
      res.status(500).send('Not an array');
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (req.query.txId.length > 50) {
 | 
					 | 
				
			||||||
      res.status(400).send('Too many txids requested');
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    const txIds: string[] = [];
 | 
					 | 
				
			||||||
    for (const _txId in req.query.txId) {
 | 
					 | 
				
			||||||
      if (typeof req.query.txId[_txId] === 'string') {
 | 
					 | 
				
			||||||
        txIds.push(req.query.txId[_txId].toString());
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    try {
 | 
					 | 
				
			||||||
      const batchedOutspends = await bitcoinApi.$getBatchedOutspends(txIds);
 | 
					 | 
				
			||||||
      res.json(batchedOutspends);
 | 
					 | 
				
			||||||
    } catch (e) {
 | 
					 | 
				
			||||||
      res.status(500).send(e instanceof Error ? e.message : e);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  private async $getOutspends(req: Request, res: Response) {
 | 
					 | 
				
			||||||
    const txids_csv = req.query.txids;
 | 
					    const txids_csv = req.query.txids;
 | 
				
			||||||
    if (!txids_csv || typeof txids_csv !== 'string') {
 | 
					    if (!txids_csv || typeof txids_csv !== 'string') {
 | 
				
			||||||
      res.status(500).send('Invalid txids format');
 | 
					      res.status(500).send('Invalid txids format');
 | 
				
			||||||
 | 
				
			|||||||
@ -298,7 +298,7 @@ class ElectrsApi implements AbstractBitcoinApi {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async $getBatchedOutspends(txids: string[]): Promise<IEsploraApi.Outspend[][]> {
 | 
					  async $getBatchedOutspends(txids: string[]): Promise<IEsploraApi.Outspend[][]> {
 | 
				
			||||||
    return this.failoverRouter.$get<IEsploraApi.Outspend[][]>('/txs/outspends', 'json', { txids: txids.join(',') });
 | 
					    throw new Error('Method not implemented.');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public startHealthChecks(): void {
 | 
					  public startHealthChecks(): void {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user