diff --git a/src/slp/utils.js b/src/slp/utils.js index 47dcee6..d77f152 100644 --- a/src/slp/utils.js +++ b/src/slp/utils.js @@ -1141,13 +1141,17 @@ class Utils { const thisUtxo = utxos[i] // console.log(`thisUtxo: ${JSON.stringify(thisUtxo, null, 2)}`) - const thisValidation = validations.filter(x => x.txid === thisUtxo.txid) + const thisValidation = validations.filter(x => { + if (x !== null) return x.txid === thisUtxo.txid + + return false + }) // console.log( // `thisValidation: ${JSON.stringify(thisValidation, null, 2)}` // ) // If the utxo is not SLP, then skip the loop. - if (!thisValidation[0].valid) { + if (!thisValidation[0] || !thisValidation[0].valid) { outAry[i] = false continue } diff --git a/test/unit/slp-utils.js b/test/unit/slp-utils.js index e31ceed..8d9be0b 100644 --- a/test/unit/slp-utils.js +++ b/test/unit/slp-utils.js @@ -1166,6 +1166,42 @@ describe("#SLP Utils", () => { assert2.equal(result.length, 2) assert2.equal(result[0], false) }) + + it("should return false for BCH-only UTXOs", async () => { + // Mock the call to REST API + if (process.env.TEST === "unit") { + // Stub the call to validateTxid + sandbox.stub(slp.Utils, "validateTxid").resolves([null, null]) + } + + const utxos = [ + { + txid: + "a937f792c7c9eb23b4f344ce5c233d1ac0909217d0a504d71e6b1e4efb864a3b", + vout: 0, + amount: 0.00001, + satoshis: 1000, + confirmations: 0, + ts: 1578424704 + }, + { + txid: + "53fd141c2e999e080a5860887441a2c45e9cbe262027e2bd2ac998fc76e43c44", + vout: 0, + amount: 0.00001, + satoshis: 1000, + confirmations: 0, + ts: 1578424634 + } + ] + + const data = await slp.Utils.tokenUtxoDetails(utxos) + // console.log(`data: ${JSON.stringify(data, null, 2)}`) + + assert2.isArray(data) + assert2.equal(false, data[0]) + assert2.equal(false, data[1]) + }) }) describe("#txDetails", () => {