fix: parse address before get tx status

This commit is contained in:
José Oliveira 2022-04-19 13:47:35 +01:00 committed by siiky
parent d0b960fd6a
commit 81ef96a670

View file

@ -269,6 +269,7 @@ function getStatus (account, tx, requested, settings, operatorId) {
return 'notSeen' return 'notSeen'
} }
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode) const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
const address = coinUtils.parseUrl(address)
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => getGaloyAccount(account.apiKey)) .then(() => getGaloyAccount(account.apiKey))
.then(galoyAccount => { .then(galoyAccount => {
@ -278,13 +279,13 @@ function getStatus (account, tx, requested, settings, operatorId) {
wallet.id === account.walletId)(galoyAccount.wallets) wallet.id === account.walletId)(galoyAccount.wallets)
) )
const transactions = wallet.transactions.edges const transactions = wallet.transactions.edges
if (isLightning(toAddress)) { if (isLightning(address)) {
const paymentHash = invoice.decode(toAddress).paymentHash.toString('hex') const paymentHash = invoice.decode(address).paymentHash.toString('hex')
const transaction = _.head(_.filter(tx => tx.node.initiationVia.paymentHash === paymentHash && tx.node.direction === 'RECEIVE')(transactions)) const transaction = _.head(_.filter(tx => tx.node.initiationVia.paymentHash === paymentHash && tx.node.direction === 'RECEIVE')(transactions))
return { receivedCryptoAtoms: cryptoAtoms, status: mapStatus(transaction) } return { receivedCryptoAtoms: cryptoAtoms, status: mapStatus(transaction) }
} }
// On-chain tx // On-chain tx
const transaction = _.head(_.filter(tx => tx.node.initiationVia.address === toAddress)(transactions)) const transaction = _.head(_.filter(tx => tx.node.initiationVia.address === address)(transactions))
return { receivedCryptoAtoms: cryptoAtoms, status: mapStatus(transaction) } return { receivedCryptoAtoms: cryptoAtoms, status: mapStatus(transaction) }
}) })
} }