fix(Utxo.get()): Properly handling addresses with no SLP utxos

This commit is contained in:
Chris Troutner
2022-01-19 14:46:00 -08:00
parent 0b1cf57852
commit 6d70568082
4 changed files with 72 additions and 4 deletions
+15 -3
View File
@@ -357,10 +357,22 @@ class UTXO {
// console.log(`utxoData: ${JSON.stringify(utxoData, null, 2)}`)
const utxos = utxoData.utxos
let slpUtxos = []
// Get SLP UTXOs from the psf-slp-indexer
const slpUtxoData = await this.psfSlpIndexer.balance(addr)
// console.log(`slpUtxoData: ${JSON.stringify(slpUtxoData, null, 2)}`)
const slpUtxos = slpUtxoData.balance.utxos
try {
const slpUtxoData = await this.psfSlpIndexer.balance(addr)
// console.log(`slpUtxoData: ${JSON.stringify(slpUtxoData, null, 2)}`)
slpUtxos = slpUtxoData.balance.utxos
} catch (err) {
// console.log('err: ', err)
// Exit quietly if address has no SLP UTXOs. Otherwise, throw the error.
if (err.error && !err.error.includes('Key not found in database')) {
throw err
}
}
// Loop through the Fulcrum UTXOs.
for (let i = 0; i < utxos.length; i++) {