Merge pull request #1113 from josepfo/fix/fee-priority-selector-up-to-spec

feat: advanced wallet settings up to spec
This commit is contained in:
Rafael Taranto 2022-02-18 16:59:53 +00:00 committed by GitHub
commit 6f0c735be8
11 changed files with 263 additions and 153 deletions

View file

@ -11,6 +11,8 @@ const unitScale = cryptoRec.unitScale
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
const SUPPORTS_BATCHING = true
function fetch (method, params) {
return jsonRpc.fetch(rpcConfig, method, params)
}
@ -63,7 +65,10 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
return checkCryptoCode(cryptoCode)
.then(() => calculateFeeDiscount(feeMultiplier))
.then(newFee => fetch('settxfee', [newFee]))
.then(newFee => {
logger.info('** DEBUG MINERS FEE ** - Calculated fee discount: ', newFee)
return fetch('settxfee', [newFee])
})
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
@ -82,7 +87,10 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
function sendCoinsBatch (account, txs, cryptoCode, feeMultiplier) {
return checkCryptoCode(cryptoCode)
.then(() => calculateFeeDiscount(feeMultiplier))
.then(newFee => fetch('settxfee', [newFee]))
.then(newFee => {
logger.info('** DEBUG MINERS FEE ** - Calculated fee discount: ', newFee)
return fetch('settxfee', [newFee])
})
.then(() => {
const txAddressAmountPairs = _.map(tx => [tx.toAddress, BN(tx.cryptoAtoms).shiftedBy(-unitScale).toFixed(8)], txs)
return _.fromPairs(txAddressAmountPairs)
@ -186,5 +194,6 @@ module.exports = {
fetchRBF,
estimateFee,
sendCoinsBatch,
checkBlockchainStatus
checkBlockchainStatus,
SUPPORTS_BATCHING
}