feat: add transaction batching module
feat: plugin sendCoins batching support feat: batching processing on poller feat: mock-wallet batching fix: bitcoin tx batching fix: transaction batching db table
This commit is contained in:
parent
c8adaabf85
commit
73c0d09198
7 changed files with 154 additions and 6 deletions
|
|
@ -81,13 +81,18 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
|
|||
|
||||
function sendCoinsBatch (account, txs, cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => calculateFeeDiscount(feeMultiplier))
|
||||
.then(newFee => fetch('settxfee', [newFee]))
|
||||
.then(() => {
|
||||
const txAddressAmountPairs = _.map(tx => [tx.address, tx.cryptoAtoms.shift(-unitScale).toFixed(8)], txs)
|
||||
return Promise.all([JSON.stringify(_.fromPairs(txAddressAmountPairs))])
|
||||
})
|
||||
.then(([obj]) => fetch('sendmany', ['', obj]))
|
||||
.then(res => ({
|
||||
txid: res.txid
|
||||
.then((txId) => fetch('gettransaction', [txId]))
|
||||
.then((res) => _.pick(['fee', 'txid'], res))
|
||||
.then((pickedObj) => ({
|
||||
fee: BN(pickedObj.fee).abs().shift(unitScale).round(),
|
||||
txid: pickedObj.txid
|
||||
}))
|
||||
.catch(err => {
|
||||
if (err.code === -6) throw new E.InsufficientFundsError()
|
||||
|
|
@ -173,5 +178,6 @@ module.exports = {
|
|||
newFunding,
|
||||
cryptoNetwork,
|
||||
fetchRBF,
|
||||
estimateFee
|
||||
estimateFee,
|
||||
sendCoinsBatch
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue