Merge remote-tracking branch 'origin/release-8.1.10' into merge-8.1-into-9
This commit is contained in:
commit
d18b5bb29d
8 changed files with 1443 additions and 790 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 }
|
||||
|
|
@ -174,7 +174,7 @@ function advancedBatch (data) {
|
|||
}
|
||||
|
||||
function simplifiedBatch (data) {
|
||||
const fields = ['txClass', 'id', 'created', 'machineName',
|
||||
const fields = ['txClass', 'id', 'created', 'machineName', 'fee',
|
||||
'cryptoCode', 'cryptoAtoms', 'fiat', 'fiatCode', 'phone', 'email', 'toAddress',
|
||||
'txHash', 'dispense', 'error', 'status', 'fiatProfit', 'cryptoAmount']
|
||||
|
||||
|
|
@ -236,7 +236,6 @@ function getCustomerTransactionsBatch (ids) {
|
|||
|
||||
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
||||
c.phone AS customer_phone,
|
||||
c.email AS customer_email,
|
||||
c.id_card_data_number AS customer_id_card_data_number,
|
||||
c.id_card_data_expiration AS customer_id_card_data_expiration,
|
||||
c.id_card_data AS customer_id_card_data,
|
||||
|
|
@ -255,7 +254,6 @@ function getCustomerTransactionsBatch (ids) {
|
|||
txs.*,
|
||||
actions.tx_hash,
|
||||
c.phone AS customer_phone,
|
||||
c.email AS customer_email,
|
||||
c.id_card_data_number AS customer_id_card_data_number,
|
||||
c.id_card_data_expiration AS customer_id_card_data_expiration,
|
||||
c.id_card_data AS customer_id_card_data,
|
||||
|
|
@ -284,7 +282,6 @@ function single (txId) {
|
|||
|
||||
const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*,
|
||||
c.phone AS customer_phone,
|
||||
c.email AS customer_email,
|
||||
c.id_card_data_number AS customer_id_card_data_number,
|
||||
c.id_card_data_expiration AS customer_id_card_data_expiration,
|
||||
c.id_card_data AS customer_id_card_data,
|
||||
|
|
@ -302,7 +299,6 @@ function single (txId) {
|
|||
txs.*,
|
||||
actions.tx_hash,
|
||||
c.phone AS customer_phone,
|
||||
c.email AS customer_email,
|
||||
c.id_card_data_number AS customer_id_card_data_number,
|
||||
c.id_card_data_expiration AS customer_id_card_data_expiration,
|
||||
c.id_card_data AS customer_id_card_data,
|
||||
|
|
|
|||
|
|
@ -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,20 +56,27 @@ 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) {
|
||||
function calculateFeeDiscount (feeMultiplier = 1) {
|
||||
// 0 makes bitcoind do automatic fee selection
|
||||
const AUTOMATIC_FEE = 0
|
||||
if (!feeMultiplier || feeMultiplier.eq(1)) return AUTOMATIC_FEE
|
||||
return estimateFee()
|
||||
.then(estimatedFee => {
|
||||
if (!estimatedFee) return AUTOMATIC_FEE
|
||||
if (!estimatedFee) {
|
||||
logger.info('failure estimating fee, using bitcoind automatic fee selection')
|
||||
return AUTOMATIC_FEE
|
||||
}
|
||||
const newFee = estimatedFee.times(feeMultiplier)
|
||||
if (newFee.lt(0.00001) || newFee.gt(0.1)) return AUTOMATIC_FEE
|
||||
if (newFee.lt(0.00001) || newFee.gt(0.1)) {
|
||||
logger.info('fee outside safety parameters, defaulting to automatic fee selection')
|
||||
return AUTOMATIC_FEE
|
||||
}
|
||||
return newFee.toFixed(8)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue