Merge branch 'master' into simon/configurable-main-module

This commit is contained in:
softsimon
2021-08-03 18:41:43 +03:00
42 changed files with 2426 additions and 1760 deletions

View File

@@ -162,7 +162,7 @@ class Bisq {
this.buildIndex();
this.calculateStats();
} catch (e) {
logger.err('loadBisqDumpFile() error.' + e.message || e);
logger.info('loadBisqDumpFile() error.' + e.message || e);
}
}

View File

@@ -56,6 +56,11 @@ class BitcoinApi implements AbstractBitcoinApi {
.then((rpcBlock: IBitcoinApi.Block) => rpcBlock.tx);
}
$getRawBlock(hash: string): Promise<string> {
return this.bitcoindClient.getBlock(hash, 0);
}
$getBlockHash(height: number): Promise<string> {
return this.bitcoindClient.getBlockHash(height);
}

View File

@@ -9,6 +9,7 @@ export namespace IEsploraApi {
vin: Vin[];
vout: Vout[];
status: Status;
hex?: string;
}
export interface Recent {

View File

@@ -235,6 +235,7 @@ class Server {
.get(config.MEMPOOL.API_URL_PREFIX + 'mempool/txids', routes.getMempoolTxIds)
.get(config.MEMPOOL.API_URL_PREFIX + 'mempool/recent', routes.getRecentMempoolTransactions)
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId', routes.getTransaction)
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/hex', routes.getRawTransaction)
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/status', routes.getTransactionStatus)
.get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', routes.getTransactionOutspends)
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash', routes.getBlock)

View File

@@ -484,6 +484,20 @@ class Routes {
}
}
public async getRawTransaction(req: Request, res: Response) {
try {
const transaction: IEsploraApi.Transaction = await bitcoinApi.$getRawTransaction(req.params.txId, true);
res.setHeader('content-type', 'text/plain');
res.send(transaction.hex);
} catch (e) {
let statusCode = 500;
if (e.message && e.message.indexOf('No such mempool or blockchain transaction') > -1) {
statusCode = 404;
}
res.status(statusCode).send(e.message || e);
}
}
public async getTransactionStatus(req: Request, res: Response) {
try {
const transaction = await transactionUtils.$getTransactionExtended(req.params.txId, true);