1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | 'use strict'
|
8 | import { config } from './config'
|
9 |
|
10 | const Constants = {}
|
11 |
|
12 | Constants.Mainnet = {
|
13 | maxsize: 0x02000000,
|
14 | Address: {
|
15 | pubKeyHash: 0x00
|
16 | },
|
17 | Bip32: {
|
18 | pubKey: 0x0488b21e,
|
19 | privKey: 0x0488ade4
|
20 | },
|
21 | Block: {
|
22 | maxNBits: 0x1d00ffff,
|
23 | magicNum: 0xf9beb4d9
|
24 | },
|
25 | Msg: {
|
26 | magicNum: 0xf9beb4d9,
|
27 | versionBytesNum: 70012
|
28 | },
|
29 | PrivKey: {
|
30 | versionByteNum: 0x80
|
31 | },
|
32 | TxBuilder: {
|
33 | dust: 546,
|
34 | feePerKbNum: 0.00000500e8
|
35 | },
|
36 | Workers: {
|
37 |
|
38 |
|
39 |
|
40 | timeout: 60000
|
41 | }
|
42 | }
|
43 |
|
44 | Constants.Testnet = Object.assign({}, Constants.Mainnet, {
|
45 | Address: {
|
46 | pubKeyHash: 0x6f
|
47 | },
|
48 | Bip32: {
|
49 | pubKey: 0x043587cf,
|
50 | privKey: 0x04358394
|
51 | },
|
52 | Block: {
|
53 | maxNBits: 0x1d00ffff,
|
54 | magicNum: 0x0b110907
|
55 | },
|
56 | Msg: {
|
57 | magicNum: 0x0b110907,
|
58 | versionBytesNum: 70012
|
59 | },
|
60 | PrivKey: {
|
61 | versionByteNum: 0xef
|
62 | }
|
63 | })
|
64 |
|
65 | Constants.Regtest = Object.assign({}, Constants.Mainnet, {
|
66 | Address: {
|
67 | pubKeyHash: 0x6f
|
68 | },
|
69 | Bip32: {
|
70 | pubKey: 0x043587cf,
|
71 | privKey: 0x04358394
|
72 | },
|
73 | Block: {
|
74 | maxNBits: 0x1d00ffff,
|
75 | magicNum: 0xdab5bffa
|
76 | },
|
77 | Msg: {
|
78 | magicNum: 0x0b110907,
|
79 | versionBytesNum: 70012
|
80 | },
|
81 | PrivKey: {
|
82 | versionByteNum: 0xef
|
83 | }
|
84 | })
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | if (config.get('NETWORK') === 'testnet') {
|
94 | Constants.Default = Object.assign({}, Constants.Testnet)
|
95 | } else if (config.get('NETWORK') === 'mainnet') {
|
96 | Constants.Default = Object.assign({}, Constants.Mainnet)
|
97 | } else if (config.get('NETWORK') === 'regtest') {
|
98 | Constants.Default = Object.assign({}, Constants.Regtest)
|
99 | } else {
|
100 | throw new Error(
|
101 | `must set network in environment variable - mainnet, testnet or regtest?, received ${config.get('NETWORK')}`
|
102 | )
|
103 | }
|
104 |
|
105 | export { Constants }
|