Merge pull request #1638 from RafaelTaranto/fix/fee-multiplier
fix: prevent deafult fee values, add logs
This commit is contained in:
commit
d071f9dda3
1 changed files with 9 additions and 4 deletions
|
|
@ -63,15 +63,20 @@ function estimateFee () {
|
|||
})
|
||||
}
|
||||
|
||||
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