@psf/bch-js 5.3.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psf/bch-js",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "The FullStack.cash JavaScript library for Bitcoin Cash and SLP Tokens",
5
5
  "author": "Chris Troutner <chris.troutner@gmail.com>",
6
6
  "contributors": [
package/src/utxo.js CHANGED
@@ -404,8 +404,18 @@ class UTXO {
404
404
  if (!thisUtxo.isSlp) {
405
405
  thisUtxo.txid = thisUtxo.tx_hash
406
406
  thisUtxo.vout = thisUtxo.tx_pos
407
- thisUtxo.isSlp = false
408
407
  thisUtxo.address = addr
408
+
409
+ // Check the transaction to see if its a 'null' token, ignored by
410
+ // the indexer.
411
+ const txData = await this.psfSlpIndexer.tx(thisUtxo.tx_hash)
412
+ // console.log(`txData: ${JSON.stringify(txData, null, 2)}`)
413
+ if (txData.txData.isValidSlp === null) {
414
+ thisUtxo.isSlp = null
415
+ } else {
416
+ thisUtxo.isSlp = false
417
+ }
418
+ // console.log(`thisUtxo.isSlp: ${thisUtxo.isSlp}`)
409
419
  }
410
420
  }
411
421
 
@@ -438,7 +448,7 @@ class UTXO {
438
448
 
439
449
  return outObj
440
450
  } catch (err) {
441
- // console.error('Error in bchjs.utxo.get2(): ', err)
451
+ console.error('Error in bchjs.Utxo.get(): ', err)
442
452
 
443
453
  if (err.error) throw new Error(err.error)
444
454
  throw err
@@ -5,7 +5,8 @@
5
5
  const assert = require('chai').assert
6
6
 
7
7
  const BCHJS = require('../../../../src/bch-js')
8
- const bchjs = new BCHJS()
8
+ // const bchjs = new BCHJS()
9
+ const bchjs = new BCHJS({ restURL: 'http://192.168.2.129:3000/v5/' })
9
10
 
10
11
  describe('#UTXO', () => {
11
12
  beforeEach(async () => {
@@ -199,7 +200,7 @@ describe('#UTXO', () => {
199
200
 
200
201
  // TODO: NFTs are currently not identified as different than normal BCH UTXOs.
201
202
  // The psf-slp-indexer needs to be updated to fix this issue.
202
- it('should handle NFTs and minting batons', async () => {
203
+ it('should handle minting batons', async () => {
203
204
  const addr = 'simpleledger:qrm0c67wwqh0w7wjxua2gdt2xggnm90xwsr5k22euj'
204
205
 
205
206
  const result = await bchjs.Utxo.get(addr)
@@ -218,6 +219,15 @@ describe('#UTXO', () => {
218
219
  assert.isAbove(result.bchUtxos.length, 0)
219
220
  assert.equal(result.slpUtxos.type1.tokens.length, 0)
220
221
  })
222
+
223
+ it('should handle Group NFTs', async () => {
224
+ const addr = 'bitcoincash:qrnghwrfgccf3s5e9wnglzxegcnhje9rkcwv2eka33'
225
+
226
+ const result = await bchjs.Utxo.get(addr)
227
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
228
+
229
+ assert.isAbove(result.nullUtxos.length, 0)
230
+ })
221
231
  })
222
232
  })
223
233
 
@@ -249,6 +249,10 @@ describe('#utxo', () => {
249
249
  sandbox
250
250
  .stub(bchjs.Utxo.psfSlpIndexer, 'balance')
251
251
  .resolves(mockData.psfSlpIndexerUtxos01)
252
+ sandbox
253
+ .stub(bchjs.Utxo.psfSlpIndexer, 'tx')
254
+ .resolves({ txData: { isValidSlp: false } })
255
+
252
256
  // Mock function to return the same input. Good enough for this test.
253
257
  sandbox.stub(bchjs.Utxo, 'hydrateTokenData').resolves(x => x)
254
258
 
@@ -278,6 +282,9 @@ describe('#utxo', () => {
278
282
  sandbox
279
283
  .stub(bchjs.Utxo.electrumx, 'utxo')
280
284
  .resolves(mockData.fulcrumUtxos02)
285
+ sandbox
286
+ .stub(bchjs.Utxo.psfSlpIndexer, 'tx')
287
+ .resolves({ txData: { isValidSlp: false } })
281
288
 
282
289
  // Force psf-slp-indexer to return no UTXOs
283
290
  sandbox