fix: check for wallet tx batching support

This commit is contained in:
Sérgio Salgado 2021-05-24 16:16:51 +01:00
parent 73c0d09198
commit 8289c55acf
10 changed files with 77 additions and 26 deletions

View file

@ -129,11 +129,17 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}
module.exports = {
balance,
sendCoins,
newAddress,
getStatus,
newFunding,
cryptoNetwork
cryptoNetwork,
supportsBatching
}

View file

@ -170,6 +170,11 @@ function fetchRBF (txId) {
})
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}
module.exports = {
balance,
sendCoins,
@ -179,5 +184,6 @@ module.exports = {
cryptoNetwork,
fetchRBF,
estimateFee,
sendCoinsBatch
sendCoinsBatch,
supportsBatching
}

View file

@ -157,6 +157,11 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
.then(() => account.environment === 'test' ? 'test' : 'main')
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}
module.exports = {
NAME,
balance,
@ -164,5 +169,6 @@ module.exports = {
newAddress,
getStatus,
newFunding,
cryptoNetwork
cryptoNetwork,
supportsBatching
}

View file

@ -112,10 +112,16 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}
module.exports = {
balance,
sendCoins,
newAddress,
getStatus,
newFunding
newFunding,
supportsBatching
}

View file

@ -29,7 +29,8 @@ module.exports = {
newFunding,
privateKey,
isStrictAddress,
connect
connect,
supportsBatching
}
function connect (url) {
@ -222,3 +223,8 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
})
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}

View file

@ -112,10 +112,16 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}
module.exports = {
balance,
sendCoins,
newAddress,
getStatus,
newFunding
newFunding,
supportsBatching
}

View file

@ -3,8 +3,10 @@ const _ = require('lodash/fp')
const BN = require('../../../bn')
const E = require('../../../error')
const { utils: coinUtils } = require('lamassu-coins')
const consoleLogLevel = require('console-log-level')
const NAME = 'FakeWallet'
const BATCHABLE_COINS = ['BTC']
const SECONDS = 1000
const PUBLISH_TIME = 3 * SECONDS
@ -59,9 +61,6 @@ function sendCoins (account, tx, settings, operatorId) {
})
}
<<<<<<< HEAD
function newAddress (account, info, tx, settings, operatorId) {
=======
function sendCoinsBatch (account, txs, cryptoCode) {
sendCount = sendCount + txs.length
return new Promise((resolve, reject) => {
@ -81,7 +80,6 @@ function sendCoinsBatch (account, txs, cryptoCode) {
}
function newAddress () {
>>>>>>> feat: add transaction batching module
t0 = Date.now()
return Promise.resolve('<Fake address, don\'t send>')
}
@ -114,6 +112,10 @@ function getStatus (account, tx, requested, settings, operatorId) {
return Promise.resolve({status: 'confirmed'})
}
function supportsBatching (account, cryptoCode) {
return Promise.resolve(_.includes(cryptoCode, BATCHABLE_COINS))
}
module.exports = {
NAME,
balance,
@ -121,5 +123,6 @@ module.exports = {
sendCoins,
newAddress,
getStatus,
newFunding
newFunding,
supportsBatching
}

View file

@ -138,10 +138,16 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
}
function supportsBatching (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => _.isFunction(sendCoinsBatch))
}
module.exports = {
balance,
sendCoins,
newAddress,
getStatus,
newFunding
newFunding,
supportsBatching
}