Optionally support second CoreRPC instance as source for the minimum fee.
This commit is contained in:
@@ -4,6 +4,7 @@ import { IBitcoinApi } from './bitcoin-api.interface';
|
||||
|
||||
class BitcoinBaseApi {
|
||||
bitcoindClient: any;
|
||||
bitcoindClientMempoolInfo: any;
|
||||
|
||||
constructor() {
|
||||
this.bitcoindClient = new bitcoin.Client({
|
||||
@@ -13,9 +14,30 @@ class BitcoinBaseApi {
|
||||
pass: config.CORE_RPC.PASSWORD,
|
||||
timeout: 60000,
|
||||
});
|
||||
|
||||
if (config.CORE_RPC_MINFEE.ENABLED) {
|
||||
this.bitcoindClientMempoolInfo = new bitcoin.Client({
|
||||
host: config.CORE_RPC_MINFEE.HOST,
|
||||
port: config.CORE_RPC_MINFEE.PORT,
|
||||
user: config.CORE_RPC_MINFEE.USERNAME,
|
||||
pass: config.CORE_RPC_MINFEE.PASSWORD,
|
||||
timeout: 60000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$getMempoolInfo(): Promise<IBitcoinApi.MempoolInfo> {
|
||||
if (config.CORE_RPC_MINFEE.ENABLED) {
|
||||
return Promise.all([
|
||||
this.bitcoindClient.getMempoolInfo(),
|
||||
this.bitcoindClientMempoolInfo.getMempoolInfo()
|
||||
]).then(([mempoolInfo, secondMempoolInfo]) => {
|
||||
mempoolInfo.maxmempool = secondMempoolInfo.maxmempool;
|
||||
mempoolInfo.mempoolminfee = secondMempoolInfo.mempoolminfee;
|
||||
mempoolInfo.minrelaytxfee = secondMempoolInfo.minrelaytxfee;
|
||||
return mempoolInfo;
|
||||
});
|
||||
}
|
||||
return this.bitcoindClient.getMempoolInfo();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user