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