@xchainjs/xchain-utxo 2.0.0 → 2.0.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/lib/coininfo.d.ts +12 -0
- package/lib/coins/bch.d.ts +70 -0
- package/lib/coins/dash.d.ts +42 -0
- package/lib/coins/doge.d.ts +43 -0
- package/lib/coins/ltc.d.ts +42 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.esm.js +287 -1
- package/lib/index.js +287 -0
- package/package.json +5 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function toBitcoinJS(chain: 'bitcoincash' | 'dogecoin' | 'dash' | 'litecoin', network: 'main' | 'test'): {
|
|
2
|
+
messagePrefix: string;
|
|
3
|
+
bech32: string | undefined;
|
|
4
|
+
bip32: {
|
|
5
|
+
public: number;
|
|
6
|
+
private: number;
|
|
7
|
+
};
|
|
8
|
+
pubKeyHash: number;
|
|
9
|
+
scriptHash: number;
|
|
10
|
+
wif: number;
|
|
11
|
+
dustThreshold: null;
|
|
12
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
declare const main: {
|
|
2
|
+
hashGenesisBlock: string;
|
|
3
|
+
port: number;
|
|
4
|
+
portRpc: number;
|
|
5
|
+
protocol: {
|
|
6
|
+
magic: number;
|
|
7
|
+
};
|
|
8
|
+
seedsDns: string[];
|
|
9
|
+
versions: {
|
|
10
|
+
bip32: {
|
|
11
|
+
private: number;
|
|
12
|
+
public: number;
|
|
13
|
+
};
|
|
14
|
+
bip44: number;
|
|
15
|
+
private: number;
|
|
16
|
+
public: number;
|
|
17
|
+
scripthash: number;
|
|
18
|
+
};
|
|
19
|
+
} & {
|
|
20
|
+
name: string;
|
|
21
|
+
per1: number;
|
|
22
|
+
unit: string;
|
|
23
|
+
};
|
|
24
|
+
declare const test: {
|
|
25
|
+
hashGenesisBlock: string;
|
|
26
|
+
port: number;
|
|
27
|
+
portRpc: number;
|
|
28
|
+
protocol: {
|
|
29
|
+
magic: number;
|
|
30
|
+
};
|
|
31
|
+
seedsDns: string[];
|
|
32
|
+
versions: {
|
|
33
|
+
bip32: {
|
|
34
|
+
private: number;
|
|
35
|
+
public: number;
|
|
36
|
+
};
|
|
37
|
+
bip44: number;
|
|
38
|
+
private: number;
|
|
39
|
+
public: number;
|
|
40
|
+
scripthash: number;
|
|
41
|
+
};
|
|
42
|
+
} & {
|
|
43
|
+
name: string;
|
|
44
|
+
per1: number;
|
|
45
|
+
unit: string;
|
|
46
|
+
};
|
|
47
|
+
declare const regtest: {
|
|
48
|
+
hashGenesisBlock: string;
|
|
49
|
+
port: number;
|
|
50
|
+
portRpc: number;
|
|
51
|
+
protocol: {
|
|
52
|
+
magic: number;
|
|
53
|
+
};
|
|
54
|
+
seedsDns: never[];
|
|
55
|
+
versions: {
|
|
56
|
+
bip32: {
|
|
57
|
+
private: number;
|
|
58
|
+
public: number;
|
|
59
|
+
};
|
|
60
|
+
bip44: number;
|
|
61
|
+
private: number;
|
|
62
|
+
public: number;
|
|
63
|
+
scripthash: number;
|
|
64
|
+
};
|
|
65
|
+
} & {
|
|
66
|
+
name: string;
|
|
67
|
+
per1: number;
|
|
68
|
+
unit: string;
|
|
69
|
+
};
|
|
70
|
+
export { main, test, regtest };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare const main: {
|
|
2
|
+
hashGenesisBlock: string;
|
|
3
|
+
port: number;
|
|
4
|
+
portRpc: number;
|
|
5
|
+
protocol: {
|
|
6
|
+
magic: number;
|
|
7
|
+
};
|
|
8
|
+
seedsDns: string[];
|
|
9
|
+
versions: {
|
|
10
|
+
bip32: {
|
|
11
|
+
private: number;
|
|
12
|
+
public: number;
|
|
13
|
+
};
|
|
14
|
+
bip44: number;
|
|
15
|
+
private: number;
|
|
16
|
+
public: number;
|
|
17
|
+
scripthash: number;
|
|
18
|
+
};
|
|
19
|
+
} & {
|
|
20
|
+
name: string;
|
|
21
|
+
unit: string;
|
|
22
|
+
};
|
|
23
|
+
declare const test: {
|
|
24
|
+
hashGenesisBlock: string;
|
|
25
|
+
port: number;
|
|
26
|
+
portRpc: number;
|
|
27
|
+
seedsDns: string[];
|
|
28
|
+
versions: {
|
|
29
|
+
bip32: {
|
|
30
|
+
private: number;
|
|
31
|
+
public: number;
|
|
32
|
+
};
|
|
33
|
+
bip44: number;
|
|
34
|
+
private: number;
|
|
35
|
+
public: number;
|
|
36
|
+
scripthash: number;
|
|
37
|
+
};
|
|
38
|
+
} & {
|
|
39
|
+
name: string;
|
|
40
|
+
unit: string;
|
|
41
|
+
};
|
|
42
|
+
export { main, test };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const main: {
|
|
2
|
+
hashGenesisBlock: string;
|
|
3
|
+
port: number;
|
|
4
|
+
protocol: {
|
|
5
|
+
magic: number;
|
|
6
|
+
};
|
|
7
|
+
seedsDns: string[];
|
|
8
|
+
versions: {
|
|
9
|
+
bip32: {
|
|
10
|
+
private: number;
|
|
11
|
+
public: number;
|
|
12
|
+
};
|
|
13
|
+
bip44: number;
|
|
14
|
+
private: number;
|
|
15
|
+
public: number;
|
|
16
|
+
scripthash: number;
|
|
17
|
+
};
|
|
18
|
+
} & {
|
|
19
|
+
name: string;
|
|
20
|
+
unit: string;
|
|
21
|
+
};
|
|
22
|
+
declare const test: {
|
|
23
|
+
hashGenesisBlock: string;
|
|
24
|
+
port: number;
|
|
25
|
+
protocol: {
|
|
26
|
+
magic: number;
|
|
27
|
+
};
|
|
28
|
+
seedsDns: string[];
|
|
29
|
+
versions: {
|
|
30
|
+
bip32: {
|
|
31
|
+
private: number;
|
|
32
|
+
public: number;
|
|
33
|
+
};
|
|
34
|
+
bip44: number;
|
|
35
|
+
private: number;
|
|
36
|
+
public: number;
|
|
37
|
+
scripthash: number;
|
|
38
|
+
};
|
|
39
|
+
} & {
|
|
40
|
+
name: string;
|
|
41
|
+
unit: string;
|
|
42
|
+
};
|
|
43
|
+
export { main, test };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare const main: {
|
|
2
|
+
hashGenesisBlock: string;
|
|
3
|
+
port: number;
|
|
4
|
+
protocol: {
|
|
5
|
+
magic: number;
|
|
6
|
+
};
|
|
7
|
+
bech32: string;
|
|
8
|
+
seedsDns: string[];
|
|
9
|
+
versions: {
|
|
10
|
+
bip32: {
|
|
11
|
+
private: number;
|
|
12
|
+
public: number;
|
|
13
|
+
};
|
|
14
|
+
bip44: number;
|
|
15
|
+
private: number;
|
|
16
|
+
public: number;
|
|
17
|
+
scripthash: number;
|
|
18
|
+
scripthash2: number;
|
|
19
|
+
};
|
|
20
|
+
} & {
|
|
21
|
+
name: string;
|
|
22
|
+
unit: string;
|
|
23
|
+
};
|
|
24
|
+
declare const test: {
|
|
25
|
+
hashGenesisBlock: string;
|
|
26
|
+
bech32: string;
|
|
27
|
+
versions: {
|
|
28
|
+
bip32: {
|
|
29
|
+
private: number;
|
|
30
|
+
public: number;
|
|
31
|
+
};
|
|
32
|
+
bip44: number;
|
|
33
|
+
private: number;
|
|
34
|
+
public: number;
|
|
35
|
+
scripthash: number;
|
|
36
|
+
scripthash2: number;
|
|
37
|
+
};
|
|
38
|
+
} & {
|
|
39
|
+
name: string;
|
|
40
|
+
unit: string;
|
|
41
|
+
};
|
|
42
|
+
export { main, test };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
|
+
import { toBitcoinJS } from './coininfo';
|
|
2
3
|
import { Balance, PreparedTx, Tx, TxFrom, TxParams, TxTo, TxsPage, UTXO, UtxoClientParams, Witness } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* Exported symbols from the `Client`, `UTXO`, `UtxoClientParams`, `Witness`, and `PreparedTx` modules.
|
|
5
6
|
*/
|
|
6
|
-
export { Client, UTXO, UtxoClientParams, Witness, PreparedTx, Balance, Tx, TxsPage, TxParams, TxTo, TxFrom };
|
|
7
|
+
export { Client, UTXO, UtxoClientParams, Witness, PreparedTx, Balance, Tx, TxsPage, TxParams, TxTo, TxFrom, toBitcoinJS, };
|
package/lib/index.esm.js
CHANGED
|
@@ -352,4 +352,290 @@ class Client extends BaseXChainClient {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
/*
|
|
356
|
+
info from:
|
|
357
|
+
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/chainparams.cpp
|
|
358
|
+
*/
|
|
359
|
+
const common$3 = {
|
|
360
|
+
name: 'BitcoinCash',
|
|
361
|
+
per1: 1e8,
|
|
362
|
+
unit: 'BCH',
|
|
363
|
+
};
|
|
364
|
+
const main$3 = Object.assign({}, {
|
|
365
|
+
hashGenesisBlock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
|
|
366
|
+
// nDefaultPort
|
|
367
|
+
port: 8333,
|
|
368
|
+
portRpc: 8332,
|
|
369
|
+
protocol: {
|
|
370
|
+
// pchMessageStart
|
|
371
|
+
magic: 0xe8f3e1e3, // careful, sent over wire as little endian
|
|
372
|
+
},
|
|
373
|
+
// vSeeds
|
|
374
|
+
seedsDns: [
|
|
375
|
+
'seed.bitcoinabc.org',
|
|
376
|
+
'seed-abc.bitcoinforks.org',
|
|
377
|
+
'btccash-seeder.bitcoinunlimited.info',
|
|
378
|
+
'seed.bitprim.org',
|
|
379
|
+
'seed.deadalnix.me',
|
|
380
|
+
'seeder.criptolayer.net',
|
|
381
|
+
],
|
|
382
|
+
// base58Prefixes
|
|
383
|
+
versions: {
|
|
384
|
+
bip32: {
|
|
385
|
+
private: 0x0488ade4,
|
|
386
|
+
public: 0x0488b21e,
|
|
387
|
+
},
|
|
388
|
+
bip44: 145,
|
|
389
|
+
private: 0x80,
|
|
390
|
+
public: 0x00,
|
|
391
|
+
scripthash: 0x05,
|
|
392
|
+
},
|
|
393
|
+
}, common$3);
|
|
394
|
+
const test$3 = Object.assign({}, {
|
|
395
|
+
hashGenesisBlock: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943',
|
|
396
|
+
port: 18333,
|
|
397
|
+
portRpc: 18332,
|
|
398
|
+
protocol: {
|
|
399
|
+
magic: 0xf4f3e5f4,
|
|
400
|
+
},
|
|
401
|
+
seedsDns: [
|
|
402
|
+
'testnet-seed.bitcoinabc.org',
|
|
403
|
+
'testnet-seed-abc.bitcoinforks.org',
|
|
404
|
+
'testnet-seed.bitprim.org',
|
|
405
|
+
'testnet-seed.deadalnix.me',
|
|
406
|
+
'testnet-seeder.criptolayer.net',
|
|
407
|
+
],
|
|
408
|
+
versions: {
|
|
409
|
+
bip32: {
|
|
410
|
+
private: 0x04358394,
|
|
411
|
+
public: 0x043587cf,
|
|
412
|
+
},
|
|
413
|
+
bip44: 1,
|
|
414
|
+
private: 0xef,
|
|
415
|
+
public: 0x6f,
|
|
416
|
+
scripthash: 0xc4,
|
|
417
|
+
},
|
|
418
|
+
}, common$3);
|
|
419
|
+
const regtest = Object.assign({}, {
|
|
420
|
+
hashGenesisBlock: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206',
|
|
421
|
+
port: 18444,
|
|
422
|
+
portRpc: 18332,
|
|
423
|
+
protocol: {
|
|
424
|
+
magic: 0xfabfb5da,
|
|
425
|
+
},
|
|
426
|
+
seedsDns: [],
|
|
427
|
+
versions: {
|
|
428
|
+
bip32: {
|
|
429
|
+
private: 0x04358394,
|
|
430
|
+
public: 0x043587cf,
|
|
431
|
+
},
|
|
432
|
+
bip44: 1,
|
|
433
|
+
private: 0xef,
|
|
434
|
+
public: 0x6f,
|
|
435
|
+
scripthash: 0xc4,
|
|
436
|
+
},
|
|
437
|
+
}, common$3);
|
|
438
|
+
|
|
439
|
+
var bchData = /*#__PURE__*/Object.freeze({
|
|
440
|
+
__proto__: null,
|
|
441
|
+
main: main$3,
|
|
442
|
+
regtest: regtest,
|
|
443
|
+
test: test$3
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
/*
|
|
447
|
+
info from:
|
|
448
|
+
https://github.com/dashpay/dash/blob/master/src/chainparams.cpp
|
|
449
|
+
*/
|
|
450
|
+
const common$2 = {
|
|
451
|
+
name: 'Dash',
|
|
452
|
+
unit: 'DASH',
|
|
453
|
+
};
|
|
454
|
+
const main$2 = Object.assign({}, {
|
|
455
|
+
hashGenesisBlock: '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6',
|
|
456
|
+
// nDefaultPort
|
|
457
|
+
port: 9999,
|
|
458
|
+
portRpc: 9998,
|
|
459
|
+
protocol: {
|
|
460
|
+
magic: 0xbd6b0cbf, // careful, sent over wire as little endian
|
|
461
|
+
},
|
|
462
|
+
// vSeeds
|
|
463
|
+
seedsDns: [
|
|
464
|
+
'dash.org',
|
|
465
|
+
'dnsseed.dash.org',
|
|
466
|
+
'dashdot.io',
|
|
467
|
+
'dnsseed.dashdot.io',
|
|
468
|
+
'masternode.io',
|
|
469
|
+
'dnsseed.masternode.io',
|
|
470
|
+
'dashpay.io',
|
|
471
|
+
'dnsseed.dashpay.io',
|
|
472
|
+
],
|
|
473
|
+
// base58Prefixes
|
|
474
|
+
versions: {
|
|
475
|
+
bip32: {
|
|
476
|
+
private: 0x0488ade4,
|
|
477
|
+
public: 0x0488b21e,
|
|
478
|
+
},
|
|
479
|
+
bip44: 5,
|
|
480
|
+
private: 0xcc,
|
|
481
|
+
public: 0x4c,
|
|
482
|
+
scripthash: 0x10,
|
|
483
|
+
},
|
|
484
|
+
}, common$2);
|
|
485
|
+
const test$2 = Object.assign({}, {
|
|
486
|
+
hashGenesisBlock: '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c',
|
|
487
|
+
port: 19999,
|
|
488
|
+
portRpc: 19998,
|
|
489
|
+
seedsDns: ['dashdot.io', 'testnet-seed.dashdot.io', 'masternode.io', 'test.dnsseed.masternode.io'],
|
|
490
|
+
versions: {
|
|
491
|
+
bip32: {
|
|
492
|
+
private: 0x04358394,
|
|
493
|
+
public: 0x043587cf,
|
|
494
|
+
},
|
|
495
|
+
bip44: 1,
|
|
496
|
+
private: 0xef,
|
|
497
|
+
public: 0x8c,
|
|
498
|
+
scripthash: 0x13,
|
|
499
|
+
},
|
|
500
|
+
}, common$2);
|
|
501
|
+
|
|
502
|
+
var dashData = /*#__PURE__*/Object.freeze({
|
|
503
|
+
__proto__: null,
|
|
504
|
+
main: main$2,
|
|
505
|
+
test: test$2
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// https://github.com/dogecoin/dogecoin/blob/master/src/chainparams.cpp
|
|
509
|
+
const common$1 = {
|
|
510
|
+
name: 'Dogecoin',
|
|
511
|
+
unit: 'DOGE',
|
|
512
|
+
};
|
|
513
|
+
const main$1 = Object.assign({}, {
|
|
514
|
+
hashGenesisBlock: '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691',
|
|
515
|
+
port: 22556,
|
|
516
|
+
protocol: {
|
|
517
|
+
magic: 0xc0c0c0c0,
|
|
518
|
+
},
|
|
519
|
+
seedsDns: ['seed.multidoge.org', 'seed2.multidoge.org'],
|
|
520
|
+
versions: {
|
|
521
|
+
bip32: {
|
|
522
|
+
private: 0x02fac398,
|
|
523
|
+
public: 0x02facafd,
|
|
524
|
+
},
|
|
525
|
+
bip44: 3,
|
|
526
|
+
private: 0x9e,
|
|
527
|
+
public: 0x1e,
|
|
528
|
+
scripthash: 0x16,
|
|
529
|
+
},
|
|
530
|
+
}, common$1);
|
|
531
|
+
const test$1 = Object.assign({}, {
|
|
532
|
+
hashGenesisBlock: 'bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e',
|
|
533
|
+
port: 44556,
|
|
534
|
+
protocol: {
|
|
535
|
+
magic: 0xfcc1b7dc,
|
|
536
|
+
},
|
|
537
|
+
seedsDns: ['testseed.jrn.me.uk'],
|
|
538
|
+
versions: {
|
|
539
|
+
bip32: {
|
|
540
|
+
private: 0x04358394,
|
|
541
|
+
public: 0x043587cf,
|
|
542
|
+
},
|
|
543
|
+
bip44: 1,
|
|
544
|
+
private: 0xf1,
|
|
545
|
+
public: 0x71,
|
|
546
|
+
scripthash: 0xc4,
|
|
547
|
+
},
|
|
548
|
+
}, common$1);
|
|
549
|
+
|
|
550
|
+
var dogeData = /*#__PURE__*/Object.freeze({
|
|
551
|
+
__proto__: null,
|
|
552
|
+
main: main$1,
|
|
553
|
+
test: test$1
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
// https://github.com/litecoin-project/litecoin/blob/master-0.10/src/chainparams.cpp
|
|
557
|
+
const common = {
|
|
558
|
+
name: 'Litecoin',
|
|
559
|
+
unit: 'LTC',
|
|
560
|
+
};
|
|
561
|
+
const main = Object.assign({}, {
|
|
562
|
+
hashGenesisBlock: '12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2',
|
|
563
|
+
port: 9333,
|
|
564
|
+
protocol: {
|
|
565
|
+
magic: 0xdbb6c0fb,
|
|
566
|
+
},
|
|
567
|
+
bech32: 'ltc',
|
|
568
|
+
seedsDns: [
|
|
569
|
+
'dnsseed.litecointools.com',
|
|
570
|
+
'dnsseed.litecoinpool.org',
|
|
571
|
+
'dnsseed.ltc.xurious.com',
|
|
572
|
+
'dnsseed.koin-project.com',
|
|
573
|
+
'dnsseed.weminemnc.com',
|
|
574
|
+
],
|
|
575
|
+
versions: {
|
|
576
|
+
bip32: {
|
|
577
|
+
private: 0x019d9cfe,
|
|
578
|
+
public: 0x019da462,
|
|
579
|
+
},
|
|
580
|
+
bip44: 2,
|
|
581
|
+
private: 0xb0,
|
|
582
|
+
public: 0x30,
|
|
583
|
+
scripthash: 0x32,
|
|
584
|
+
scripthash2: 0x05, // old '3' prefix. available for backward compatibility.
|
|
585
|
+
},
|
|
586
|
+
}, common);
|
|
587
|
+
const test = Object.assign({}, {
|
|
588
|
+
hashGenesisBlock: 'f5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f',
|
|
589
|
+
bech32: 'tltc',
|
|
590
|
+
versions: {
|
|
591
|
+
bip32: {
|
|
592
|
+
private: 0x0436ef7d,
|
|
593
|
+
public: 0x0436f6e1,
|
|
594
|
+
},
|
|
595
|
+
bip44: 1,
|
|
596
|
+
private: 0xef,
|
|
597
|
+
public: 0x6f,
|
|
598
|
+
scripthash: 0x3a,
|
|
599
|
+
scripthash2: 0xc4,
|
|
600
|
+
},
|
|
601
|
+
}, common);
|
|
602
|
+
|
|
603
|
+
var ltcData = /*#__PURE__*/Object.freeze({
|
|
604
|
+
__proto__: null,
|
|
605
|
+
main: main,
|
|
606
|
+
test: test
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
function toBitcoinJSInner(coinConfig) {
|
|
610
|
+
return {
|
|
611
|
+
messagePrefix: coinConfig.messagePrefix || '\x19' + coinConfig.name + ' Signed Message:\n',
|
|
612
|
+
bech32: coinConfig.bech32,
|
|
613
|
+
bip32: {
|
|
614
|
+
public: (coinConfig.versions.bip32 || {}).public,
|
|
615
|
+
private: (coinConfig.versions.bip32 || {}).private,
|
|
616
|
+
},
|
|
617
|
+
pubKeyHash: coinConfig.versions.public,
|
|
618
|
+
scriptHash: coinConfig.versions.scripthash,
|
|
619
|
+
wif: coinConfig.versions.private,
|
|
620
|
+
dustThreshold: null,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
const coinConfigs = {
|
|
624
|
+
bitcoincash: bchData,
|
|
625
|
+
dogecoin: dogeData,
|
|
626
|
+
dash: dashData,
|
|
627
|
+
litecoin: ltcData,
|
|
628
|
+
};
|
|
629
|
+
function toBitcoinJS(chain, network) {
|
|
630
|
+
const coinData = coinConfigs[chain];
|
|
631
|
+
if (!coinData) {
|
|
632
|
+
throw new Error(`Coin data for ${chain} not found`);
|
|
633
|
+
}
|
|
634
|
+
const config = network === 'main' ? coinData.main : coinData.test;
|
|
635
|
+
if (!config) {
|
|
636
|
+
throw new Error(`Network ${network} not found for ${chain}`);
|
|
637
|
+
}
|
|
638
|
+
return toBitcoinJSInner(config);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export { Client, toBitcoinJS };
|
package/lib/index.js
CHANGED
|
@@ -354,4 +354,291 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
/*
|
|
358
|
+
info from:
|
|
359
|
+
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/chainparams.cpp
|
|
360
|
+
*/
|
|
361
|
+
const common$3 = {
|
|
362
|
+
name: 'BitcoinCash',
|
|
363
|
+
per1: 1e8,
|
|
364
|
+
unit: 'BCH',
|
|
365
|
+
};
|
|
366
|
+
const main$3 = Object.assign({}, {
|
|
367
|
+
hashGenesisBlock: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
|
|
368
|
+
// nDefaultPort
|
|
369
|
+
port: 8333,
|
|
370
|
+
portRpc: 8332,
|
|
371
|
+
protocol: {
|
|
372
|
+
// pchMessageStart
|
|
373
|
+
magic: 0xe8f3e1e3, // careful, sent over wire as little endian
|
|
374
|
+
},
|
|
375
|
+
// vSeeds
|
|
376
|
+
seedsDns: [
|
|
377
|
+
'seed.bitcoinabc.org',
|
|
378
|
+
'seed-abc.bitcoinforks.org',
|
|
379
|
+
'btccash-seeder.bitcoinunlimited.info',
|
|
380
|
+
'seed.bitprim.org',
|
|
381
|
+
'seed.deadalnix.me',
|
|
382
|
+
'seeder.criptolayer.net',
|
|
383
|
+
],
|
|
384
|
+
// base58Prefixes
|
|
385
|
+
versions: {
|
|
386
|
+
bip32: {
|
|
387
|
+
private: 0x0488ade4,
|
|
388
|
+
public: 0x0488b21e,
|
|
389
|
+
},
|
|
390
|
+
bip44: 145,
|
|
391
|
+
private: 0x80,
|
|
392
|
+
public: 0x00,
|
|
393
|
+
scripthash: 0x05,
|
|
394
|
+
},
|
|
395
|
+
}, common$3);
|
|
396
|
+
const test$3 = Object.assign({}, {
|
|
397
|
+
hashGenesisBlock: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943',
|
|
398
|
+
port: 18333,
|
|
399
|
+
portRpc: 18332,
|
|
400
|
+
protocol: {
|
|
401
|
+
magic: 0xf4f3e5f4,
|
|
402
|
+
},
|
|
403
|
+
seedsDns: [
|
|
404
|
+
'testnet-seed.bitcoinabc.org',
|
|
405
|
+
'testnet-seed-abc.bitcoinforks.org',
|
|
406
|
+
'testnet-seed.bitprim.org',
|
|
407
|
+
'testnet-seed.deadalnix.me',
|
|
408
|
+
'testnet-seeder.criptolayer.net',
|
|
409
|
+
],
|
|
410
|
+
versions: {
|
|
411
|
+
bip32: {
|
|
412
|
+
private: 0x04358394,
|
|
413
|
+
public: 0x043587cf,
|
|
414
|
+
},
|
|
415
|
+
bip44: 1,
|
|
416
|
+
private: 0xef,
|
|
417
|
+
public: 0x6f,
|
|
418
|
+
scripthash: 0xc4,
|
|
419
|
+
},
|
|
420
|
+
}, common$3);
|
|
421
|
+
const regtest = Object.assign({}, {
|
|
422
|
+
hashGenesisBlock: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206',
|
|
423
|
+
port: 18444,
|
|
424
|
+
portRpc: 18332,
|
|
425
|
+
protocol: {
|
|
426
|
+
magic: 0xfabfb5da,
|
|
427
|
+
},
|
|
428
|
+
seedsDns: [],
|
|
429
|
+
versions: {
|
|
430
|
+
bip32: {
|
|
431
|
+
private: 0x04358394,
|
|
432
|
+
public: 0x043587cf,
|
|
433
|
+
},
|
|
434
|
+
bip44: 1,
|
|
435
|
+
private: 0xef,
|
|
436
|
+
public: 0x6f,
|
|
437
|
+
scripthash: 0xc4,
|
|
438
|
+
},
|
|
439
|
+
}, common$3);
|
|
440
|
+
|
|
441
|
+
var bchData = /*#__PURE__*/Object.freeze({
|
|
442
|
+
__proto__: null,
|
|
443
|
+
main: main$3,
|
|
444
|
+
regtest: regtest,
|
|
445
|
+
test: test$3
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
/*
|
|
449
|
+
info from:
|
|
450
|
+
https://github.com/dashpay/dash/blob/master/src/chainparams.cpp
|
|
451
|
+
*/
|
|
452
|
+
const common$2 = {
|
|
453
|
+
name: 'Dash',
|
|
454
|
+
unit: 'DASH',
|
|
455
|
+
};
|
|
456
|
+
const main$2 = Object.assign({}, {
|
|
457
|
+
hashGenesisBlock: '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6',
|
|
458
|
+
// nDefaultPort
|
|
459
|
+
port: 9999,
|
|
460
|
+
portRpc: 9998,
|
|
461
|
+
protocol: {
|
|
462
|
+
magic: 0xbd6b0cbf, // careful, sent over wire as little endian
|
|
463
|
+
},
|
|
464
|
+
// vSeeds
|
|
465
|
+
seedsDns: [
|
|
466
|
+
'dash.org',
|
|
467
|
+
'dnsseed.dash.org',
|
|
468
|
+
'dashdot.io',
|
|
469
|
+
'dnsseed.dashdot.io',
|
|
470
|
+
'masternode.io',
|
|
471
|
+
'dnsseed.masternode.io',
|
|
472
|
+
'dashpay.io',
|
|
473
|
+
'dnsseed.dashpay.io',
|
|
474
|
+
],
|
|
475
|
+
// base58Prefixes
|
|
476
|
+
versions: {
|
|
477
|
+
bip32: {
|
|
478
|
+
private: 0x0488ade4,
|
|
479
|
+
public: 0x0488b21e,
|
|
480
|
+
},
|
|
481
|
+
bip44: 5,
|
|
482
|
+
private: 0xcc,
|
|
483
|
+
public: 0x4c,
|
|
484
|
+
scripthash: 0x10,
|
|
485
|
+
},
|
|
486
|
+
}, common$2);
|
|
487
|
+
const test$2 = Object.assign({}, {
|
|
488
|
+
hashGenesisBlock: '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c',
|
|
489
|
+
port: 19999,
|
|
490
|
+
portRpc: 19998,
|
|
491
|
+
seedsDns: ['dashdot.io', 'testnet-seed.dashdot.io', 'masternode.io', 'test.dnsseed.masternode.io'],
|
|
492
|
+
versions: {
|
|
493
|
+
bip32: {
|
|
494
|
+
private: 0x04358394,
|
|
495
|
+
public: 0x043587cf,
|
|
496
|
+
},
|
|
497
|
+
bip44: 1,
|
|
498
|
+
private: 0xef,
|
|
499
|
+
public: 0x8c,
|
|
500
|
+
scripthash: 0x13,
|
|
501
|
+
},
|
|
502
|
+
}, common$2);
|
|
503
|
+
|
|
504
|
+
var dashData = /*#__PURE__*/Object.freeze({
|
|
505
|
+
__proto__: null,
|
|
506
|
+
main: main$2,
|
|
507
|
+
test: test$2
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
// https://github.com/dogecoin/dogecoin/blob/master/src/chainparams.cpp
|
|
511
|
+
const common$1 = {
|
|
512
|
+
name: 'Dogecoin',
|
|
513
|
+
unit: 'DOGE',
|
|
514
|
+
};
|
|
515
|
+
const main$1 = Object.assign({}, {
|
|
516
|
+
hashGenesisBlock: '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691',
|
|
517
|
+
port: 22556,
|
|
518
|
+
protocol: {
|
|
519
|
+
magic: 0xc0c0c0c0,
|
|
520
|
+
},
|
|
521
|
+
seedsDns: ['seed.multidoge.org', 'seed2.multidoge.org'],
|
|
522
|
+
versions: {
|
|
523
|
+
bip32: {
|
|
524
|
+
private: 0x02fac398,
|
|
525
|
+
public: 0x02facafd,
|
|
526
|
+
},
|
|
527
|
+
bip44: 3,
|
|
528
|
+
private: 0x9e,
|
|
529
|
+
public: 0x1e,
|
|
530
|
+
scripthash: 0x16,
|
|
531
|
+
},
|
|
532
|
+
}, common$1);
|
|
533
|
+
const test$1 = Object.assign({}, {
|
|
534
|
+
hashGenesisBlock: 'bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e',
|
|
535
|
+
port: 44556,
|
|
536
|
+
protocol: {
|
|
537
|
+
magic: 0xfcc1b7dc,
|
|
538
|
+
},
|
|
539
|
+
seedsDns: ['testseed.jrn.me.uk'],
|
|
540
|
+
versions: {
|
|
541
|
+
bip32: {
|
|
542
|
+
private: 0x04358394,
|
|
543
|
+
public: 0x043587cf,
|
|
544
|
+
},
|
|
545
|
+
bip44: 1,
|
|
546
|
+
private: 0xf1,
|
|
547
|
+
public: 0x71,
|
|
548
|
+
scripthash: 0xc4,
|
|
549
|
+
},
|
|
550
|
+
}, common$1);
|
|
551
|
+
|
|
552
|
+
var dogeData = /*#__PURE__*/Object.freeze({
|
|
553
|
+
__proto__: null,
|
|
554
|
+
main: main$1,
|
|
555
|
+
test: test$1
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
// https://github.com/litecoin-project/litecoin/blob/master-0.10/src/chainparams.cpp
|
|
559
|
+
const common = {
|
|
560
|
+
name: 'Litecoin',
|
|
561
|
+
unit: 'LTC',
|
|
562
|
+
};
|
|
563
|
+
const main = Object.assign({}, {
|
|
564
|
+
hashGenesisBlock: '12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2',
|
|
565
|
+
port: 9333,
|
|
566
|
+
protocol: {
|
|
567
|
+
magic: 0xdbb6c0fb,
|
|
568
|
+
},
|
|
569
|
+
bech32: 'ltc',
|
|
570
|
+
seedsDns: [
|
|
571
|
+
'dnsseed.litecointools.com',
|
|
572
|
+
'dnsseed.litecoinpool.org',
|
|
573
|
+
'dnsseed.ltc.xurious.com',
|
|
574
|
+
'dnsseed.koin-project.com',
|
|
575
|
+
'dnsseed.weminemnc.com',
|
|
576
|
+
],
|
|
577
|
+
versions: {
|
|
578
|
+
bip32: {
|
|
579
|
+
private: 0x019d9cfe,
|
|
580
|
+
public: 0x019da462,
|
|
581
|
+
},
|
|
582
|
+
bip44: 2,
|
|
583
|
+
private: 0xb0,
|
|
584
|
+
public: 0x30,
|
|
585
|
+
scripthash: 0x32,
|
|
586
|
+
scripthash2: 0x05, // old '3' prefix. available for backward compatibility.
|
|
587
|
+
},
|
|
588
|
+
}, common);
|
|
589
|
+
const test = Object.assign({}, {
|
|
590
|
+
hashGenesisBlock: 'f5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f',
|
|
591
|
+
bech32: 'tltc',
|
|
592
|
+
versions: {
|
|
593
|
+
bip32: {
|
|
594
|
+
private: 0x0436ef7d,
|
|
595
|
+
public: 0x0436f6e1,
|
|
596
|
+
},
|
|
597
|
+
bip44: 1,
|
|
598
|
+
private: 0xef,
|
|
599
|
+
public: 0x6f,
|
|
600
|
+
scripthash: 0x3a,
|
|
601
|
+
scripthash2: 0xc4,
|
|
602
|
+
},
|
|
603
|
+
}, common);
|
|
604
|
+
|
|
605
|
+
var ltcData = /*#__PURE__*/Object.freeze({
|
|
606
|
+
__proto__: null,
|
|
607
|
+
main: main,
|
|
608
|
+
test: test
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
function toBitcoinJSInner(coinConfig) {
|
|
612
|
+
return {
|
|
613
|
+
messagePrefix: coinConfig.messagePrefix || '\x19' + coinConfig.name + ' Signed Message:\n',
|
|
614
|
+
bech32: coinConfig.bech32,
|
|
615
|
+
bip32: {
|
|
616
|
+
public: (coinConfig.versions.bip32 || {}).public,
|
|
617
|
+
private: (coinConfig.versions.bip32 || {}).private,
|
|
618
|
+
},
|
|
619
|
+
pubKeyHash: coinConfig.versions.public,
|
|
620
|
+
scriptHash: coinConfig.versions.scripthash,
|
|
621
|
+
wif: coinConfig.versions.private,
|
|
622
|
+
dustThreshold: null,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
const coinConfigs = {
|
|
626
|
+
bitcoincash: bchData,
|
|
627
|
+
dogecoin: dogeData,
|
|
628
|
+
dash: dashData,
|
|
629
|
+
litecoin: ltcData,
|
|
630
|
+
};
|
|
631
|
+
function toBitcoinJS(chain, network) {
|
|
632
|
+
const coinData = coinConfigs[chain];
|
|
633
|
+
if (!coinData) {
|
|
634
|
+
throw new Error(`Coin data for ${chain} not found`);
|
|
635
|
+
}
|
|
636
|
+
const config = network === 'main' ? coinData.main : coinData.test;
|
|
637
|
+
if (!config) {
|
|
638
|
+
throw new Error(`Network ${network} not found for ${chain}`);
|
|
639
|
+
}
|
|
640
|
+
return toBitcoinJSInner(config);
|
|
641
|
+
}
|
|
642
|
+
|
|
357
643
|
exports.Client = Client;
|
|
644
|
+
exports.toBitcoinJS = toBitcoinJS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-utxo",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Genereic UTXO client for XChainJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"XChain",
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
"clean": "rm -rf .turbo && rm -rf lib",
|
|
28
28
|
"build": "yarn clean && rollup -c --bundleConfigAsCjs",
|
|
29
29
|
"build:release": "yarn exec rm -rf release && yarn pack && yarn exec \"mkdir release && tar zxvf package.tgz --directory release && rm package.tgz\"",
|
|
30
|
-
"lint": "eslint \"{src,__tests__, __mocks__}/**/*.ts\" --fix --max-warnings 0"
|
|
30
|
+
"lint": "eslint \"{src,__tests__, __mocks__}/**/*.ts\" --fix --max-warnings 0",
|
|
31
|
+
"test": "jest"
|
|
31
32
|
},
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"access": "public",
|
|
34
35
|
"directory": "release/package"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@xchainjs/xchain-client": "2.0.
|
|
38
|
+
"@xchainjs/xchain-client": "2.0.1",
|
|
38
39
|
"@xchainjs/xchain-util": "2.0.0",
|
|
39
|
-
"@xchainjs/xchain-utxo-providers": "2.0.
|
|
40
|
+
"@xchainjs/xchain-utxo-providers": "2.0.1"
|
|
40
41
|
}
|
|
41
42
|
}
|