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:
Sérgio Salgado 2021-05-24 02:53:36 +01:00
parent c8adaabf85
commit 73c0d09198
7 changed files with 154 additions and 6 deletions

View file

@ -75,6 +75,24 @@ function sendCoins (settings, tx) {
})
}
function sendCoinsBatch (settings, txs, cryptoCode) {
return fetchWallet(settings, cryptoCode)
.then(r => {
return r.wallet.sendCoinsBatch(r.account, txs, cryptoCode)
.then(res => {
mem.clear(module.exports.balance)
return res
})
})
.catch(err => {
if (err.name === INSUFFICIENT_FUNDS_NAME) {
throw httpError(INSUFFICIENT_FUNDS_NAME, INSUFFICIENT_FUNDS_CODE)
}
throw err
})
}
function newAddress (settings, info, tx) {
const walletAddressPromise = fetchWallet(settings, info.cryptoCode)
.then(r => r.wallet.newAddress(r.account, info, tx, settings, r.operatorId))
@ -235,11 +253,13 @@ const balanceFiltered = mem(_balance, {
module.exports = {
balance,
sendCoins,
sendCoinsBatch,
newAddress,
getStatus,
isStrictAddress,
sweep,
isHd,
newFunding,
cryptoNetwork
cryptoNetwork,
supportsBatching
}