feat: add transaction batching option to advanced wallet settings

This commit is contained in:
Sérgio Salgado 2022-02-03 17:11:48 +00:00
parent 2da14d64b3
commit 68d9d95dfa
12 changed files with 25 additions and 74 deletions

View file

@ -8,8 +8,6 @@ const { utils: coinUtils } = require('lamassu-coins')
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
const unitScale = cryptoRec.unitScale
const SUPPORTS_BATCHING = false
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
function fetch (method, params) {
@ -118,11 +116,6 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getblockchaininfo'))
@ -136,6 +129,5 @@ module.exports = {
getStatus,
newFunding,
cryptoNetwork,
supportsBatching,
checkBlockchainStatus
}

View file

@ -9,7 +9,6 @@ const { utils: coinUtils } = require('lamassu-coins')
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
const unitScale = cryptoRec.unitScale
const SUPPORTS_BATCHING = true
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
function fetch (method, params) {
@ -171,11 +170,6 @@ function fetchRBF (txId) {
})
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getblockchaininfo'))
@ -192,6 +186,5 @@ module.exports = {
fetchRBF,
estimateFee,
sendCoinsBatch,
supportsBatching,
checkBlockchainStatus
}

View file

@ -14,8 +14,6 @@ const NAME = 'BitGo'
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH']
const BCH_CODES = ['BCH', 'TBCH']
const SUPPORTS_BATCHING = false
function buildBitgo (account) {
const env = account.environment === 'test' ? 'test' : 'prod'
return new BitGo.BitGo({ accessToken: account.token.trim(), env, userAgent: userAgent })
@ -159,11 +157,6 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
.then(() => account.environment === 'test' ? 'test' : 'main')
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => Promise.resolve('ready'))
@ -177,6 +170,5 @@ module.exports = {
getStatus,
newFunding,
cryptoNetwork,
supportsBatching,
checkBlockchainStatus
}

View file

@ -9,7 +9,6 @@ const E = require('../../../error')
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
const unitScale = cryptoRec.unitScale
const SUPPORTS_BATCHING = false
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
function fetch (method, params) {
@ -113,11 +112,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getblockchaininfo'))
@ -130,6 +124,5 @@ module.exports = {
newAddress,
getStatus,
newFunding,
supportsBatching,
checkBlockchainStatus
}

View file

@ -17,8 +17,6 @@ const paymentPrefixPath = "m/44'/60'/0'/0'"
const defaultPrefixPath = "m/44'/60'/1'/0'"
let lastUsedNonces = {}
const SUPPORTS_BATCHING = false
module.exports = {
NAME,
balance,
@ -32,7 +30,6 @@ module.exports = {
privateKey,
isStrictAddress,
connect,
supportsBatching,
checkBlockchainStatus
}
@ -227,11 +224,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
})
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(pify(web3.eth.isSyncing))

View file

@ -9,7 +9,6 @@ const E = require('../../../error')
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
const unitScale = cryptoRec.unitScale
const SUPPORTS_BATCHING = false
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
function fetch (method, params) {
@ -113,11 +112,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getblockchaininfo'))
@ -130,6 +124,5 @@ module.exports = {
newAddress,
getStatus,
newFunding,
supportsBatching,
checkBlockchainStatus
}

View file

@ -5,7 +5,6 @@ const E = require('../../../error')
const { utils: coinUtils } = require('lamassu-coins')
const NAME = 'FakeWallet'
const BATCHABLE_COINS = ['BTC']
const SECONDS = 1000
const PUBLISH_TIME = 3 * SECONDS
@ -111,10 +110,6 @@ function getStatus (account, tx, requested, settings, operatorId) {
return Promise.resolve({status: 'confirmed'})
}
function supportsBatching (cryptoCode) {
return Promise.resolve(_.includes(cryptoCode, BATCHABLE_COINS))
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => Promise.resolve('ready'))
@ -128,6 +123,5 @@ module.exports = {
newAddress,
getStatus,
newFunding,
supportsBatching,
checkBlockchainStatus
}

View file

@ -17,8 +17,6 @@ const configPath = utils.configPath(cryptoRec, blockchainDir)
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, blockchainDir), 'wallets')
const unitScale = cryptoRec.unitScale
const SUPPORTS_BATCHING = false
function rpcConfig () {
try {
const config = jsonRpc.parseConf(configPath)
@ -200,11 +198,6 @@ function cryptoNetwork (account, cryptoCode) {
})
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
@ -236,6 +229,5 @@ module.exports = {
getStatus,
newFunding,
cryptoNetwork,
supportsBatching,
checkBlockchainStatus
}

View file

@ -9,7 +9,6 @@ const E = require('../../../error')
const cryptoRec = coinUtils.getCryptoCurrency('ZEC')
const unitScale = cryptoRec.unitScale
const SUPPORTS_BATCHING = false
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
@ -139,11 +138,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
}))
}
function supportsBatching (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getblockchaininfo'))
@ -156,6 +150,5 @@ module.exports = {
newAddress,
getStatus,
newFunding,
supportsBatching,
checkBlockchainStatus
}