fix(tokenUtxoDetails): porting fix from slp-sdk to Utils.tokenUtxoDetails

This commit is contained in:
Chris Troutner
2020-01-11 12:39:26 -08:00
parent 0089e82b42
commit d735c2f180
2 changed files with 42 additions and 2 deletions
+6 -2
View File
@@ -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
}
+36
View File
@@ -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", () => {