Send legacy address for BCH on bitgo api
This commit is contained in:
parent
1773c0ca2a
commit
71ed3b83dd
1 changed files with 12 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ const userAgent = 'Lamassu-Server/' + pjson.version
|
|||
|
||||
const NAME = 'BitGo'
|
||||
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH']
|
||||
const BCH_CODES = ['BCH', 'TBCH']
|
||||
|
||||
function buildBitgo (account) {
|
||||
const env = account.environment === 'test' ? 'test' : 'prod'
|
||||
|
|
@ -34,19 +35,24 @@ function checkCryptoCode (cryptoCode) {
|
|||
}
|
||||
|
||||
function getLegacyAddress (address, cryptoCode) {
|
||||
const BCH_CODES = ['BCH', 'TBCH']
|
||||
if (!BCH_CODES.includes(cryptoCode)) return address
|
||||
|
||||
return toLegacyAddress(address)
|
||||
}
|
||||
|
||||
function getCashAddress (address, cryptoCode) {
|
||||
const BCH_CODES = ['BCH', 'TBCH']
|
||||
if (!BCH_CODES.includes(cryptoCode)) return address
|
||||
|
||||
return toCashAddress(address)
|
||||
}
|
||||
|
||||
function formatToGetStatus (address, cryptoCode) {
|
||||
if (!BCH_CODES.includes(cryptoCode)) return address
|
||||
|
||||
const [part1, part2] = getLegacyAddress(address, cryptoCode).split(':')
|
||||
return part2 || part1
|
||||
}
|
||||
|
||||
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getWallet(account, cryptoCode))
|
||||
|
|
@ -99,7 +105,10 @@ function newAddress (account, info) {
|
|||
function getStatus (account, toAddress, requested, cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getWallet(account, cryptoCode))
|
||||
.then(wallet => wallet.transfers({ type: 'receive', address: toAddress }))
|
||||
.then(wallet => wallet.transfers({
|
||||
type: 'receive',
|
||||
address: formatToGetStatus(toAddress, cryptoCode)
|
||||
}))
|
||||
.then(({ transfers }) => {
|
||||
const filterConfirmed = _.filter(it =>
|
||||
it.state === 'confirmed' && it.type === 'receive'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue