Merge pull request #1636 from RafaelTaranto/feat/mempool-space-fees
LAM-1012 feat: mempool.space fee estimation
This commit is contained in:
commit
148b10fc48
2 changed files with 14 additions and 3 deletions
8
lib/blockexplorers/mempool.space.js
Normal file
8
lib/blockexplorers/mempool.space.js
Normal file
|
|
@ -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 }
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
const jsonRpc = require('../../common/json-rpc')
|
const jsonRpc = require('../../common/json-rpc')
|
||||||
|
const { getEstimateFeeBtc } = require('../../../blockexplorers/mempool.space')
|
||||||
|
|
||||||
const BN = require('../../../bn')
|
const BN = require('../../../bn')
|
||||||
const E = require('../../../error')
|
const E = require('../../../error')
|
||||||
|
|
@ -55,9 +56,11 @@ function balance (account, cryptoCode, settings, operatorId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function estimateFee () {
|
function estimateFee () {
|
||||||
return fetch('estimatesmartfee', [6, 'unset'])
|
return getEstimateFeeBtc()
|
||||||
.then(result => BN(result.feerate))
|
.then(result => BN(result))
|
||||||
.catch(() => {})
|
.catch(err => {
|
||||||
|
logger.error('failure estimating fes', err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateFeeDiscount (feeMultiplier) {
|
function calculateFeeDiscount (feeMultiplier) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue