@psf/bch-js 4.21.0 → 5.2.0

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.
@@ -11,71 +11,74 @@ describe('#Transaction', () => {
11
11
  if (process.env.IS_USING_FREE_TIER) await bchjs.Util.sleep(1000)
12
12
  })
13
13
 
14
- describe('#get', () => {
15
- it('should get details about a non-SLP transaction', async () => {
16
- const txid =
17
- '2b37bdb3b63dd0bca720437754a36671431a950e684b64c44ea910ea9d5297c7'
14
+ if (process.env.TESTSLP) {
15
+ describe('#getOld', () => {
16
+ it('should get details about a non-SLP transaction', async () => {
17
+ const txid =
18
+ '2b37bdb3b63dd0bca720437754a36671431a950e684b64c44ea910ea9d5297c7'
18
19
 
19
- const result = await bchjs.Transaction.get(txid)
20
- // console.log(`result: ${JSON.stringify(result, null, 2)}`)
20
+ const result = await bchjs.Transaction.getOld(txid)
21
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
21
22
 
22
- // Assert that there are stanardized properties.
23
- assert.property(result, 'txid')
24
- assert.property(result, 'vin')
25
- assert.property(result, 'vout')
26
- assert.property(result.vout[0], 'value')
27
- assert.property(result.vout[0].scriptPubKey, 'addresses')
23
+ // Assert that there are stanardized properties.
24
+ assert.property(result, 'txid')
25
+ assert.property(result, 'vin')
26
+ assert.property(result, 'vout')
27
+ assert.property(result.vout[0], 'value')
28
+ assert.property(result.vout[0].scriptPubKey, 'addresses')
28
29
 
29
- // Assert that added properties exist.
30
- assert.property(result.vin[0], 'address')
31
- assert.property(result.vin[0], 'value')
32
- assert.property(result, 'isValidSLPTx')
33
- assert.equal(result.isValidSLPTx, false)
34
- })
30
+ // Assert that added properties exist.
31
+ assert.property(result.vin[0], 'address')
32
+ assert.property(result.vin[0], 'value')
33
+ assert.property(result, 'isValidSLPTx')
34
+ assert.equal(result.isValidSLPTx, false)
35
+ })
35
36
 
36
- it('should get details about a SLP transaction', async () => {
37
- const txid =
38
- '266844d53e46bbd7dd37134688dffea6e54d944edff27a0add63dd0908839bc1'
37
+ it('should get details about a SLP transaction', async () => {
38
+ const txid =
39
+ '266844d53e46bbd7dd37134688dffea6e54d944edff27a0add63dd0908839bc1'
39
40
 
40
- const result = await bchjs.Transaction.get(txid)
41
- // console.log(`result: ${JSON.stringify(result, null, 2)}`)
41
+ const result = await bchjs.Transaction.getOld(txid)
42
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
42
43
 
43
- // Assert that there are stanardized properties.
44
- assert.property(result, 'txid')
45
- assert.property(result, 'vin')
46
- assert.property(result, 'vout')
47
- assert.property(result.vout[0], 'value')
48
- assert.property(result.vout[1].scriptPubKey, 'addresses')
44
+ // Assert that there are stanardized properties.
45
+ assert.property(result, 'txid')
46
+ assert.property(result, 'vin')
47
+ assert.property(result, 'vout')
48
+ assert.property(result.vout[0], 'value')
49
+ assert.property(result.vout[1].scriptPubKey, 'addresses')
49
50
 
50
- // Assert that added properties exist.
51
- assert.property(result.vout[0], 'tokenQty')
52
- assert.equal(result.vout[0].tokenQty, null)
53
- assert.property(result.vin[0], 'address')
54
- assert.property(result.vin[0], 'value')
55
- assert.property(result.vin[0], 'tokenQty')
56
- assert.property(result, 'isValidSLPTx')
57
- assert.equal(result.isValidSLPTx, true)
58
- })
51
+ // Assert that added properties exist.
52
+ assert.property(result.vout[0], 'tokenQty')
53
+ assert.equal(result.vout[0].tokenQty, null)
54
+ assert.property(result.vin[0], 'address')
55
+ assert.property(result.vin[0], 'value')
56
+ assert.property(result.vin[0], 'tokenQty')
57
+ assert.property(result, 'isValidSLPTx')
58
+ assert.equal(result.isValidSLPTx, true)
59
+ })
59
60
 
60
- // it('should get problematic transaction', async () => {
61
- // const txid = 'a55515de32577e296c512840bcaabed5823bb773fb4f8fd8e5197cc96cbc54d1'
62
- //
63
- // const result = await bchjs.Transaction.get(txid)
64
- // console.log(`result: ${JSON.stringify(result, null, 2)}`)
65
- // })
61
+ // it('should get problematic transaction', async () => {
62
+ // const txid = 'a55515de32577e296c512840bcaabed5823bb773fb4f8fd8e5197cc96cbc54d1'
63
+ //
64
+ // const result = await bchjs.Transaction.get(txid)
65
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
66
+ // })
66
67
 
67
- // TX a19f2f395a8b0e15b6202944c56834367d128f1e3630486a4756de53424a46fe has
68
- // an input TXID (bd84bc1dd5ecd976165892306992401272f6bedeb37d7b2cdbf74fc4a55967a6)
69
- // that is also a valid SLP tx, but is unrelated. Both TXs pass DAG validation,
70
- // but for separate tokens.
71
- it('should get problematic transaction', async () => {
72
- const txid = 'a19f2f395a8b0e15b6202944c56834367d128f1e3630486a4756de53424a46fe'
68
+ // TX a19f2f395a8b0e15b6202944c56834367d128f1e3630486a4756de53424a46fe has
69
+ // an input TXID (bd84bc1dd5ecd976165892306992401272f6bedeb37d7b2cdbf74fc4a55967a6)
70
+ // that is also a valid SLP tx, but is unrelated. Both TXs pass DAG validation,
71
+ // but for separate tokens.
72
+ it('should get problematic transaction', async () => {
73
+ const txid =
74
+ 'a19f2f395a8b0e15b6202944c56834367d128f1e3630486a4756de53424a46fe'
73
75
 
74
- const result = await bchjs.Transaction.get(txid)
75
- // console.log(`result: ${JSON.stringify(result, null, 2)}`)
76
+ const result = await bchjs.Transaction.getOld(txid)
77
+ // console.log(`result: ${JSON.stringify(result, null, 2)}`)
76
78
 
77
- // The token ID should equal the txid for this Vin.
78
- assert.equal(result.vin[2].txid, result.vin[2].tokenId)
79
+ // The token ID should equal the txid for this Vin.
80
+ assert.equal(result.vin[2].txid, result.vin[2].tokenId)
81
+ })
79
82
  })
80
- })
83
+ }
81
84
  })
@@ -0,0 +1,153 @@
1
+ /*
2
+ Mocking data for unit tests for the PSF SLP INDEXER library.
3
+ */
4
+
5
+ 'use strict'
6
+
7
+ const tokenStats = {
8
+ tokenData: {
9
+ type: 1,
10
+ ticker: 'TP03',
11
+ name: 'Test Plugin 03',
12
+ tokenId: '13cad617d523c8eb4ab11fff19c010e0e0a4ea4360b58e0c8c955a45a146a669',
13
+ documentUri: 'fullstack.cash',
14
+ documentHash: '',
15
+ decimals: 0,
16
+ mintBatonIsActive: false,
17
+ tokensInCirculationBN: '1',
18
+ tokensInCirculationStr: '1',
19
+ blockCreated: 722420,
20
+ totalBurned: '0',
21
+ totalMinted: '1',
22
+ txs: [
23
+ {
24
+ txid:
25
+ '13cad617d523c8eb4ab11fff19c010e0e0a4ea4360b58e0c8c955a45a146a669',
26
+ height: 722420,
27
+ type: 'GENESIS',
28
+ qty: '1'
29
+ }
30
+ ]
31
+ }
32
+ }
33
+
34
+ const txData = {
35
+ txData: {
36
+ txid: 'a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2',
37
+ hash: 'a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2',
38
+ version: 2,
39
+ size: 339,
40
+ locktime: 0,
41
+ vin: [
42
+ {
43
+ txid:
44
+ '8370db30d94761ab9a11b71ecd22541151bf6125c8c613f0f6fab8ab794565a7',
45
+ vout: 0,
46
+ scriptSig: {
47
+ asm:
48
+ '304402207e9631c53dfc8a9a793d1916469628c6b7c5780c01c2f676d51ef21b0ba4926f022069feb471ec869a49f8d108d0aaba04e7cd36e60a7500109d86537f55698930d4[ALL|FORKID] 02791b19a39165dbd83403d6df268d44fd621da30581b0b6e5cb15a7101ed58851',
49
+ hex:
50
+ '47304402207e9631c53dfc8a9a793d1916469628c6b7c5780c01c2f676d51ef21b0ba4926f022069feb471ec869a49f8d108d0aaba04e7cd36e60a7500109d86537f55698930d4412102791b19a39165dbd83403d6df268d44fd621da30581b0b6e5cb15a7101ed58851'
51
+ },
52
+ sequence: 4294967295,
53
+ address: 'bitcoincash:qpvsg9vl9a5mlf37a7n3yce6pktdctn73qwgaqm3wq',
54
+ value: 0.00051303,
55
+ tokenQty: 0,
56
+ tokenQtyStr: '0',
57
+ tokenId: null
58
+ }
59
+ ],
60
+ vout: [
61
+ {
62
+ value: 0,
63
+ n: 0,
64
+ scriptPubKey: {
65
+ asm:
66
+ 'OP_RETURN 5262419 1 47454e45534953 54524f5554 54726f75742773207465737420746f6b656e 74726f757473626c6f672e636f6d 0 2 2 000000174876e800',
67
+ hex:
68
+ '6a04534c500001010747454e455349530554524f55541254726f75742773207465737420746f6b656e0e74726f757473626c6f672e636f6d4c000102010208000000174876e800',
69
+ type: 'nulldata'
70
+ },
71
+ tokenQtyStr: '0',
72
+ tokenQty: 0
73
+ }
74
+ ],
75
+ hex:
76
+ '0200000001a7654579abb8faf6f013c6c82561bf51115422cd1eb7119aab6147d930db7083000000006a47304402207e9631c53dfc8a9a793d1916469628c6b7c5780c01c2f676d51ef21b0ba4926f022069feb471ec869a49f8d108d0aaba04e7cd36e60a7500109d86537f55698930d4412102791b19a39165dbd83403d6df268d44fd621da30581b0b6e5cb15a7101ed58851ffffffff040000000000000000476a04534c500001010747454e455349530554524f55541254726f75742773207465737420746f6b656e0e74726f757473626c6f672e636f6d4c000102010208000000174876e80022020000000000001976a914db4d39ceb7794ffe5d06855f249e1d3a7f1b024088ac22020000000000001976a914db4d39ceb7794ffe5d06855f249e1d3a7f1b024088accec20000000000001976a9145904159f2f69bfa63eefa712633a0d96dc2e7e8888ac00000000',
77
+ blockhash:
78
+ '0000000000000000009f65225a3e12e23a7ea057c869047e0f36563a1f410267',
79
+ confirmations: 97398,
80
+ time: 1581773131,
81
+ blocktime: 1581773131,
82
+ blockheight: 622414,
83
+ isSlpTx: true,
84
+ tokenTxType: 'GENESIS',
85
+ tokenId: 'a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2',
86
+ tokenType: 1,
87
+ tokenTicker: 'TROUT',
88
+ tokenName: "Trout's test token",
89
+ tokenDecimals: 2,
90
+ tokenUri: 'troutsblog.com',
91
+ tokenDocHash: '',
92
+ isValidSlp: true
93
+ }
94
+ }
95
+ const balance = {
96
+ balance: {
97
+ utxos: [
98
+ {
99
+ txid:
100
+ 'a24a6a4abf06fabd799ecea4f8fac6a9ff21e6a8dd6169a3c2ebc03665329db9',
101
+ vout: 1,
102
+ type: 'token',
103
+ qty: '1800',
104
+ tokenId:
105
+ 'a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2',
106
+ address: 'bitcoincash:qrqy3kj7r822ps6628vwqq5k8hyjl6ey3y4eea2m4s'
107
+ }
108
+ ],
109
+ txs: [
110
+ {
111
+ txid:
112
+ '078b2c48ed1db0d5d5996f2889b8d847a49200d0a781f6aa6752f740f312688f',
113
+ height: 717796
114
+ },
115
+ {
116
+ txid:
117
+ 'a24a6a4abf06fabd799ecea4f8fac6a9ff21e6a8dd6169a3c2ebc03665329db9',
118
+ height: 717832
119
+ }
120
+ ],
121
+ balances: [
122
+ {
123
+ tokenId:
124
+ 'a4fb5c2da1aa064e25018a43f9165040071d9e984ba190c222a7f59053af84b2',
125
+ qty: '1800'
126
+ }
127
+ ]
128
+ }
129
+ }
130
+
131
+ const status = {
132
+ status: {
133
+ startBlockHeight: 543376,
134
+ syncedBlockHeight: 722860,
135
+ chainBlockHeight: 722679
136
+ }
137
+ }
138
+
139
+ const tokenData01 = {
140
+ tokenType: 1,
141
+ txType: 'MINT',
142
+ tokenId: 'dd21be4532d93661e8ffe16db6535af0fb8ee1344d1fef81a193e2b4cfa9fbc9',
143
+ mintBatonVout: 2,
144
+ qty: {}
145
+ }
146
+
147
+ module.exports = {
148
+ tokenStats,
149
+ txData,
150
+ balance,
151
+ status,
152
+ tokenData01
153
+ }
@@ -280,10 +280,100 @@ const electrumxUtxos = {
280
280
  ]
281
281
  }
282
282
 
283
+ const fulcrumUtxos01 = {
284
+ success: true,
285
+ utxos: [
286
+ {
287
+ height: 674512,
288
+ tx_hash:
289
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
290
+ tx_pos: 1,
291
+ value: 546
292
+ },
293
+ {
294
+ height: 674512,
295
+ tx_hash:
296
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
297
+ tx_pos: 2,
298
+ value: 546
299
+ },
300
+ {
301
+ height: 674512,
302
+ tx_hash:
303
+ 'eeddccc4d716f04157ea132ac93a48040fea34a6b57f3d8f0cccb7d1a731ab2b',
304
+ tx_pos: 1,
305
+ value: 546
306
+ },
307
+ {
308
+ height: 674513,
309
+ tx_hash:
310
+ '705bcc442e5a2770e560b528f52a47b1dcc9ce9ab6a8de9dfdefa55177f00d04',
311
+ tx_pos: 1,
312
+ value: 546
313
+ },
314
+ {
315
+ height: 674513,
316
+ tx_hash:
317
+ '705bcc442e5a2770e560b528f52a47b1dcc9ce9ab6a8de9dfdefa55177f00d04',
318
+ tx_pos: 2,
319
+ value: 546
320
+ },
321
+ {
322
+ height: 674513,
323
+ tx_hash:
324
+ '705bcc442e5a2770e560b528f52a47b1dcc9ce9ab6a8de9dfdefa55177f00d04',
325
+ tx_pos: 3,
326
+ value: 38134
327
+ }
328
+ ]
329
+ }
330
+
331
+ const psfSlpIndexerUtxos01 = {
332
+ balance: {
333
+ utxos: [
334
+ {
335
+ txid:
336
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
337
+ vout: 1,
338
+ type: 'token',
339
+ qty: '10000000000',
340
+ tokenId:
341
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
342
+ address: 'bitcoincash:qrm0c67wwqh0w7wjxua2gdt2xggnm90xws00a3lezv'
343
+ },
344
+ {
345
+ txid:
346
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
347
+ vout: 2,
348
+ type: 'baton',
349
+ tokenId:
350
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
351
+ address: 'bitcoincash:qrm0c67wwqh0w7wjxua2gdt2xggnm90xws00a3lezv'
352
+ }
353
+ ],
354
+ txs: [
355
+ {
356
+ txid:
357
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
358
+ height: 674512
359
+ }
360
+ ],
361
+ balances: [
362
+ {
363
+ tokenId:
364
+ 'acbb0d3ceef55aa3e5fafc19335ae4bf2f8edba3c0567547dfd402391db32230',
365
+ qty: '10000000000'
366
+ }
367
+ ]
368
+ }
369
+ }
370
+
283
371
  module.exports = {
284
372
  mockUtxoData,
285
373
  mockHydratedUtxos,
286
374
  mockTwoHydratedAddrs,
287
375
  mockEveryUtxoType,
288
- electrumxUtxos
376
+ electrumxUtxos,
377
+ fulcrumUtxos01,
378
+ psfSlpIndexerUtxos01
289
379
  }