@psf/bch-js 4.20.14 → 4.20.18

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": "4.20.14",
3
+ "version": "4.20.18",
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": [
@@ -76,9 +76,9 @@
76
76
  "eslint-plugin-standard": "^4.0.0",
77
77
  "husky": "^4.3.6",
78
78
  "lodash.clonedeep": "^4.5.0",
79
- "mocha": "^6.1.4",
79
+ "mocha": "^9.1.3",
80
80
  "node-mocks-http": "^1.7.0",
81
- "nyc": "^14.1.0",
81
+ "nyc": "^15.1.0",
82
82
  "prettier": "^1.18.2",
83
83
  "semantic-release": "^17.3.9",
84
84
  "sinon": "^7.3.2",
package/src/address.js CHANGED
@@ -145,7 +145,7 @@ class Address {
145
145
  * // qq50d800hgunr8u4trz3uuppspk3mds0dyug2v69da
146
146
  *
147
147
  */
148
- toEcashAddress (address, prefix = true) {
148
+ toEcashAddress (address, prefix = true) {
149
149
  const decoded = this._decode(address)
150
150
 
151
151
  const ecashAddress = cashaddr.encode(
@@ -173,7 +173,7 @@ class Address {
173
173
  * bchjs.Address.ecashtoCashAddress('ecash:qq50d800hgunr8u4trz3uuppspk3mds0dyug2v69da', false)
174
174
  * // qq50d800hgunr8u4trz3uuppspk3mds0dy9978plt2
175
175
  */
176
- ecashtoCashAddress (address, prefix = true) {
176
+ ecashtoCashAddress (address, prefix = true) {
177
177
  const decoded = this._decodeEcashAddress(address)
178
178
 
179
179
  const cashAddress = cashaddr.encode(
package/src/price.js CHANGED
@@ -128,7 +128,7 @@ class Price {
128
128
  * @apiGroup Price
129
129
  * @apiDescription Return current price of BCHA in USD.
130
130
  * This endpoint gets the USD price of XEC from the Coinex API. The price
131
- * denominated in BCHA comes from bch-api, so it has a better chance of
131
+ * denominated in BCHA comes from bch-api, so it has a better chance of
132
132
  * working in Tor.
133
133
  *
134
134
  * @apiExample Example usage:
@@ -150,7 +150,7 @@ class Price {
150
150
  this.axiosOptions
151
151
  )
152
152
  // console.log(`response.data: ${JSON.stringify(response.data, null, 2)}`)
153
-
153
+
154
154
  const bchaPrice = response.data.usd * 1000000
155
155
  // Convert XEC denomination to BCHA denomination
156
156
 
@@ -161,7 +161,7 @@ class Price {
161
161
  }
162
162
  }
163
163
 
164
- /**
164
+ /**
165
165
  * @api price.getXecUsd() getXecUsd()
166
166
  * @apiName Price getXecUsd()
167
167
  * @apiGroup Price
@@ -179,9 +179,9 @@ class Price {
179
179
  * }
180
180
  *})()
181
181
  *
182
- * // 0.00021234
182
+ * // 0.00021234
183
183
  */
184
- async getXecUsd () {
184
+ async getXecUsd () {
185
185
  try {
186
186
  const response = await this.axios.get(
187
187
  `${this.restURL}price/bchausd`,
@@ -127,11 +127,18 @@ class Transaction {
127
127
  tokenQty = inTokenData.qty
128
128
  // console.log(`tokenQty: ${JSON.stringify(tokenQty, null, 2)}`)
129
129
  }
130
+ } else if (inTokenData.txType === 'MINT') {
131
+ // vout=1 (second output) recieves the newly minted tokens.
132
+ if (thisVin.vout === 1) {
133
+ tokenQty = inTokenData.qty
134
+ } else {
135
+ tokenQty = null
136
+ }
130
137
 
131
138
  //
132
139
  } else {
133
140
  console.log(
134
- 'Unexpected code path in Transaction.get(). Is this a MINT transaction?'
141
+ 'Unexpected code path in Transaction.get(). What is the txType?'
135
142
  )
136
143
  console.log(inTokenData)
137
144
  throw new Error('Unexpected code path')
@@ -266,14 +266,117 @@ const genesisTestInputTx = {
266
266
  blocktime: 1534271330
267
267
  }
268
268
 
269
- genesisTestOpReturnData01 = {
269
+ const mintTestInputTx = {
270
+ txid: '4640a734063ea79fa587a3cac38a70a2f6f3db0011e23514024185982110d0fa',
271
+ hash: '4640a734063ea79fa587a3cac38a70a2f6f3db0011e23514024185982110d0fa',
272
+ version: 1,
273
+ size: 585,
274
+ locktime: 543613,
275
+ vin: [
276
+ {
277
+ txid: '938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8',
278
+ vout: 1,
279
+ scriptSig: {
280
+ asm: '3045022100e3d5f9a48f9aa1cf7e9ed1992e0281e7300b734ba0e4bd5bb9265b2be60bd71002200ccde53ce7ea9da9df3e834f234f3bea65c2e58c96f8436f93333fd8946a1db2[ALL|FORKID] 02056220984cc2cf5261a27d4f66d31c9ef601a688ca1a5ab81e55b6f0d311be74',
281
+ hex: '483045022100e3d5f9a48f9aa1cf7e9ed1992e0281e7300b734ba0e4bd5bb9265b2be60bd71002200ccde53ce7ea9da9df3e834f234f3bea65c2e58c96f8436f93333fd8946a1db2412102056220984cc2cf5261a27d4f66d31c9ef601a688ca1a5ab81e55b6f0d311be74'
282
+ },
283
+ sequence: 4294967294,
284
+ address: 'bitcoincash:qpaf9wltgmpjlg2vxwwu7zdw5y4z7m277ckxn8cufl',
285
+ value: 0.00000546,
286
+ tokenQtyStr: '43545.34534',
287
+ tokenQty: 43545.34534
288
+ },
289
+ {
290
+ txid: 'ee9d3cf5153599c134147e3fac9844c68e216843f4452a1ce15a29452af6db34',
291
+ vout: 1,
292
+ scriptSig: {
293
+ asm: '3045022100bb90d52be9b568f643fdb1a302e9f063be27a9f914e2a6b192cbabf2cbdeaf9302203c275fc8d1b82390bc1726390d361c5266056bddd54dec23efa207c79eacea4a[ALL|FORKID] 024146cfcd0c02e99d6451dc48ad0f97114aeda18fe55c52a10bfc0490f314e6a2',
294
+ hex: '483045022100bb90d52be9b568f643fdb1a302e9f063be27a9f914e2a6b192cbabf2cbdeaf9302203c275fc8d1b82390bc1726390d361c5266056bddd54dec23efa207c79eacea4a4121024146cfcd0c02e99d6451dc48ad0f97114aeda18fe55c52a10bfc0490f314e6a2'
295
+ },
296
+ sequence: 4294967294,
297
+ address: 'bitcoincash:qqf89zzwd0fqc3npkks997r5l7dpfjf9kgx2rqu500',
298
+ value: 0.00000546,
299
+ tokenQtyStr: '2.34123',
300
+ tokenQty: 2.34123
301
+ },
302
+ {
303
+ txid: 'ee9d3cf5153599c134147e3fac9844c68e216843f4452a1ce15a29452af6db34',
304
+ vout: 3,
305
+ scriptSig: {
306
+ asm: '3044022029ab770c249f467b40bb90410429f6d657f9be299baa19a6838d04d972436b450220143660297e8e836bc16d317649fad8c310bdadb4fb61d4e9f6ba11203abe5dae[ALL|FORKID] 02eed4ac9dda3405d9b1ccbbf09f8056f3e7c615924274bd5643238b543d0a1d56',
307
+ hex: '473044022029ab770c249f467b40bb90410429f6d657f9be299baa19a6838d04d972436b450220143660297e8e836bc16d317649fad8c310bdadb4fb61d4e9f6ba11203abe5dae412102eed4ac9dda3405d9b1ccbbf09f8056f3e7c615924274bd5643238b543d0a1d56'
308
+ },
309
+ sequence: 4294967294,
310
+ address: 'bitcoincash:qqt30r33k0jx3sxe34tmupaujpaljnglmvqgrrfp2x',
311
+ value: 0.00054848,
312
+ tokenQtyStr: '2.34123',
313
+ tokenQty: 2.34123
314
+ }
315
+ ],
316
+ vout: [
317
+ {
318
+ value: 0,
319
+ n: 0,
320
+ scriptPubKey: {
321
+ asm: 'OP_RETURN 5262419 1 1145980243 938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8 0000000103907f11',
322
+ hex: '6a04534c500001010453454e4420938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8080000000103907f11',
323
+ type: 'nulldata'
324
+ },
325
+ tokenQty: null
326
+ },
327
+ {
328
+ value: 0.00000546,
329
+ n: 1,
330
+ scriptPubKey: {
331
+ asm: 'OP_DUP OP_HASH160 059775ff94f65c04e8a6847e74eb9809d8cd779b OP_EQUALVERIFY OP_CHECKSIG',
332
+ hex: '76a914059775ff94f65c04e8a6847e74eb9809d8cd779b88ac',
333
+ reqSigs: 1,
334
+ type: 'pubkeyhash',
335
+ addresses: [
336
+ 'bitcoincash:qqzewa0ljnm9cp8g56z8ua8tnqya3nthnvhv5hpu8y'
337
+ ]
338
+ },
339
+ tokenQtyStr: '43547.68657',
340
+ tokenQty: 43547.68657
341
+ },
342
+ {
343
+ value: 0.00054808,
344
+ n: 2,
345
+ scriptPubKey: {
346
+ asm: 'OP_DUP OP_HASH160 0e330dc9009e1e07831f5a22d4ade8977ab674c8 OP_EQUALVERIFY OP_CHECKSIG',
347
+ hex: '76a9140e330dc9009e1e07831f5a22d4ade8977ab674c888ac',
348
+ reqSigs: 1,
349
+ type: 'pubkeyhash',
350
+ addresses: [
351
+ 'bitcoincash:qq8rxrwfqz0pupurradz949dazth4dn5eqs3mhrucv'
352
+ ]
353
+ },
354
+ tokenQty: null
355
+ }
356
+ ],
357
+ hex: '0100000003f8cda53b43b0ea49991a9bc6c74eb901d2a8b964bc7b8987d76789618ec18c93010000006b483045022100e3d5f9a48f9aa1cf7e9ed1992e0281e7300b734ba0e4bd5bb9265b2be60bd71002200ccde53ce7ea9da9df3e834f234f3bea65c2e58c96f8436f93333fd8946a1db2412102056220984cc2cf5261a27d4f66d31c9ef601a688ca1a5ab81e55b6f0d311be74feffffff34dbf62a45295ae11c2a45f44368218ec64498ac3f7e1434c1993515f53c9dee010000006b483045022100bb90d52be9b568f643fdb1a302e9f063be27a9f914e2a6b192cbabf2cbdeaf9302203c275fc8d1b82390bc1726390d361c5266056bddd54dec23efa207c79eacea4a4121024146cfcd0c02e99d6451dc48ad0f97114aeda18fe55c52a10bfc0490f314e6a2feffffff34dbf62a45295ae11c2a45f44368218ec64498ac3f7e1434c1993515f53c9dee030000006a473044022029ab770c249f467b40bb90410429f6d657f9be299baa19a6838d04d972436b450220143660297e8e836bc16d317649fad8c310bdadb4fb61d4e9f6ba11203abe5dae412102eed4ac9dda3405d9b1ccbbf09f8056f3e7c615924274bd5643238b543d0a1d56feffffff030000000000000000376a04534c500001010453454e4420938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8080000000103907f1122020000000000001976a914059775ff94f65c04e8a6847e74eb9809d8cd779b88ac18d60000000000001976a9140e330dc9009e1e07831f5a22d4ade8977ab674c888ac7d4b0800',
358
+ blockhash: '00000000000000000140f0d813052da59c811a936494a8d8b2d60b215d19e3dc',
359
+ confirmations: 167007,
360
+ time: 1534391953,
361
+ blocktime: 1534391953,
362
+ isValidSLPTx: true,
363
+ tokenTxType: 'SEND',
364
+ tokenId: '938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8',
365
+ tokenTicker: 'Bubb2',
366
+ tokenName: 'the new bubbles!',
367
+ tokenDecimals: 5,
368
+ tokenUri: '',
369
+ tokenDocHash: ''
370
+ }
371
+
372
+ const genesisTestOpReturnData01 = {
270
373
  tokenType: 1,
271
374
  txType: 'SEND',
272
375
  tokenId: '323a1e35ae0b356316093d20f2d9fbc995d19314b5c0148b78dc8d9c0dab9d35',
273
376
  amounts: ['5000000', '5000000']
274
377
  }
275
378
 
276
- genesisTestOpReturnData02 = {
379
+ const genesisTestOpReturnData02 = {
277
380
  tokenType: 1,
278
381
  txType: 'GENESIS',
279
382
  ticker: '',
@@ -286,6 +389,175 @@ genesisTestOpReturnData02 = {
286
389
  qty: '10000000'
287
390
  }
288
391
 
392
+ const mintTestOpReturnData01 = {
393
+ tokenType: 1,
394
+ txType: 'SEND',
395
+ tokenId: '938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8',
396
+ amounts: [
397
+ '4354768657'
398
+ ]
399
+ }
400
+
401
+ const mintTestOpReturnData02 = {
402
+ tokenType: 1,
403
+ txType: 'GENESIS',
404
+ ticker: 'Bubb2',
405
+ name: 'the new bubbles!',
406
+ tokenId: '938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8',
407
+ documentUri: '',
408
+ documentHash: '',
409
+ decimals: 5,
410
+ mintBatonVout: 2,
411
+ qty: '4354534534'
412
+ }
413
+
414
+ const mintTestOpReturnData03 = {
415
+ tokenType: 1,
416
+ txType: 'MINT',
417
+ tokenId: '938cc18e618967d787897bbc64b9a8d201b94ec7c69b1a9949eab0433ba5cdf8',
418
+ mintBatonVout: 2,
419
+ qty: '234123'
420
+ }
421
+
422
+ const sendTestInputTx01 = {
423
+ txid: '6bc111fbf5b118021d68355ca19a0e77fa358dd931f284b2550f79a51ab4792a',
424
+ hash: '6bc111fbf5b118021d68355ca19a0e77fa358dd931f284b2550f79a51ab4792a',
425
+ version: 1,
426
+ size: 627,
427
+ locktime: 543956,
428
+ vin: [
429
+ {
430
+ txid: 'b36b0c7485ad569b98cc9b9614dc68a5208495f22ec3b00effcf963b135a5215',
431
+ vout: 1,
432
+ scriptSig: {
433
+ asm: '3045022100934ca9732bf6c1b146f09e6198142a79a80788b576c6b94e2052df5bcdc86ad902205ef6205192200ea93f6c97f966b838ee785529b694eb61e576e3452470613847[ALL|FORKID] 02b23484341cf36ec00184e045d54e6ffca97da7a8f8a6fd719cead192132306b1',
434
+ hex: '483045022100934ca9732bf6c1b146f09e6198142a79a80788b576c6b94e2052df5bcdc86ad902205ef6205192200ea93f6c97f966b838ee785529b694eb61e576e3452470613847412102b23484341cf36ec00184e045d54e6ffca97da7a8f8a6fd719cead192132306b1'
435
+ },
436
+ sequence: 4294967294,
437
+ address: 'bitcoincash:qqxj7p2jatt8h3tcpadyxw8a2mr7myqk2qm57u4rdf',
438
+ value: 0.00000546
439
+ },
440
+ {
441
+ txid: 'b36b0c7485ad569b98cc9b9614dc68a5208495f22ec3b00effcf963b135a5215',
442
+ vout: 3,
443
+ scriptSig: {
444
+ asm: '3044022004d4a95658ef140561ae3a936fb01511778a5376a499bcd6f47b64074a6ca4430220273a4bf553ca17c7e10f393582f980e17a6a98ada867633faad9dbcc595dfd23[ALL|FORKID] 0324fe3b895cfa09523e8ec529eb15c681e3a20f96df85175c54a952b68ac018df',
445
+ hex: '473044022004d4a95658ef140561ae3a936fb01511778a5376a499bcd6f47b64074a6ca4430220273a4bf553ca17c7e10f393582f980e17a6a98ada867633faad9dbcc595dfd2341210324fe3b895cfa09523e8ec529eb15c681e3a20f96df85175c54a952b68ac018df'
446
+ },
447
+ sequence: 4294967294,
448
+ address: 'bitcoincash:qrcdncgpnv3s8lekcamv4yekp8sghnk37qtsxdyzla',
449
+ value: 0.00153976
450
+ },
451
+ {
452
+ txid: '95d460512143b636bbc5780d8b27b04fca3bfd2f22003ab48da594e2bab9cfc1',
453
+ vout: 2,
454
+ scriptSig: {
455
+ asm: '3044022079f239216f8d806a084221e841227e55d23a1b90aaf5b5ab54d6f865fbeacf8b022053568f10afc00459af083e4c77d0b85229eb8973a1de406aaa699557f05c7fed[ALL|FORKID] 02035f98ff79d6f3a8ec5a2738c103bbb7796e94fcaffdfaae8f5b7a7fae5d93e3',
456
+ hex: '473044022079f239216f8d806a084221e841227e55d23a1b90aaf5b5ab54d6f865fbeacf8b022053568f10afc00459af083e4c77d0b85229eb8973a1de406aaa699557f05c7fed412102035f98ff79d6f3a8ec5a2738c103bbb7796e94fcaffdfaae8f5b7a7fae5d93e3'
457
+ },
458
+ sequence: 4294967294,
459
+ address: 'bitcoincash:qrcukahsm53lsywcdarehh73vqazpdu8zv547nym9g',
460
+ value: 0.00000546
461
+ }
462
+ ],
463
+ vout: [
464
+ {
465
+ value: 0,
466
+ n: 0,
467
+ scriptPubKey: {
468
+ asm: 'OP_RETURN 5262419 1 1145980243 550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b35 00005af3107a4000 004657febe8d8000',
469
+ hex: '6a04534c500001010453454e4420550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b350800005af3107a400008004657febe8d8000',
470
+ type: 'nulldata'
471
+ }
472
+ },
473
+ {
474
+ value: 0.00000546,
475
+ n: 1,
476
+ scriptPubKey: {
477
+ asm: 'OP_DUP OP_HASH160 268dadd7c7becc11782ad3d956342442d8eae92a OP_EQUALVERIFY OP_CHECKSIG',
478
+ hex: '76a914268dadd7c7becc11782ad3d956342442d8eae92a88ac',
479
+ reqSigs: 1,
480
+ type: 'pubkeyhash',
481
+ addresses: [
482
+ 'bitcoincash:qqngmtwhc7lvcytc9tfaj435y3pd36hf9gtdq8nsuu'
483
+ ]
484
+ }
485
+ },
486
+ {
487
+ value: 0.00000546,
488
+ n: 2,
489
+ scriptPubKey: {
490
+ asm: 'OP_DUP OP_HASH160 9fb45b370f9ff38a775ee95cabcad7615817924e OP_EQUALVERIFY OP_CHECKSIG',
491
+ hex: '76a9149fb45b370f9ff38a775ee95cabcad7615817924e88ac',
492
+ reqSigs: 1,
493
+ type: 'pubkeyhash',
494
+ addresses: [
495
+ 'bitcoincash:qz0mgkehp70l8znhtm54e2726as4s9ujfc9s2szctr'
496
+ ]
497
+ }
498
+ },
499
+ {
500
+ value: 0.00153347,
501
+ n: 3,
502
+ scriptPubKey: {
503
+ asm: 'OP_DUP OP_HASH160 9fb45b370f9ff38a775ee95cabcad7615817924e OP_EQUALVERIFY OP_CHECKSIG',
504
+ hex: '76a9149fb45b370f9ff38a775ee95cabcad7615817924e88ac',
505
+ reqSigs: 1,
506
+ type: 'pubkeyhash',
507
+ addresses: [
508
+ 'bitcoincash:qz0mgkehp70l8znhtm54e2726as4s9ujfc9s2szctr'
509
+ ]
510
+ }
511
+ }
512
+ ],
513
+ hex: '010000000315525a133b96cfff0eb0c32ef2958420a568dc14969bcc989b56ad85740c6bb3010000006b483045022100934ca9732bf6c1b146f09e6198142a79a80788b576c6b94e2052df5bcdc86ad902205ef6205192200ea93f6c97f966b838ee785529b694eb61e576e3452470613847412102b23484341cf36ec00184e045d54e6ffca97da7a8f8a6fd719cead192132306b1feffffff15525a133b96cfff0eb0c32ef2958420a568dc14969bcc989b56ad85740c6bb3030000006a473044022004d4a95658ef140561ae3a936fb01511778a5376a499bcd6f47b64074a6ca4430220273a4bf553ca17c7e10f393582f980e17a6a98ada867633faad9dbcc595dfd2341210324fe3b895cfa09523e8ec529eb15c681e3a20f96df85175c54a952b68ac018dffeffffffc1cfb9bae294a58db43a00222ffd3bca4fb0278b0d78c5bb36b643215160d495020000006a473044022079f239216f8d806a084221e841227e55d23a1b90aaf5b5ab54d6f865fbeacf8b022053568f10afc00459af083e4c77d0b85229eb8973a1de406aaa699557f05c7fed412102035f98ff79d6f3a8ec5a2738c103bbb7796e94fcaffdfaae8f5b7a7fae5d93e3feffffff040000000000000000406a04534c500001010453454e4420550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b350800005af3107a400008004657febe8d800022020000000000001976a914268dadd7c7becc11782ad3d956342442d8eae92a88ac22020000000000001976a9149fb45b370f9ff38a775ee95cabcad7615817924e88ac03570200000000001976a9149fb45b370f9ff38a775ee95cabcad7615817924e88acd44c0800',
514
+ blockhash: '000000000000000001882548bbd9a41bc53a039634f2afa4a12d653434347d04',
515
+ confirmations: 166670,
516
+ time: 1534593905,
517
+ blocktime: 1534593905
518
+ }
519
+
520
+ const sendTestOpReturnData01 = {
521
+ tokenType: 1,
522
+ txType: 'SEND',
523
+ tokenId: '550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b35',
524
+ amounts: [
525
+ '100000000000000',
526
+ '19800000000000000'
527
+ ]
528
+ }
529
+
530
+ const sendTestOpReturnData02 = {
531
+ tokenType: 1,
532
+ txType: 'GENESIS',
533
+ ticker: 'USDT',
534
+ name: 'Tether Ltd. US dollar backed tokens',
535
+ tokenId: '550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b35',
536
+ documentUri: 'https://tether.to/wp-content/uploads/2016/06/TetherWhitePaper.pdf',
537
+ documentHash: '�DQ�\u001e�3�\u0006p���pM�\u0001\u0017�pW(;\u0003,��wy19\u0016',
538
+ decimals: 8,
539
+ mintBatonVout: 2,
540
+ qty: '10000000000000000'
541
+ }
542
+
543
+ const sendTestOpReturnData03 = {
544
+ tokenType: 1,
545
+ txType: 'MINT',
546
+ tokenId: '550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b35',
547
+ mintBatonVout: 2,
548
+ qty: '10000000000000000'
549
+ }
550
+
551
+ const sendTestOpReturnData04 = {
552
+ tokenType: 1,
553
+ txType: 'SEND',
554
+ tokenId: '550d19eb820e616a54b8a73372c4420b5a0567d8dc00f613b71c5234dc884b35',
555
+ amounts: [
556
+ '100000000000000',
557
+ '9900000000000000'
558
+ ]
559
+ }
560
+
289
561
  module.exports = {
290
562
  nonSlpTxDetails,
291
563
  slpTxDetails,
@@ -293,6 +565,15 @@ module.exports = {
293
565
  mockOpReturnData02,
294
566
  mockOpReturnData03,
295
567
  genesisTestInputTx,
568
+ mintTestInputTx,
296
569
  genesisTestOpReturnData01,
297
- genesisTestOpReturnData02
570
+ genesisTestOpReturnData02,
571
+ mintTestOpReturnData01,
572
+ mintTestOpReturnData02,
573
+ mintTestOpReturnData03,
574
+ sendTestInputTx01,
575
+ sendTestOpReturnData01,
576
+ sendTestOpReturnData02,
577
+ sendTestOpReturnData03,
578
+ sendTestOpReturnData04
298
579
  }
@@ -164,5 +164,105 @@ describe('#TransactionLib', () => {
164
164
  assert.equal(result.vin[0].tokenQty, 10000000)
165
165
  assert.equal(result.vin[1].tokenQty, null)
166
166
  })
167
+
168
+ it('should get input details when input is a mint tx', async () => {
169
+ // Mock dependencies
170
+ sandbox
171
+ .stub(bchjs.Transaction.rawTransaction, 'getTxData')
172
+ .resolves(mockData.mintTestInputTx)
173
+ sandbox
174
+ .stub(bchjs.Transaction.slpUtils, 'decodeOpReturn')
175
+ .onCall(0)
176
+ .resolves(mockData.mintTestOpReturnData01)
177
+ .onCall(1)
178
+ .resolves(mockData.mintTestOpReturnData02)
179
+ .onCall(2)
180
+ .resolves(mockData.mintTestOpReturnData02)
181
+ .onCall(3)
182
+ .resolves(mockData.mintTestOpReturnData03)
183
+ .onCall(4)
184
+ .resolves(mockData.mintTestOpReturnData03)
185
+ sandbox
186
+ .stub(bchjs.Transaction.slpUtils, 'waterfallValidateTxid')
187
+ .resolves(true)
188
+
189
+ const txid =
190
+ '4640a734063ea79fa587a3cac38a70a2f6f3db0011e23514024185982110d0fa'
191
+
192
+ const result = await bchjs.Transaction.get(txid)
193
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
194
+
195
+ // Assert that there are stanardized properties.
196
+ assert.property(result, 'txid')
197
+ assert.property(result, 'vin')
198
+ assert.property(result, 'vout')
199
+ assert.property(result.vout[0], 'value')
200
+ assert.property(result.vout[1].scriptPubKey, 'addresses')
201
+
202
+ // Assert that added properties exist.
203
+ assert.property(result.vout[0], 'tokenQty')
204
+ assert.equal(result.vout[0].tokenQty, null)
205
+ assert.property(result.vin[0], 'address')
206
+ assert.property(result.vin[0], 'value')
207
+ assert.property(result.vin[0], 'tokenQty')
208
+ assert.property(result, 'isValidSLPTx')
209
+ assert.equal(result.isValidSLPTx, true)
210
+
211
+ // Assert inputs values unique to a Mint input have the proper values.
212
+ assert.equal(result.vin[0].tokenQty, 43545.34534)
213
+ assert.equal(result.vin[1].tokenQty, 2.34123)
214
+ assert.equal(result.vin[2].tokenQty, null)
215
+ })
216
+
217
+ // This test case was generated from the problematic transaction that
218
+ // used inputs in a 'non-standard' way.
219
+ it('should correctly assign quantities to mixed mint inputs', async () => {
220
+ // Mock dependencies
221
+ sandbox
222
+ .stub(bchjs.Transaction.rawTransaction, 'getTxData')
223
+ .resolves(mockData.sendTestInputTx01)
224
+ sandbox
225
+ .stub(bchjs.Transaction.slpUtils, 'decodeOpReturn')
226
+ .onCall(0)
227
+ .resolves(mockData.sendTestOpReturnData01)
228
+ .onCall(1)
229
+ .resolves(mockData.sendTestOpReturnData02)
230
+ .onCall(2)
231
+ .resolves(mockData.sendTestOpReturnData03)
232
+ .onCall(3)
233
+ .resolves(mockData.sendTestOpReturnData03)
234
+ .onCall(4)
235
+ .resolves(mockData.sendTestOpReturnData04)
236
+ sandbox
237
+ .stub(bchjs.Transaction.slpUtils, 'waterfallValidateTxid')
238
+ .resolves(true)
239
+
240
+ const txid =
241
+ '6bc111fbf5b118021d68355ca19a0e77fa358dd931f284b2550f79a51ab4792a'
242
+
243
+ const result = await bchjs.Transaction.get(txid)
244
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
245
+
246
+ // Assert that there are stanardized properties.
247
+ assert.property(result, 'txid')
248
+ assert.property(result, 'vin')
249
+ assert.property(result, 'vout')
250
+ assert.property(result.vout[0], 'value')
251
+ assert.property(result.vout[1].scriptPubKey, 'addresses')
252
+
253
+ // Assert that added properties exist.
254
+ assert.property(result.vout[0], 'tokenQty')
255
+ assert.equal(result.vout[0].tokenQty, null)
256
+ assert.property(result.vin[0], 'address')
257
+ assert.property(result.vin[0], 'value')
258
+ assert.property(result.vin[0], 'tokenQty')
259
+ assert.property(result, 'isValidSLPTx')
260
+ assert.equal(result.isValidSLPTx, true)
261
+
262
+ // Assert inputs values unique to a Mint input have the proper values.
263
+ assert.equal(result.vin[0].tokenQty, 100000000)
264
+ assert.equal(result.vin[1].tokenQty, null)
265
+ assert.equal(result.vin[2].tokenQty, 99000000)
266
+ })
167
267
  })
168
268
  })