Merge pull request #1088 from chaotixkilla/feat-add-transaction-batching-option
Add transaction batching option to advanced wallet settings
This commit is contained in:
commit
7f4858ddd4
12 changed files with 29 additions and 74 deletions
|
|
@ -8,8 +8,6 @@ const { utils: coinUtils } = require('lamassu-coins')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
|
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
|
|
||||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||||
|
|
||||||
function fetch (method, params) {
|
function fetch (method, params) {
|
||||||
|
|
@ -118,11 +116,6 @@ function cryptoNetwork (account, cryptoCode, settings, operatorId) {
|
||||||
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
|
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsBatching (cryptoCode) {
|
|
||||||
return checkCryptoCode(cryptoCode)
|
|
||||||
.then(() => SUPPORTS_BATCHING)
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkBlockchainStatus (cryptoCode) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getblockchaininfo'))
|
.then(() => fetch('getblockchaininfo'))
|
||||||
|
|
@ -136,6 +129,5 @@ module.exports = {
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
cryptoNetwork,
|
cryptoNetwork,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ const { utils: coinUtils } = require('lamassu-coins')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = true
|
|
||||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||||
|
|
||||||
function fetch (method, params) {
|
function fetch (method, params) {
|
||||||
|
|
@ -171,11 +170,6 @@ function fetchRBF (txId) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsBatching (cryptoCode) {
|
|
||||||
return checkCryptoCode(cryptoCode)
|
|
||||||
.then(() => SUPPORTS_BATCHING)
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkBlockchainStatus (cryptoCode) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getblockchaininfo'))
|
.then(() => fetch('getblockchaininfo'))
|
||||||
|
|
@ -192,6 +186,5 @@ module.exports = {
|
||||||
fetchRBF,
|
fetchRBF,
|
||||||
estimateFee,
|
estimateFee,
|
||||||
sendCoinsBatch,
|
sendCoinsBatch,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ const NAME = 'BitGo'
|
||||||
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH']
|
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH']
|
||||||
const BCH_CODES = ['BCH', 'TBCH']
|
const BCH_CODES = ['BCH', 'TBCH']
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
|
|
||||||
function buildBitgo (account) {
|
function buildBitgo (account) {
|
||||||
const env = account.environment === 'test' ? 'test' : 'prod'
|
const env = account.environment === 'test' ? 'test' : 'prod'
|
||||||
return new BitGo.BitGo({ accessToken: account.token.trim(), env, userAgent: userAgent })
|
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')
|
.then(() => account.environment === 'test' ? 'test' : 'main')
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsBatching (cryptoCode) {
|
|
||||||
return checkCryptoCode(cryptoCode)
|
|
||||||
.then(() => SUPPORTS_BATCHING)
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkBlockchainStatus (cryptoCode) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => Promise.resolve('ready'))
|
.then(() => Promise.resolve('ready'))
|
||||||
|
|
@ -177,6 +170,5 @@ module.exports = {
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
cryptoNetwork,
|
cryptoNetwork,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ const E = require('../../../error')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
|
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||||
|
|
||||||
function fetch (method, params) {
|
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) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getblockchaininfo'))
|
.then(() => fetch('getblockchaininfo'))
|
||||||
|
|
@ -130,6 +124,5 @@ module.exports = {
|
||||||
newAddress,
|
newAddress,
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ const paymentPrefixPath = "m/44'/60'/0'/0'"
|
||||||
const defaultPrefixPath = "m/44'/60'/1'/0'"
|
const defaultPrefixPath = "m/44'/60'/1'/0'"
|
||||||
let lastUsedNonces = {}
|
let lastUsedNonces = {}
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
NAME,
|
NAME,
|
||||||
balance,
|
balance,
|
||||||
|
|
@ -32,7 +30,6 @@ module.exports = {
|
||||||
privateKey,
|
privateKey,
|
||||||
isStrictAddress,
|
isStrictAddress,
|
||||||
connect,
|
connect,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,11 +224,6 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsBatching (cryptoCode) {
|
|
||||||
return checkCryptoCode(cryptoCode)
|
|
||||||
.then(() => SUPPORTS_BATCHING)
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkBlockchainStatus (cryptoCode) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(pify(web3.eth.isSyncing))
|
.then(pify(web3.eth.isSyncing))
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ const E = require('../../../error')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
|
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
||||||
|
|
||||||
function fetch (method, params) {
|
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) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getblockchaininfo'))
|
.then(() => fetch('getblockchaininfo'))
|
||||||
|
|
@ -130,6 +124,5 @@ module.exports = {
|
||||||
newAddress,
|
newAddress,
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ const E = require('../../../error')
|
||||||
const { utils: coinUtils } = require('lamassu-coins')
|
const { utils: coinUtils } = require('lamassu-coins')
|
||||||
|
|
||||||
const NAME = 'FakeWallet'
|
const NAME = 'FakeWallet'
|
||||||
const BATCHABLE_COINS = ['BTC']
|
|
||||||
|
|
||||||
const SECONDS = 1000
|
const SECONDS = 1000
|
||||||
const PUBLISH_TIME = 3 * SECONDS
|
const PUBLISH_TIME = 3 * SECONDS
|
||||||
|
|
@ -111,10 +110,6 @@ function getStatus (account, tx, requested, settings, operatorId) {
|
||||||
return Promise.resolve({status: 'confirmed'})
|
return Promise.resolve({status: 'confirmed'})
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsBatching (cryptoCode) {
|
|
||||||
return Promise.resolve(_.includes(cryptoCode, BATCHABLE_COINS))
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkBlockchainStatus (cryptoCode) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => Promise.resolve('ready'))
|
.then(() => Promise.resolve('ready'))
|
||||||
|
|
@ -128,6 +123,5 @@ module.exports = {
|
||||||
newAddress,
|
newAddress,
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ const configPath = utils.configPath(cryptoRec, blockchainDir)
|
||||||
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, blockchainDir), 'wallets')
|
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, blockchainDir), 'wallets')
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
|
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
|
|
||||||
function rpcConfig () {
|
function rpcConfig () {
|
||||||
try {
|
try {
|
||||||
const config = jsonRpc.parseConf(configPath)
|
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) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
@ -236,6 +229,5 @@ module.exports = {
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
cryptoNetwork,
|
cryptoNetwork,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ const E = require('../../../error')
|
||||||
|
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('ZEC')
|
const cryptoRec = coinUtils.getCryptoCurrency('ZEC')
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
const SUPPORTS_BATCHING = false
|
|
||||||
|
|
||||||
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
|
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) {
|
function checkBlockchainStatus (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getblockchaininfo'))
|
.then(() => fetch('getblockchaininfo'))
|
||||||
|
|
@ -156,6 +150,5 @@ module.exports = {
|
||||||
newAddress,
|
newAddress,
|
||||||
getStatus,
|
getStatus,
|
||||||
newFunding,
|
newFunding,
|
||||||
supportsBatching,
|
|
||||||
checkBlockchainStatus
|
checkBlockchainStatus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,8 +233,7 @@ function isStrictAddress (settings, cryptoCode, toAddress) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function supportsBatching (settings, cryptoCode) {
|
function supportsBatching (settings, cryptoCode) {
|
||||||
return fetchWallet(settings, cryptoCode)
|
return Promise.resolve(!!configManager.getWalletSettings(cryptoCode, settings.config).allowTransactionBatching)
|
||||||
.then(r => r.wallet.supportsBatching(cryptoCode))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkBlockchainStatus (settings, cryptoCode) {
|
function checkBlockchainStatus (settings, cryptoCode) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@ import React from 'react'
|
||||||
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
||||||
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
import { AdvancedWalletSchema, getAdvancedWalletElements } from './helper'
|
import {
|
||||||
|
WalletSchema,
|
||||||
|
AdvancedWalletSchema,
|
||||||
|
getAdvancedWalletElements
|
||||||
|
} from './helper'
|
||||||
|
|
||||||
const SAVE_CONFIG = gql`
|
const SAVE_CONFIG = gql`
|
||||||
mutation Save($config: JSONObject, $accounts: JSONObject) {
|
mutation Save($config: JSONObject, $accounts: JSONObject) {
|
||||||
|
|
@ -51,8 +55,9 @@ const AdvancedWallet = () => {
|
||||||
enableEdit
|
enableEdit
|
||||||
editWidth={174}
|
editWidth={174}
|
||||||
save={save}
|
save={save}
|
||||||
|
stripeWhen={it => !WalletSchema.isValidSync(it)}
|
||||||
validationSchema={AdvancedWalletSchema}
|
validationSchema={AdvancedWalletSchema}
|
||||||
elements={getAdvancedWalletElements(cryptoCurrencies, coinUtils)}
|
elements={getAdvancedWalletElements(cryptoCurrencies, coinUtils, config)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
import { NumberInput } from 'src/components/inputs/formik'
|
import {
|
||||||
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
|
Autocomplete,
|
||||||
|
Checkbox,
|
||||||
|
NumberInput
|
||||||
|
} from 'src/components/inputs/formik'
|
||||||
import { disabledColor } from 'src/styling/variables'
|
import { disabledColor } from 'src/styling/variables'
|
||||||
import { CURRENCY_MAX } from 'src/utils/constants'
|
import { CURRENCY_MAX } from 'src/utils/constants'
|
||||||
import { transformNumber } from 'src/utils/number'
|
import { transformNumber } from 'src/utils/number'
|
||||||
|
|
@ -29,10 +32,11 @@ const WalletSchema = Yup.object().shape({
|
||||||
})
|
})
|
||||||
|
|
||||||
const AdvancedWalletSchema = Yup.object().shape({
|
const AdvancedWalletSchema = Yup.object().shape({
|
||||||
cryptoUnits: Yup.string().required()
|
cryptoUnits: Yup.string().required(),
|
||||||
|
allowTransactionBatching: Yup.boolean()
|
||||||
})
|
})
|
||||||
|
|
||||||
const getAdvancedWalletElements = (cryptoCurrencies, coinUtils) => {
|
const getAdvancedWalletElements = (cryptoCurrencies, coinUtils, config) => {
|
||||||
const viewCryptoCurrency = it =>
|
const viewCryptoCurrency = it =>
|
||||||
R.compose(
|
R.compose(
|
||||||
R.prop(['display']),
|
R.prop(['display']),
|
||||||
|
|
@ -66,6 +70,19 @@ const getAdvancedWalletElements = (cryptoCurrencies, coinUtils) => {
|
||||||
valueProp: 'code',
|
valueProp: 'code',
|
||||||
labelProp: 'display'
|
labelProp: 'display'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'allowTransactionBatching',
|
||||||
|
size: 'sm',
|
||||||
|
stripe: true,
|
||||||
|
width: 250,
|
||||||
|
view: (_, ite) => {
|
||||||
|
if (ite.id !== 'BTC')
|
||||||
|
return <span style={classes.editDisabled}>{`No`}</span>
|
||||||
|
return config[`${ite.id}_allowTransactionBatching`] ? 'Yes' : 'No'
|
||||||
|
},
|
||||||
|
input: Checkbox,
|
||||||
|
editable: it => it.id === 'BTC'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue