Chore: refactor generic wallet and wallet plugins

This commit is contained in:
csrapr 2021-03-16 18:41:44 +00:00 committed by Josh Harvey
parent d2b7224c73
commit b6d91f94bf
11 changed files with 110 additions and 87 deletions

View file

@ -259,7 +259,7 @@ function plugins (settings, deviceId) {
}
function sendCoins (tx) {
return wallet.sendCoins(settings, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode)
return wallet.sendCoins(settings, tx)
}
function recordPing (deviceTime, version, model) {
@ -279,7 +279,7 @@ function plugins (settings, deviceId) {
}
function isHd (tx) {
return wallet.isHd(settings, tx.cryptoCode)
return wallet.isHd(settings, tx)
}
function getStatus (tx) {
@ -295,7 +295,7 @@ function plugins (settings, deviceId) {
cryptoAtoms: tx.cryptoAtoms,
isLightning: tx.isLightning
}
return wallet.newAddress(settings, info)
return wallet.newAddress(settings, info, tx)
}
function dispenseAck (tx) {

View file

@ -45,15 +45,15 @@ function accountUnconfirmedBalance (cryptoCode) {
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
return checkCryptoCode(cryptoCode)
.then(() => fetch('sendtoaddress', [address, coins]))
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
.then((pickedObj) => {
@ -68,7 +68,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
})
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => fetch('getnewaddress'))
}
@ -88,7 +88,9 @@ function pendingBalance (address, cryptoCode) {
.then(() => addressBalance(address, 0))
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(toAddress, cryptoCode))
.then(confirmed => {
@ -103,7 +105,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
})
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
@ -121,7 +123,7 @@ function newFunding (account, cryptoCode) {
}))
}
function cryptoNetwork (account, cryptoCode) {
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
}

View file

@ -45,15 +45,16 @@ function accountUnconfirmedBalance (cryptoCode) {
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
return checkCryptoCode(cryptoCode)
.then(() => fetch('sendtoaddress', [address, coins]))
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
.then((pickedObj) => {
@ -68,7 +69,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
})
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => fetch('getnewaddress'))
}
@ -88,7 +89,8 @@ function pendingBalance (address, cryptoCode) {
.then(() => addressBalance(address, 0))
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(toAddress, cryptoCode))
.then(confirmed => {
@ -103,7 +105,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
})
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
@ -121,7 +123,7 @@ function newFunding (account, cryptoCode) {
}))
}
function cryptoNetwork (account, cryptoCode) {
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => parseInt(rpcConfig.port, 10) === 18332 ? 'test' : 'main')
}

View file

@ -53,12 +53,13 @@ function formatToGetStatus (address, cryptoCode) {
return part2 || part1
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => getWallet(account, cryptoCode))
.then(wallet => {
const params = {
address: getLegacyAddress(address, cryptoCode),
address: getLegacyAddress(toAddress, cryptoCode),
amount: cryptoAtoms.toNumber(),
walletPassphrase: account[`${cryptoCode}WalletPassphrase`],
enforceMinConfirmsForChange: false
@ -77,13 +78,13 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
})
}
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => getWallet(account, cryptoCode))
.then(wallet => BN(wallet._wallet.spendableBalanceString))
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => getWallet(account, info.cryptoCode))
.then(wallet => {
@ -102,7 +103,8 @@ function newAddress (account, info) {
})
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => getWallet(account, cryptoCode))
.then(wallet => wallet.transfers({
@ -131,7 +133,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
})
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
return getWallet(account, cryptoCode)
@ -150,7 +152,7 @@ function newFunding (account, cryptoCode) {
})
}
function cryptoNetwork (account, cryptoCode) {
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => account.environment === 'test' ? 'test' : 'main')
}

View file

