diff --git a/lib/blockexplorers/mempool.space.js b/lib/blockexplorers/mempool.space.js new file mode 100644 index 00000000..4ef494d7 --- /dev/null +++ b/lib/blockexplorers/mempool.space.js @@ -0,0 +1,8 @@ +const axios = require("axios"); + +const getEstimateFeeBtc = () => { + return axios.get('https://mempool.space/api/v1/fees/recommended') + .then(r => r.data.hourFee) +} + +module.exports = { getEstimateFeeBtc } \ No newline at end of file diff --git a/lib/plugins/wallet/bitcoind/bitcoind.js b/lib/plugins/wallet/bitcoind/bitcoind.js index cc30e4b4..b6a71684 100644 --- a/lib/plugins/wallet/bitcoind/bitcoind.js +++ b/lib/plugins/wallet/bitcoind/bitcoind.js @@ -1,5 +1,6 @@ const _ = require('lodash/fp') const jsonRpc = require('../../common/json-rpc') +const { getEstimateFeeBtc } = require('../../../blockexplorers/mempool.space') const BN = require('../../../bn') const E = require('../../../error') @@ -55,9 +56,11 @@ function balance (account, cryptoCode, settings, operatorId) { } function estimateFee () { - return fetch('estimatesmartfee', [6, 'unset']) - .then(result => BN(result.feerate)) - .catch(() => {}) + return getEstimateFeeBtc() + .then(result => BN(result)) + .catch(err => { + logger.error('failure estimating fes', err) + }) } function calculateFeeDiscount (feeMultiplier) {