trac-msb 0.2.13 → 0.2.16
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.16",
|
|
5
5
|
"pear": {
|
|
6
6
|
"name": "trac-msb",
|
|
7
7
|
"type": "terminal"
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"protomux-wakeup": "2.4.0",
|
|
52
52
|
"readline": "npm:bare-node-readline",
|
|
53
53
|
"ready-resource": "1.1.2",
|
|
54
|
-
"trac-
|
|
54
|
+
"trac-crypto-api": "0.1.5",
|
|
55
|
+
"trac-wallet": "1.0.4",
|
|
55
56
|
"tty": "npm:bare-node-tty",
|
|
56
57
|
"uuid": "^13.0.0"
|
|
57
58
|
},
|
|
@@ -65,8 +66,7 @@
|
|
|
65
66
|
"protobufjs-cli": "^1.2.0",
|
|
66
67
|
"protocol-buffers": "^4.2.0",
|
|
67
68
|
"sinon": "^21.0.0",
|
|
68
|
-
"supertest": "^7.1.4"
|
|
69
|
-
"trac-crypto-api": "^0.1.1"
|
|
69
|
+
"supertest": "^7.1.4"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"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,5 +1,6 @@
|
|
|
1
1
|
import { TRAC_NETWORK_MSB_MAINNET_PREFIX, TRAC_NETWORK_MSB_TESTNET1_PREFIX } from 'trac-wallet/constants.js';
|
|
2
2
|
import { TRAC_NETWORK_TESTNET_ID, TRAC_NETWORK_MAINNET_ID } from 'trac-crypto-api/constants.js';
|
|
3
|
+
import { address } from 'trac-crypto-api';
|
|
3
4
|
import { Config } from './config.js';
|
|
4
5
|
|
|
5
6
|
export const ENV = {
|
|
@@ -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,
|
|
@@ -60,6 +62,7 @@ const configData = {
|
|
|
60
62
|
bootstrap: 'acbc3a4344d3a804101d40e53db1dda82b767646425af73599d4cd6577d69685',
|
|
61
63
|
channel: '0000trac0network0msb0mainnet0000',
|
|
62
64
|
dhtBootstrap: ['116.202.214.149:10001', '157.180.12.214:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'],
|
|
65
|
+
derivationPath: address.MAINNET_DERIVATION_PATH,
|
|
63
66
|
disableRateLimit: false,
|
|
64
67
|
enableErrorApplyLogs: false,
|
|
65
68
|
enableInteractiveMode: true,
|
|
@@ -102,6 +105,7 @@ const configData = {
|
|
|
102
105
|
bootstrap: 'e90cca53847a12a82f3bf0f67401e45e2ccc1698ee163e61414c2894eb3c6b12',
|
|
103
106
|
channel: '12312313123123',
|
|
104
107
|
dhtBootstrap: ['116.202.214.149:10001', '157.180.12.214:10001', 'node1.hyperdht.org:49737', 'node2.hyperdht.org:49737', 'node3.hyperdht.org:49737'],
|
|
108
|
+
derivationPath: address.MAINNET_DERIVATION_PATH,
|
|
105
109
|
disableRateLimit: false,
|
|
106
110
|
enableErrorApplyLogs: true,
|
|
107
111
|
enableInteractiveMode: true,
|
|
@@ -116,7 +120,7 @@ const configData = {
|
|
|
116
120
|
messageValidatorResponseTimeout: 3 * 3 * 1000, //Overall timeout for sending a message (ms). This is 3 * maxRetries * messageValidatorRetryDelay;
|
|
117
121
|
host: 'localhost',
|
|
118
122
|
port: 5000,
|
|
119
|
-
networkId:
|
|
123
|
+
networkId: TRAC_NETWORK_MAINNET_ID,
|
|
120
124
|
maxPeers: 64, // Connectivity constants
|
|
121
125
|
maxParallel: 64, // Connectivity constants
|
|
122
126
|
maxServerConnections: Infinity, // Connectivity constants
|
package/src/index.js
CHANGED
|
@@ -62,7 +62,10 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
62
62
|
super();
|
|
63
63
|
this.#config = config
|
|
64
64
|
this.#store = new Corestore(this.#config.storesFullPath);
|
|
65
|
-
this.#wallet = new PeerWallet({
|
|
65
|
+
this.#wallet = new PeerWallet({
|
|
66
|
+
networkPrefix: this.#config.addressPrefix,
|
|
67
|
+
derivationPath: this.#config.derivationPath
|
|
68
|
+
});
|
|
66
69
|
this.#readline_instance = null;
|
|
67
70
|
|
|
68
71
|
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++) {
|