trac-msb 0.2.12 → 0.2.15
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 +4 -4
- package/src/config/config.js +4 -0
- package/src/config/env.js +6 -2
- package/src/index.js +4 -1
- package/tests/fixtures/assembleMessage.fixtures.js +8 -7
- package/tests/helpers/autobaseTestHelpers.js +5 -2
- package/tests/helpers/createTestSignature.js +3 -2
- package/tests/unit/messages/state/applyStateMessageBuilder.complete.test.js +5 -1
- package/tests/unit/messages/state/applyStateMessageBuilder.partial.test.js +5 -1
- package/tests/unit/utils/fileUtils/readAddressesFromWhitelistFile.test.js +2 -2
- package/tests/unit/utils/fileUtils/readBalanceMigrationFile.test.js +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trac-msb",
|
|
3
3
|
"main": "msb.mjs",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.15",
|
|
5
5
|
"pear": {
|
|
6
6
|
"name": "trac-msb",
|
|
7
7
|
"type": "terminal"
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"protomux-wakeup": "2.4.0",
|
|
49
49
|
"readline": "npm:bare-node-readline",
|
|
50
50
|
"ready-resource": "1.1.2",
|
|
51
|
-
"trac-
|
|
51
|
+
"trac-crypto-api": "0.1.5",
|
|
52
|
+
"trac-wallet": "1.0.4",
|
|
52
53
|
"tty": "npm:bare-node-tty",
|
|
53
54
|
"uuid": "^13.0.0"
|
|
54
55
|
},
|
|
@@ -60,8 +61,7 @@
|
|
|
60
61
|
"jest": "^30.1.3",
|
|
61
62
|
"protocol-buffers": "^4.2.0",
|
|
62
63
|
"sinon": "^21.0.0",
|
|
63
|
-
"supertest": "^7.1.4"
|
|
64
|
-
"trac-crypto-api": "^0.1.1"
|
|
64
|
+
"supertest": "^7.1.4"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"registry": "https://registry.npmjs.org",
|
package/src/config/config.js
CHANGED
|
@@ -46,6 +46,10 @@ export class Config {
|
|
|
46
46
|
return this.#config.dhtBootstrap
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
get derivationPath() {
|
|
50
|
+
return this.#config.derivationPath
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
get disableRateLimit() {
|
|
50
54
|
if (this.#isOverriden('disableRateLimit')) return !!this.#options.disableRateLimit
|
|
51
55
|
return !!this.#config.disableRateLimit
|
package/src/config/env.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TRAC_NETWORK_MSB_MAINNET_PREFIX, TRAC_NETWORK_MSB_TESTNET1_PREFIX } from 'trac-wallet/constants.js';
|
|
2
2
|
import { Config } from './config.js';
|
|
3
3
|
import { TRAC_NETWORK_TESTNET_ID, TRAC_NETWORK_MAINNET_ID } from 'trac-crypto-api/constants.js';
|
|
4
|
+
import { address } from 'trac-crypto-api';
|
|
4
5
|
|
|
5
6
|
export const ENV = {
|
|
6
7
|
MAINNET: 'mainnet',
|
|
@@ -15,9 +16,10 @@ const configData = {
|
|
|
15
16
|
addressPrefix: TRAC_NETWORK_MSB_TESTNET1_PREFIX,
|
|
16
17
|
addressPrefixLength: TRAC_NETWORK_MSB_TESTNET1_PREFIX.length,
|
|
17
18
|
bech32mHrpLength: TRAC_NETWORK_MSB_TESTNET1_PREFIX.length + 1, // len(addressPrefix + separator)
|
|
18
|
-
bootstrap: '
|
|
19
|
+
bootstrap: 'c184f4ad8e9cf5e911f9415b60e7dcfb30aed73ebd8a402ef68e1b154624f5ef',
|
|
19
20
|
channel: '1111trac1network1msb1testnet1111',
|
|
20
21
|
dhtBootstrap: ['116.202.214.149:10001', '157.180.12.214:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'], // these are used to peer discovery
|
|
22
|
+
derivationPath: address.TESNET_DERIVATION_PATH,
|
|
21
23
|
disableRateLimit: false,
|
|
22
24
|
enableErrorApplyLogs: true,
|
|
23
25
|
enableInteractiveMode: true,
|
|
@@ -55,6 +57,7 @@ const configData = {
|
|
|
55
57
|
bootstrap: 'acbc3a4344d3a804101d40e53db1dda82b767646425af73599d4cd6577d69685',
|
|
56
58
|
channel: '0000trac0network0msb0mainnet0000',
|
|
57
59
|
dhtBootstrap: ['116.202.214.149:10001', '157.180.12.214:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'],
|
|
60
|
+
derivationPath: address.MAINNET_DERIVATION_PATH,
|
|
58
61
|
disableRateLimit: false,
|
|
59
62
|
enableErrorApplyLogs: false,
|
|
60
63
|
enableInteractiveMode: true,
|
|
@@ -92,6 +95,7 @@ const configData = {
|
|
|
92
95
|
bootstrap: 'e90cca53847a12a82f3bf0f67401e45e2ccc1698ee163e61414c2894eb3c6b12',
|
|
93
96
|
channel: '12312313123123',
|
|
94
97
|
dhtBootstrap: ['116.202.214.149:10001', '157.180.12.214:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'],
|
|
98
|
+
derivationPath: address.MAINNET_DERIVATION_PATH,
|
|
95
99
|
disableRateLimit: false,
|
|
96
100
|
enableErrorApplyLogs: true,
|
|
97
101
|
enableInteractiveMode: true,
|
|
@@ -106,7 +110,7 @@ const configData = {
|
|
|
106
110
|
messageValidatorResponseTimeout: 3 * 3 * 1000, //Overall timeout for sending a message (ms). This is 3 * maxRetries * messageValidatorRetryDelay;
|
|
107
111
|
host: 'localhost',
|
|
108
112
|
port: 5000,
|
|
109
|
-
networkId:
|
|
113
|
+
networkId: TRAC_NETWORK_MAINNET_ID,
|
|
110
114
|
maxPeers: 64, // Connectivity constants
|
|
111
115
|
maxParallel: 64, // Connectivity constants
|
|
112
116
|
maxServerConnections: Infinity, // Connectivity constants
|
package/src/index.js
CHANGED
|
@@ -61,7 +61,10 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
61
61
|
super();
|
|
62
62
|
this.#config = config
|
|
63
63
|
this.#store = new Corestore(this.#config.storesFullPath);
|
|
64
|
-
this.#wallet = new PeerWallet({
|
|
64
|
+
this.#wallet = new PeerWallet({
|
|
65
|
+
networkPrefix: this.#config.addressPrefix,
|
|
66
|
+
derivationPath: this.#config.derivationPath
|
|
67
|
+
});
|
|
65
68
|
this.#readline_instance = null;
|
|
66
69
|
|
|
67
70
|
if (this.#config.enableInteractiveMode) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PeerWallet from 'trac-wallet';
|
|
2
2
|
import b4a from 'b4a';
|
|
3
|
+
import { config } from '../helpers/config.js';
|
|
3
4
|
|
|
4
5
|
export const mnemonicAdmin = "science edit ankle purity treat unable first express scatter depend also case nose regular rally area carbon wait power corn sibling metal crop farm";
|
|
5
6
|
|
|
@@ -8,9 +9,9 @@ export const writingKeyNonAdmin = b4a.from("1768953b234c79eccc6306fdcba2d7c1f0b0
|
|
|
8
9
|
|
|
9
10
|
export const bootstrapAdmin = writingKeyAdmin;
|
|
10
11
|
|
|
11
|
-
export const walletAdmin = new PeerWallet();
|
|
12
|
-
export const walletNonAdmin = new PeerWallet();
|
|
13
|
-
export const walletPeer = new PeerWallet();
|
|
12
|
+
export const walletAdmin = new PeerWallet({ derivationPath: config.derivationPath });
|
|
13
|
+
export const walletNonAdmin = new PeerWallet({ derivationPath: config.derivationPath });
|
|
14
|
+
export const walletPeer = new PeerWallet({ derivationPath: config.derivationPath });
|
|
14
15
|
|
|
15
16
|
export const adminEntry = {
|
|
16
17
|
address: null,
|
|
@@ -18,9 +19,9 @@ export const adminEntry = {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const initAll = async () => {
|
|
21
|
-
if (!walletAdmin.publicKey) await walletAdmin.generateKeyPair(mnemonicAdmin);
|
|
22
|
-
if (!walletNonAdmin.publicKey) await walletNonAdmin.generateKeyPair(walletNonAdmin.generateMnemonic());
|
|
23
|
-
if (!walletPeer.publicKey) await walletPeer.generateKeyPair(walletPeer.generateMnemonic());
|
|
22
|
+
if (!walletAdmin.publicKey) await walletAdmin.generateKeyPair(mnemonicAdmin, config.derivationPath);
|
|
23
|
+
if (!walletNonAdmin.publicKey) await walletNonAdmin.generateKeyPair(walletNonAdmin.generateMnemonic(), config.derivationPath);
|
|
24
|
+
if (!walletPeer.publicKey) await walletPeer.generateKeyPair(walletPeer.generateMnemonic(), config.derivationPath);
|
|
24
25
|
if (!adminEntry.address && !adminEntry.wk) {
|
|
25
26
|
adminEntry.address = walletAdmin.address;
|
|
26
27
|
adminEntry.wk = writingKeyAdmin;
|
|
@@ -37,4 +38,4 @@ export default {
|
|
|
37
38
|
walletPeer,
|
|
38
39
|
adminEntry,
|
|
39
40
|
initAll,
|
|
40
|
-
}
|
|
41
|
+
}
|
|
@@ -170,8 +170,11 @@ export function defaultOpenHyperbeeView(store) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
export async function createWallet(mnemonic = null) {
|
|
173
|
-
const wallet = new PeerWallet({
|
|
174
|
-
|
|
173
|
+
const wallet = new PeerWallet({
|
|
174
|
+
networkPrefix: config.addressPrefix,
|
|
175
|
+
derivationPath: config.derivationPath
|
|
176
|
+
});
|
|
177
|
+
await wallet.generateKeyPair(mnemonic, config.derivationPath);
|
|
175
178
|
return wallet;
|
|
176
179
|
}
|
|
177
180
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import PeerWallet from 'trac-wallet';
|
|
2
|
+
import { config } from './config.js';
|
|
2
3
|
|
|
3
4
|
export async function createSignature(payloadBuffer) {
|
|
4
|
-
const wallet = new PeerWallet();
|
|
5
|
-
await wallet.generateKeyPair();
|
|
5
|
+
const wallet = new PeerWallet({ derivationPath: config.derivationPath });
|
|
6
|
+
await wallet.generateKeyPair(undefined, config.derivationPath);
|
|
6
7
|
const signature = wallet.sign(payloadBuffer);
|
|
7
8
|
return { signature, wallet };
|
|
8
9
|
}
|
|
@@ -12,7 +12,11 @@ const hex = (value, bytes) => value.repeat(bytes);
|
|
|
12
12
|
const toBuf = value => b4a.from(value, 'hex');
|
|
13
13
|
|
|
14
14
|
async function createWallet(mnemonic) {
|
|
15
|
-
const wallet = new PeerWallet({
|
|
15
|
+
const wallet = new PeerWallet({
|
|
16
|
+
mnemonic,
|
|
17
|
+
networkPrefix: config.addressPrefix,
|
|
18
|
+
derivationPath: config.derivationPath
|
|
19
|
+
});
|
|
16
20
|
await wallet.ready;
|
|
17
21
|
return wallet;
|
|
18
22
|
}
|
|
@@ -12,7 +12,11 @@ import { isAddressValid } from '../../../../src/core/state/utils/address.js';
|
|
|
12
12
|
const hex = (value, bytes) => value.repeat(bytes);
|
|
13
13
|
|
|
14
14
|
async function createWallet(mnemonic) {
|
|
15
|
-
const wallet = new PeerWallet({
|
|
15
|
+
const wallet = new PeerWallet({
|
|
16
|
+
mnemonic,
|
|
17
|
+
networkPrefix: config.addressPrefix,
|
|
18
|
+
derivationPath: config.derivationPath
|
|
19
|
+
});
|
|
16
20
|
await wallet.ready;
|
|
17
21
|
return wallet;
|
|
18
22
|
}
|
|
@@ -30,9 +30,9 @@ hook('Initialize dummy whitelist files', async t => {
|
|
|
30
30
|
// Edge: large file
|
|
31
31
|
let large = '';
|
|
32
32
|
const randomAddress = async () => {
|
|
33
|
-
const wallet = new PeerWallet();
|
|
33
|
+
const wallet = new PeerWallet({ derivationPath: config.derivationPath });
|
|
34
34
|
await wallet.ready;
|
|
35
|
-
await wallet.generateKeyPair();
|
|
35
|
+
await wallet.generateKeyPair(undefined, config.derivationPath);
|
|
36
36
|
return wallet.address;
|
|
37
37
|
};
|
|
38
38
|
for (let i = 0; i < 1000; i++) {
|
|
@@ -47,9 +47,9 @@ hook('Initialize dummy balance files', async t => {
|
|
|
47
47
|
// Edge: large file
|
|
48
48
|
let large = '';
|
|
49
49
|
const randomAddress = async () => {
|
|
50
|
-
const wallet = new PeerWallet();
|
|
50
|
+
const wallet = new PeerWallet({ derivationPath: config.derivationPath });
|
|
51
51
|
await wallet.ready;
|
|
52
|
-
await wallet.generateKeyPair();
|
|
52
|
+
await wallet.generateKeyPair(undefined, config.derivationPath);
|
|
53
53
|
return wallet.address;
|
|
54
54
|
}
|
|
55
55
|
for (let i = 0; i < 1000; i++) {
|