fix: bitgo using old code
This commit is contained in:
parent
d735b2dc67
commit
fc7ef28ece
1 changed files with 19 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
const BitGo = require('bitgo')
|
||||
const { BitGoAPI } = require('@bitgo/sdk-api')
|
||||
const { toLegacyAddress, toCashAddress } = require('bchaddrjs')
|
||||
|
||||
const BN = require('../../../bn')
|
||||
|
|
@ -11,19 +11,29 @@ const pjson = require('../../../../package.json')
|
|||
const userAgent = 'Lamassu-Server/' + pjson.version
|
||||
|
||||
const NAME = 'BitGo'
|
||||
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH']
|
||||
|
||||
const BITGO_MODULES = {
|
||||
BCH: require('@bitgo/sdk-coin-bch'),
|
||||
BTC: require('@bitgo/sdk-coin-btc'),
|
||||
DASH: require('@bitgo/sdk-coin-dash'),
|
||||
LTC: require('@bitgo/sdk-coin-ltc'),
|
||||
ZEC: require('@bitgo/sdk-coin-zec'),
|
||||
}
|
||||
const SUPPORTED_COINS = _.keys(BITGO_MODULES)
|
||||
const BCH_CODES = ['BCH', 'TBCH']
|
||||
|
||||
function buildBitgo (account) {
|
||||
const getWallet = (account, cryptoCode) => {
|
||||
const accessToken = account.token.trim()
|
||||
const env = account.environment === 'test' ? 'test' : 'prod'
|
||||
return new BitGo.BitGo({ accessToken: account.token.trim(), env, userAgent: userAgent })
|
||||
}
|
||||
const walletId = account[`${cryptoCode}WalletId`]
|
||||
|
||||
function getWallet (account, cryptoCode) {
|
||||
const bitgo = buildBitgo(account)
|
||||
const coin = account.environment === 'test' ? `t${cryptoCode.toLowerCase()}` : cryptoCode.toLowerCase()
|
||||
const bitgo = new BitGoAPI({ accessToken, env, userAgent })
|
||||
BITGO_MODULES[cryptoCode].register(bitgo)
|
||||
|
||||
return bitgo.coin(coin).wallets().get({ id: account[`${cryptoCode}WalletId`] })
|
||||
cryptoCode = cryptoCode.toLowerCase()
|
||||
const coin = env === 'test' ? `t${cryptoCode}` : cryptoCode
|
||||
|
||||
return bitgo.coin(coin).wallets().get({ id: walletId })
|
||||
}
|
||||
|
||||
function checkCryptoCode (cryptoCode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue