fix: BN functions on sendCoinsBatch

This commit is contained in:
Sérgio Salgado 2022-02-03 18:50:26 +00:00
parent 2da14d64b3
commit 418668d232

View file

@ -85,14 +85,14 @@ function sendCoinsBatch (account, txs, cryptoCode) {
.then(() => calculateFeeDiscount(feeMultiplier)) .then(() => calculateFeeDiscount(feeMultiplier))
.then(newFee => fetch('settxfee', [newFee])) .then(newFee => fetch('settxfee', [newFee]))
.then(() => { .then(() => {
const txAddressAmountPairs = _.map(tx => [tx.address, tx.cryptoAtoms.shift(-unitScale).toFixed(8)], txs) const txAddressAmountPairs = _.map(tx => [tx.address, tx.cryptoAtoms.shiftedBy(-unitScale).toFixed(8)], txs)
return Promise.all([JSON.stringify(_.fromPairs(txAddressAmountPairs))]) return Promise.all([JSON.stringify(_.fromPairs(txAddressAmountPairs))])
}) })
.then(([obj]) => fetch('sendmany', ['', obj])) .then(([obj]) => fetch('sendmany', ['', obj]))
.then((txId) => fetch('gettransaction', [txId])) .then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res)) .then((res) => _.pick(['fee', 'txid'], res))
.then((pickedObj) => ({ .then((pickedObj) => ({
fee: BN(pickedObj.fee).abs().shift(unitScale).round(), fee: new BN(pickedObj.fee).abs().shiftedBy(unitScale).decimalPlaces(0),
txid: pickedObj.txid txid: pickedObj.txid
})) }))
.catch(err => { .catch(err => {