@psf/bch-js 4.20.17 → 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
package/src/transaction.js
CHANGED
|
@@ -419,6 +419,145 @@ const mintTestOpReturnData03 = {
|
|
|
419
419
|
qty: '234123'
|
|
420
420
|
}
|
|
421
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
|
+
|
|
422
561
|
module.exports = {
|
|
423
562
|
nonSlpTxDetails,
|
|
424
563
|
slpTxDetails,
|
|
@@ -431,5 +570,10 @@ module.exports = {
|
|
|
431
570
|
genesisTestOpReturnData02,
|
|
432
571
|
mintTestOpReturnData01,
|
|
433
572
|
mintTestOpReturnData02,
|
|
434
|
-
mintTestOpReturnData03
|
|
573
|
+
mintTestOpReturnData03,
|
|
574
|
+
sendTestInputTx01,
|
|
575
|
+
sendTestOpReturnData01,
|
|
576
|
+
sendTestOpReturnData02,
|
|
577
|
+
sendTestOpReturnData03,
|
|
578
|
+
sendTestOpReturnData04
|
|
435
579
|
}
|
|
@@ -213,5 +213,56 @@ describe('#TransactionLib', () => {
|
|
|
213
213
|
assert.equal(result.vin[1].tokenQty, 2.34123)
|
|
214
214
|
assert.equal(result.vin[2].tokenQty, null)
|
|
215
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
|
+
})
|
|
216
267
|
})
|
|
217
268
|
})
|