fix: BTC multiplied fee rounding

This commit is contained in:
Sérgio Salgado 2022-05-24 15:25:31 +01:00
parent fb00856cde
commit d5a794afff

View file

@ -69,7 +69,7 @@ function calculateFeeDiscount (feeMultiplier) {
if (!estimatedFee) return AUTOMATIC_FEE
const newFee = estimatedFee.times(feeMultiplier)
if (newFee.lt(0.00001) || newFee.gt(0.1)) return AUTOMATIC_FEE
return newFee
return newFee.toFixed(8)
})
}
@ -79,7 +79,7 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
return checkCryptoCode(cryptoCode)
.then(() => calculateFeeDiscount(feeMultiplier))
.then(newFee => fetch('settxfee', [newFee.toNumber()]))
.then(newFee => fetch('settxfee', [newFee]))
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
@ -95,7 +95,7 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
function sendCoinsBatch (account, txs, cryptoCode, feeMultiplier) {
return checkCryptoCode(cryptoCode)
.then(() => calculateFeeDiscount(feeMultiplier))
.then(newFee => fetch('settxfee', [newFee.toNumber()]))
.then(newFee => fetch('settxfee', [newFee]))
.then(() => _.reduce((acc, value) => ({
...acc,
[value.toAddress]: _.isNil(acc[value.toAddress])