@ -46,15 +46,16 @@ function accountUnconfirmedBalance (cryptoCode) {
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
return checkCryptoCode(cryptoCode)
.then(() => fetch('sendtoaddress', [address, coins]))
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
.then((pickedObj) => {
@ -69,7 +70,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
})
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => fetch('getnewaddress'))
}
@ -89,7 +90,8 @@ function pendingBalance (address, cryptoCode) {
.then(() => addressBalance(address, 0))
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(toAddress, cryptoCode))
.then(confirmed => {
@ -104,7 +106,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
})
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [

View file

@ -42,11 +42,12 @@ function privateKey (account) {
return defaultWallet(account).getPrivateKey()
}
function isStrictAddress (cryptoCode, toAddress) {
function isStrictAddress (cryptoCode, toAddress, settings, operatorId) {
return cryptoCode === 'ETH' && util.isValidChecksumAddress(toAddress)
}
function sendCoins (account, toAddress, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms } = tx
return generateTx(toAddress, defaultWallet(account), cryptoAtoms, false)
.then(pify(web3.eth.sendRawTransaction))
.then(txid => {
@ -66,7 +67,7 @@ function checkCryptoCode (cryptoCode) {
return Promise.reject(new Error('cryptoCode must be ETH'))
}
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(defaultAddress(account)))
}
@ -139,7 +140,7 @@ function defaultAddress (account) {
return defaultWallet(account).getChecksumAddressString()
}
function sweep (account, cryptoCode, hdIndex) {
function sweep (account, cryptoCode, hdIndex, settings, operatorId) {
const wallet = paymentHdNode(account).deriveChild(hdIndex).getWallet()
const fromAddress = wallet.getChecksumAddressString()
@ -152,20 +153,21 @@ function sweep (account, cryptoCode, hdIndex) {
})
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
const childNode = paymentHdNode(account).deriveChild(info.hdIndex)
return Promise.resolve(childNode.getWallet().getChecksumAddressString())
}
function getStatus (account, toAddress, cryptoAtoms, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(toAddress))
.then(confirmed => {
if (confirmed.gte(cryptoAtoms)) return { receivedCryptoAtoms: confirmed, status: 'confirmed' }
if (confirmed.gte(requested)) return { receivedCryptoAtoms: confirmed, status: 'confirmed' }
return pendingBalance(toAddress)
.then(pending => {
if (pending.gte(cryptoAtoms)) return { receivedCryptoAtoms: pending, status: 'published' }
if (pending.gte(requested)) return { receivedCryptoAtoms: pending, status: 'published' }
if (pending.gt(0)) return { receivedCryptoAtoms: pending, status: 'insufficientFunds' }
return { receivedCryptoAtoms: pending, status: 'notSeen' }
})
@ -186,7 +188,7 @@ function defaultHdNode (account) {
return key.derivePath(defaultPrefixPath)
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
const fundingAddress = defaultAddress(account)

View file

@ -45,15 +45,16 @@ function accountUnconfirmedBalance (cryptoCode) {
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
return checkCryptoCode(cryptoCode)
.then(() => fetch('sendtoaddress', [address, coins]))
.then(() => fetch('sendtoaddress', [toAddress, coins]))
.then((txId) => fetch('gettransaction', [txId]))
.then((res) => _.pick(['fee', 'txid'], res))
.then((pickedObj) => {
@ -68,7 +69,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
})
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => fetch('getnewaddress'))
}
@ -88,7 +89,8 @@ function pendingBalance (address, cryptoCode) {
.then(() => addressBalance(address, 0))
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(toAddress, cryptoCode))
.then(confirmed => {
@ -103,7 +105,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
})
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [

View file

@ -23,7 +23,7 @@ function connect () {
return lnd.connect(options.lnd || {})
}
function cryptoNetwork (account, cryptoCode) {
function cryptoNetwork (account, cryptoCode, settings, operatorId) {
return Promise.resolve('main')
}
@ -32,7 +32,7 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function balance (acount, cryptoCode) {
function balance (acount, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(connect)
.then(c => c.channelBalance({}))
@ -41,17 +41,18 @@ function balance (acount, cryptoCode) {
.then(r => r.shift(unitScale).round())
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
// const { toAddress, cryptoAtoms, cryptoCode } = tx
// Not implemented yet
return Promise.reject(new E.NotImplementedError())
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
// Not implemented yet
return Promise.reject(new E.NotImplementedError())
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(connect)
.then(c => {
@ -65,7 +66,8 @@ function newAddress (account, info) {
})
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => {
const parts = _.split(':', toAddress)

View file

@ -17,7 +17,7 @@ function _balance (cryptoCode) {
return BN(10).shift(unitScale).round()
}
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return Promise.resolve()
.then(() => _balance(cryptoCode))
}
@ -39,7 +39,8 @@ function isInsufficient (cryptoAtoms, cryptoCode) {
return cryptoAtoms.gt(b.div(1000).mul(sendCount))
}
function sendCoins (account, toAddress, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
sendCount++
return new Promise((resolve, reject) => {
setTimeout(() => {
@ -56,12 +57,12 @@ function sendCoins (account, toAddress, cryptoAtoms, cryptoCode) {
})
}
function newAddress () {
function newAddress (account, info, tx, settings, operatorId) {
t0 = Date.now()
return Promise.resolve('<Fake address, don\'t send>')
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
const promises = [
pendingBalance(account, cryptoCode),
confirmedBalance(account, cryptoCode),
@ -76,12 +77,13 @@ function newFunding (account, cryptoCode) {
}))
}
function getStatus (account, toAddress, cryptoAtoms, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
const elapsed = Date.now() - t0
if (elapsed < PUBLISH_TIME) return Promise.resolve({ receivedCryptoAtoms: BN(0), status: 'notSeen' })
if (elapsed < AUTHORIZE_TIME) return Promise.resolve({ receivedCryptoAtoms: cryptoAtoms, status: 'published' })
if (elapsed < CONFIRM_TIME) return Promise.resolve({ receivedCryptoAtoms: cryptoAtoms, status: 'authorized' })
if (elapsed < AUTHORIZE_TIME) return Promise.resolve({ receivedCryptoAtoms: requested, status: 'published' })
if (elapsed < CONFIRM_TIME) return Promise.resolve({ receivedCryptoAtoms: requested, status: 'authorized' })
console.log('[%s] DEBUG: Mock wallet has confirmed transaction [%s]', cryptoCode, toAddress.slice(0, 5))

View file

@ -47,11 +47,12 @@ function accountUnconfirmedBalance (cryptoCode) {
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
function balance (account, cryptoCode, settings, operatorId) {
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
function sendCoins (account, tx, settings, operatorId) {
const { toAddress, cryptoAtoms, cryptoCode } = tx
const coins = cryptoAtoms.shift(-unitScale).toFixed(8)
const checkSendStatus = function (opid) {
return new Promise((resolve, reject) => {
@ -75,7 +76,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
const checker = opid => pRetry(() => checkSendStatus(opid), { retries: 20, minTimeout: 300, factor: 1.05 })
return checkCryptoCode(cryptoCode)
.then(() => fetch('z_sendmany', ['ANY_TADDR', [{ address, amount: coins }]]))
.then(() => fetch('z_sendmany', ['ANY_TADDR', [{ toAddress, amount: coins }]]))
.then(checker)
.then((res) => {
return {
@ -95,7 +96,7 @@ function sendCoins (account, address, cryptoAtoms, cryptoCode) {
})
}
function newAddress (account, info) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => fetch('getnewaddress'))
}
@ -115,7 +116,8 @@ function pendingBalance (address, cryptoCode) {
.then(() => addressBalance(address, 0))
}
function getStatus (account, toAddress, requested, cryptoCode) {
function getStatus (account, tx, requested, settings, operatorId) {
const { toAddress, cryptoCode } = tx
return checkCryptoCode(cryptoCode)
.then(() => confirmedBalance(toAddress, cryptoCode))
.then(confirmed => {
@ -130,7 +132,7 @@ function getStatus (account, toAddress, requested, cryptoCode) {
})
}
function newFunding (account, cryptoCode) {
function newFunding (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [

View file

@ -21,6 +21,10 @@ function computeSeed (masterSeed) {
return hkdf(masterSeed, 32, { salt: 'lamassu-server-salt', info: 'wallet-seed' })
}
function computeOperatorId (masterSeed) {
return hkdf(masterSeed, 16, { salt: 'lamassu-server-salt', info: 'operator-id' }).toString('hex')
}
function fetchWallet (settings, cryptoCode) {
return fs.readFile(options.mnemonicPath, 'utf8')
.then(mnemonic => {
@ -30,8 +34,8 @@ function fetchWallet (settings, cryptoCode) {
const rawAccount = settings.accounts[plugin]
const account = _.set('seed', computeSeed(masterSeed), rawAccount)
if (_.isFunction(wallet.run)) wallet.run(account)
return { wallet, account }
const operatorId = computeOperatorId(masterSeed)
return { wallet, account, operatorId }
})
}
@ -39,7 +43,7 @@ const lastBalance = {}
function _balance (settings, cryptoCode) {
return fetchWallet(settings, cryptoCode)
.then(r => r.wallet.balance(r.account, cryptoCode))
.then(r => r.wallet.balance(r.account, cryptoCode, settings, r.operatorId))
.then(balance => ({ balance, timestamp: Date.now() }))
.then(r => {
lastBalance[cryptoCode] = r
@ -51,10 +55,10 @@ function _balance (settings, cryptoCode) {
})
}
function sendCoins (settings, toAddress, cryptoAtoms, cryptoCode) {
return fetchWallet(settings, cryptoCode)
function sendCoins (settings, tx) {
return fetchWallet(settings, tx.cryptoCode)
.then(r => {
return r.wallet.sendCoins(r.account, toAddress, cryptoAtoms, cryptoCode)
return r.wallet.sendCoins(r.account, tx, settings, r.operatorId)
.then(res => {
mem.clear(module.exports.balance)
return res
@ -69,9 +73,9 @@ function sendCoins (settings, toAddress, cryptoAtoms, cryptoCode) {
})
}
function newAddress (settings, info) {
function newAddress (settings, info, tx) {
const walletAddressPromise = fetchWallet(settings, info.cryptoCode)
.then(r => r.wallet.newAddress(r.account, info))
.then(r => r.wallet.newAddress(r.account, info, tx, settings, r.operatorId))
return Promise.all([
walletAddressPromise,
@ -89,7 +93,7 @@ function newFunding (settings, cryptoCode, address) {
const wallet = r.wallet
const account = r.account
return wallet.newFunding(account, cryptoCode)
return wallet.newFunding(account, cryptoCode, settings, r.operatorId)
})
}
@ -117,9 +121,10 @@ function mergeStatusMode (a, b) {
function getWalletStatus (settings, tx) {
const fudgeFactorEnabled = configManager.getWalletSettings(tx.cryptoCode, settings.config).fudgeFactorActive
const fudgeFactor = fudgeFactorEnabled ? 100 : 0
const requested = tx.cryptoAtoms.minus(fudgeFactor)
const walletStatusPromise = fetchWallet(settings, tx.cryptoCode)
.then(r => r.wallet.getStatus(r.account, tx.toAddress, tx.cryptoAtoms.minus(fudgeFactor), tx.cryptoCode))
.then(r => r.wallet.getStatus(r.account, tx, requested, settings, r.operatorId))
return Promise.all([
walletStatusPromise,
@ -176,21 +181,21 @@ function getStatus (settings, tx, machineId) {
function sweep (settings, cryptoCode, hdIndex) {
return fetchWallet(settings, cryptoCode)
.then(r => r.wallet.sweep(r.account, cryptoCode, hdIndex))
.then(r => r.wallet.sweep(r.account, cryptoCode, hdIndex, settings, r.operatorId))
}
function isHd (settings, cryptoCode) {
return fetchWallet(settings, cryptoCode)
function isHd (settings, tx) {
return fetchWallet(settings, tx.cryptoCode)
.then(r => r.wallet.supportsHd)
}
function cryptoNetwork (settings, cryptoCode) {
const plugin = configManager.getWalletSettings(cryptoCode, settings.config).wallet
const wallet = ph.load(ph.WALLET, plugin)
const account = settings.accounts[plugin]
if (!wallet.cryptoNetwork) return Promise.resolve(false)
return wallet.cryptoNetwork(account, cryptoCode)
return fetchWallet(settings, cryptoCode).then(r => {
if (!r.wallet.cryptoNetwork) return Promise.resolve(false)
return r.wallet.cryptoNetwork(account, cryptoCode, settings, r.operatorId)
})
}
function isStrictAddress (settings, cryptoCode, toAddress) {
@ -199,7 +204,7 @@ function isStrictAddress (settings, cryptoCode, toAddress) {
return fetchWallet(settings, cryptoCode)
.then(r => {
if (!r.wallet.isStrictAddress) return true
return r.wallet.isStrictAddress(cryptoCode, toAddress)
return r.wallet.isStrictAddress(cryptoCode, toAddress, settings, r.operatorId)
})
}