@spirobel/monero-wallet-api 0.5.2 → 0.5.4
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/README.md +6 -0
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/io/logging.d.ts +6 -6
- package/dist/io/logging.js +4 -3
- package/dist/multisig/escrow.js +0 -1
- package/dist/scanning-syncing/backgroundWorker.d.ts +0 -1
- package/dist/scanning-syncing/backgroundWorker.js +21 -33
- package/dist/scanning-syncing/connectionStatusOpened.d.ts +1 -1
- package/dist/scanning-syncing/connectionStatusOpened.js +2 -2
- package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +4 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +87 -61
- package/dist/scanning-syncing/scanresult/scanCoordination.d.ts +0 -22
- package/dist/scanning-syncing/scanresult/scanCoordination.js +3 -185
- package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
- package/dist/scanning-syncing/worker-mains/coordinator-main.js +0 -1
- package/dist/scanning-syncing/worker-mains/cpubound-main.d.ts +5 -2
- package/dist/scanning-syncing/worker-mains/cpubound-main.js +8 -7
- package/dist/scanning-syncing/worker-mains/worker.js +6 -1
- package/dist/scansettings/scanSettingsOpened.d.ts +25 -0
- package/dist/scansettings/scanSettingsOpened.js +181 -8
- package/dist/tools/monero-tools.js +1 -1
- package/dist/viewpair/ViewPair.js +9 -4
- package/dist/wasm-processing/wasmFile.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type ScanLoopInput, type ScanLoopYield } from "../scanresult/scanLoop";
|
|
2
|
-
export declare function handleCpuboundScan(msg: ScanLoopInput,
|
|
3
|
-
export declare function handleCpuboundScanTry(msg: ScanLoopInput,
|
|
2
|
+
export declare function handleCpuboundScan(msg: ScanLoopInput, cpu_worker_status: CpuWorkerStatus): Promise<ScanLoopYield>;
|
|
3
|
+
export declare function handleCpuboundScanTry(msg: ScanLoopInput, cpu_worker_status: CpuWorkerStatus): Promise<ScanLoopYield>;
|
|
4
|
+
export type CpuWorkerStatus = {
|
|
5
|
+
cancel: boolean;
|
|
6
|
+
};
|
|
4
7
|
export declare function sendFromCpuWorker(port: MessagePort, msg: ScanLoopYield): void;
|
|
5
8
|
export declare function sendToCpuWorker(port: MessagePort, msg: ScanLoopInput): void;
|
|
@@ -6,7 +6,7 @@ import {} from "../scanresult/scanLoop";
|
|
|
6
6
|
* logs progress every 10 blocks, then sends the final result.
|
|
7
7
|
*/
|
|
8
8
|
let callcounter = 0;
|
|
9
|
-
export async function handleCpuboundScan(msg,
|
|
9
|
+
export async function handleCpuboundScan(msg, cpu_worker_status) {
|
|
10
10
|
callcounter++;
|
|
11
11
|
log("handleCpuboundScan", "callcounter=" + callcounter);
|
|
12
12
|
if (!msg) {
|
|
@@ -21,10 +21,6 @@ export async function handleCpuboundScan(msg, port) {
|
|
|
21
21
|
msg.walletConfig?.primary_address?.slice(0, 6));
|
|
22
22
|
const walletConfig = msg.walletConfig;
|
|
23
23
|
const item = msg;
|
|
24
|
-
if (!port) {
|
|
25
|
-
log("handleCpuboundScan", "no port!");
|
|
26
|
-
throw new Error("[cpubound] no port");
|
|
27
|
-
}
|
|
28
24
|
log("handleCpuboundScan", "primed, feeding workItem uuid=" +
|
|
29
25
|
(item && typeof item === "object"
|
|
30
26
|
? item.work_uuid?.slice(0, 8)
|
|
@@ -90,6 +86,11 @@ export async function handleCpuboundScan(msg, port) {
|
|
|
90
86
|
heightto,
|
|
91
87
|
]);
|
|
92
88
|
}
|
|
89
|
+
if (cpu_worker_status.cancel) {
|
|
90
|
+
cpu_worker_status.cancel = false;
|
|
91
|
+
log("handleCpuboundScan", ["cpu work canceled"]);
|
|
92
|
+
return { type: "Ready" };
|
|
93
|
+
}
|
|
93
94
|
await sleep(10); // make sure the loop is not tight
|
|
94
95
|
}
|
|
95
96
|
log("handleCpuboundScan", [
|
|
@@ -105,9 +106,9 @@ export async function handleCpuboundScan(msg, port) {
|
|
|
105
106
|
result: scanResult,
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
|
-
export function handleCpuboundScanTry(msg,
|
|
109
|
+
export function handleCpuboundScanTry(msg, cpu_worker_status) {
|
|
109
110
|
try {
|
|
110
|
-
return handleCpuboundScan(msg,
|
|
111
|
+
return handleCpuboundScan(msg, cpu_worker_status);
|
|
111
112
|
}
|
|
112
113
|
catch (err) {
|
|
113
114
|
console.error("[cpubound] error", err);
|
|
@@ -8,8 +8,13 @@ self.addEventListener("unhandledrejection", (e) => self.postMessage({ type: "ERR
|
|
|
8
8
|
let SCAN_SETTINGS_PATH;
|
|
9
9
|
let PATH_PREFIX;
|
|
10
10
|
let cpuPort;
|
|
11
|
+
const cpu_worker_status = { cancel: false };
|
|
11
12
|
let multisig_dkg;
|
|
12
13
|
export function CPU_PORT_HANDLER(pe) {
|
|
14
|
+
if (pe.data === "cancel") {
|
|
15
|
+
cpu_worker_status.cancel = true;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
13
18
|
if (!cpuPort)
|
|
14
19
|
throw new Error("[cpubound] cpuPort is undefined in port.onmessage");
|
|
15
20
|
log("CPU_PORT_HANDLER", "new workitem msg received");
|
|
@@ -17,7 +22,7 @@ export function CPU_PORT_HANDLER(pe) {
|
|
|
17
22
|
type: "WORKSTART",
|
|
18
23
|
work_uuid: pe.data.work_uuid,
|
|
19
24
|
});
|
|
20
|
-
handleCpuboundScanTry(pe.data,
|
|
25
|
+
handleCpuboundScanTry(pe.data, cpu_worker_status).then((result) => {
|
|
21
26
|
log("CPU_PORT_HANDLER", "work finished, sending result");
|
|
22
27
|
if (!cpuPort)
|
|
23
28
|
throw new Error("[cpubound] cpuPort is undefined in port.onmessage");
|
|
@@ -93,6 +93,17 @@ export declare class ScanSettingsOpened {
|
|
|
93
93
|
* throws if any entry is invalid.
|
|
94
94
|
*/
|
|
95
95
|
private static _validateLogOptions;
|
|
96
|
+
private static _validateAddress;
|
|
97
|
+
private static _validateViewKey;
|
|
98
|
+
private static _validateNodeUrl;
|
|
99
|
+
private static _validateStartHeight;
|
|
100
|
+
private static _validateCpuWorkerCount;
|
|
101
|
+
private static _validateMerchantConfirmations;
|
|
102
|
+
private static _validateWalletName;
|
|
103
|
+
private static _validateWalletSlot;
|
|
104
|
+
private static _validateSubaddressIndex;
|
|
105
|
+
private static _validateWalletRoute;
|
|
106
|
+
private static _validateHalted;
|
|
96
107
|
private _settings;
|
|
97
108
|
private constructor();
|
|
98
109
|
/**
|
|
@@ -100,3 +111,17 @@ export declare class ScanSettingsOpened {
|
|
|
100
111
|
*/
|
|
101
112
|
private _persist;
|
|
102
113
|
}
|
|
114
|
+
export declare function walletRouteFromString(input: string): {
|
|
115
|
+
ok: boolean;
|
|
116
|
+
error: string;
|
|
117
|
+
route?: undefined;
|
|
118
|
+
} | {
|
|
119
|
+
ok: boolean;
|
|
120
|
+
route: {
|
|
121
|
+
identity: string;
|
|
122
|
+
domain: string;
|
|
123
|
+
wallet_type: string;
|
|
124
|
+
wallet_slot: string;
|
|
125
|
+
};
|
|
126
|
+
error?: undefined;
|
|
127
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LOCAL_NODE_DEFAULT_URL } from "../node-interaction/nodeUrl";
|
|
2
|
-
import { LOGGING_FUNCTIONS } from "../io/logging";
|
|
3
|
-
import { getPathPrefix, makeSpendKeyFromSeed, makeViewKey, openScanSettingsFile, SCAN_SETTINGS_STORE_NAME_DEFAULT, SUB_ADDRESS_INDEX_DEFAULT_VALUE, walletSettingsPlusKeys, writeEnvLineToDotEnvRefresh, writeScanSettings, writeViewKeyToDotEnv, } from "../api";
|
|
2
|
+
import { LOGGING_FUNCTIONS, } from "../io/logging";
|
|
3
|
+
import { getPathPrefix, makeSpendKeyFromSeed, makeViewKey, openScanSettingsFile, parseAddress, SCAN_SETTINGS_STORE_NAME_DEFAULT, SUB_ADDRESS_INDEX_DEFAULT_VALUE, walletSettingsPlusKeys, writeEnvLineToDotEnvRefresh, writeScanSettings, writeViewKeyToDotEnv, } from "../api";
|
|
4
4
|
export class ScanSettingsOpened {
|
|
5
5
|
_scan_settings_path;
|
|
6
6
|
_pathPrefix;
|
|
@@ -55,27 +55,34 @@ export class ScanSettingsOpened {
|
|
|
55
55
|
}
|
|
56
56
|
async setNodeUrl(node_url) {
|
|
57
57
|
await this.reload();
|
|
58
|
-
this._settings.node_url = node_url;
|
|
58
|
+
this._settings.node_url = ScanSettingsOpened._validateNodeUrl(node_url);
|
|
59
59
|
await this._persist();
|
|
60
60
|
}
|
|
61
61
|
async setStartHeight(start_height) {
|
|
62
62
|
await this.reload();
|
|
63
|
+
ScanSettingsOpened._validateStartHeight(start_height);
|
|
63
64
|
this._settings.start_height = start_height;
|
|
64
65
|
await this._persist();
|
|
65
66
|
}
|
|
66
67
|
async setMerchantConfirmations(merchant_confirmations) {
|
|
67
68
|
await this.reload();
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
if (merchant_confirmations === undefined ||
|
|
70
|
+
merchant_confirmations === null) {
|
|
70
71
|
delete this._settings.merchant_confirmations;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
ScanSettingsOpened._validateMerchantConfirmations(merchant_confirmations);
|
|
75
|
+
this._settings.merchant_confirmations = merchant_confirmations;
|
|
76
|
+
}
|
|
71
77
|
await this._persist();
|
|
72
78
|
}
|
|
73
79
|
async setCpuWorkerCount(cpu_worker_count) {
|
|
74
80
|
await this.reload();
|
|
75
|
-
if (cpu_worker_count === null) {
|
|
81
|
+
if (cpu_worker_count === null || cpu_worker_count === undefined) {
|
|
76
82
|
delete this._settings.cpu_worker_count;
|
|
77
83
|
}
|
|
78
84
|
else {
|
|
85
|
+
ScanSettingsOpened._validateCpuWorkerCount(cpu_worker_count);
|
|
79
86
|
this._settings.cpu_worker_count = cpu_worker_count;
|
|
80
87
|
}
|
|
81
88
|
await this._persist();
|
|
@@ -154,13 +161,20 @@ export class ScanSettingsOpened {
|
|
|
154
161
|
* if the wallet already exists, updates it instead.
|
|
155
162
|
*/
|
|
156
163
|
async addViewWallet(primary_address, view_key, fields) {
|
|
164
|
+
primary_address = primary_address.trim();
|
|
165
|
+
view_key = view_key.trim();
|
|
166
|
+
ScanSettingsOpened._validateAddress(primary_address);
|
|
167
|
+
ScanSettingsOpened._validateViewKey(view_key);
|
|
168
|
+
ScanSettingsOpened._validateWalletName(fields?.wallet_name);
|
|
169
|
+
ScanSettingsOpened._validateWalletSlot(fields?.wallet_slot);
|
|
170
|
+
ScanSettingsOpened._validateWalletRoute(fields?.wallet_route);
|
|
171
|
+
ScanSettingsOpened._validateSubaddressIndex(fields?.subaddress_index);
|
|
172
|
+
ScanSettingsOpened._validateHalted(fields?.halted);
|
|
157
173
|
await this.reload();
|
|
158
174
|
const existing = this.getWallet(primary_address);
|
|
159
175
|
if (existing) {
|
|
160
176
|
throw new Error(`wallet already exists: ${primary_address} in ${this._scan_settings_path}`);
|
|
161
177
|
}
|
|
162
|
-
primary_address = primary_address.trim();
|
|
163
|
-
view_key = view_key.trim();
|
|
164
178
|
// write view key to env first
|
|
165
179
|
await writeViewKeyToDotEnv(primary_address, view_key);
|
|
166
180
|
const subaddress_index = fields?.subaddress_index ?? SUB_ADDRESS_INDEX_DEFAULT_VALUE;
|
|
@@ -180,6 +194,11 @@ export class ScanSettingsOpened {
|
|
|
180
194
|
const spend_key = await makeSpendKeyFromSeed(wallet_secret.toHex());
|
|
181
195
|
const view_pair = await makeViewKey(spend_key);
|
|
182
196
|
const primary_address = view_pair.mainnet_primary;
|
|
197
|
+
ScanSettingsOpened._validateWalletName(fields?.wallet_name);
|
|
198
|
+
ScanSettingsOpened._validateWalletSlot(fields?.wallet_slot);
|
|
199
|
+
ScanSettingsOpened._validateWalletRoute(fields?.wallet_route);
|
|
200
|
+
ScanSettingsOpened._validateSubaddressIndex(fields?.subaddress_index);
|
|
201
|
+
ScanSettingsOpened._validateHalted(fields?.halted);
|
|
183
202
|
await this.reload();
|
|
184
203
|
const existing = this.getWallet(primary_address);
|
|
185
204
|
if (existing) {
|
|
@@ -214,6 +233,11 @@ export class ScanSettingsOpened {
|
|
|
214
233
|
const wallet = this.getWallet(primary_address);
|
|
215
234
|
if (!wallet)
|
|
216
235
|
throw new Error(`wallet not found: ${primary_address} in ${this._scan_settings_path}`);
|
|
236
|
+
ScanSettingsOpened._validateWalletName(fields.wallet_name);
|
|
237
|
+
ScanSettingsOpened._validateWalletSlot(fields.wallet_slot);
|
|
238
|
+
ScanSettingsOpened._validateSubaddressIndex(fields.subaddress_index);
|
|
239
|
+
ScanSettingsOpened._validateWalletRoute(fields.wallet_route);
|
|
240
|
+
ScanSettingsOpened._validateHalted(fields.halted);
|
|
217
241
|
wallet.wallet_name = fields.wallet_name ?? wallet.wallet_name;
|
|
218
242
|
wallet.wallet_slot = fields.wallet_slot ?? wallet.wallet_slot;
|
|
219
243
|
wallet.wallet_route = fields.wallet_route ?? wallet.wallet_route;
|
|
@@ -284,6 +308,90 @@ export class ScanSettingsOpened {
|
|
|
284
308
|
`valid options are: ${[...valid].join(", ")}`);
|
|
285
309
|
}
|
|
286
310
|
}
|
|
311
|
+
static _validateAddress(address) {
|
|
312
|
+
const parsed = parseAddress(address);
|
|
313
|
+
if ("error" in parsed) {
|
|
314
|
+
throw new Error(`invalid monero address: ${address}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
static _validateViewKey(key) {
|
|
318
|
+
if (!isValidMoneroPrivateKey(key)) {
|
|
319
|
+
throw new Error(`invalid secret view key: ${key}`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
static _validateNodeUrl(url) {
|
|
323
|
+
let parsed;
|
|
324
|
+
try {
|
|
325
|
+
parsed = new URL(url);
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
throw new Error(`invalid node URL: ${url}`);
|
|
329
|
+
}
|
|
330
|
+
if (!["http:", "https:"].includes(parsed.protocol)) {
|
|
331
|
+
throw new Error(`unsupported protocol: ${parsed.protocol}`);
|
|
332
|
+
}
|
|
333
|
+
if (!parsed.hostname) {
|
|
334
|
+
throw new Error(`invalid node URL, missing hostname: ${url}`);
|
|
335
|
+
}
|
|
336
|
+
return url;
|
|
337
|
+
}
|
|
338
|
+
static _validateStartHeight(start_height) {
|
|
339
|
+
if (start_height !== null &&
|
|
340
|
+
(typeof start_height !== "number" || start_height < 0)) {
|
|
341
|
+
throw new Error(`invalid start height: ${start_height}. must be null or a number >= 0`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
static _validateCpuWorkerCount(cpu_worker_count) {
|
|
345
|
+
if (cpu_worker_count !== null &&
|
|
346
|
+
(typeof cpu_worker_count !== "number" || cpu_worker_count < 0)) {
|
|
347
|
+
throw new Error(`invalid cpu_worker_count: ${cpu_worker_count}. must be null or a number >= 0`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
static _validateMerchantConfirmations(merchant_confirmations) {
|
|
351
|
+
if (merchant_confirmations !== null &&
|
|
352
|
+
(typeof merchant_confirmations !== "number" || merchant_confirmations < 0)) {
|
|
353
|
+
throw new Error(`invalid merchant_confirmations: ${merchant_confirmations}. must be null or a number >= 0`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
static _validateWalletName(name) {
|
|
357
|
+
if (name === undefined || name === null)
|
|
358
|
+
return;
|
|
359
|
+
if (name.length > 100) {
|
|
360
|
+
throw new Error(`wallet name must be 100 characters or less, got ${name.length}`);
|
|
361
|
+
}
|
|
362
|
+
if (!/^[a-zA-Z0-9 _.-]+$/.test(name)) {
|
|
363
|
+
throw new Error(`wallet name must be alphanumeric with spaces, hyphens, underscores, or dots, got: ${name}`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
static _validateWalletSlot(slot) {
|
|
367
|
+
if (slot === undefined || slot === null)
|
|
368
|
+
return;
|
|
369
|
+
if (typeof slot !== "number" || slot < 0 || !Number.isInteger(slot)) {
|
|
370
|
+
throw new Error(`wallet slot must be a number >= 0, got: ${slot}`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
static _validateSubaddressIndex(index) {
|
|
374
|
+
if (index === undefined || index === null)
|
|
375
|
+
return;
|
|
376
|
+
if (typeof index !== "number" || index < 0 || !Number.isInteger(index)) {
|
|
377
|
+
throw new Error(`subaddress index must be a number >= 0, got: ${index}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
static _validateWalletRoute(route) {
|
|
381
|
+
if (route === undefined || route === null)
|
|
382
|
+
return;
|
|
383
|
+
const result = walletRouteFromString(route);
|
|
384
|
+
if (!result.ok) {
|
|
385
|
+
throw new Error(result.error);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
static _validateHalted(halted) {
|
|
389
|
+
if (halted === undefined || halted === null)
|
|
390
|
+
return;
|
|
391
|
+
if (typeof halted !== "boolean") {
|
|
392
|
+
throw new Error(`halted must be a boolean, got: ${halted}`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
287
395
|
_settings;
|
|
288
396
|
constructor(settings, _scan_settings_path, _pathPrefix) {
|
|
289
397
|
this._scan_settings_path = _scan_settings_path;
|
|
@@ -297,3 +405,68 @@ export class ScanSettingsOpened {
|
|
|
297
405
|
await writeScanSettings(this._settings, this._scan_settings_path);
|
|
298
406
|
}
|
|
299
407
|
}
|
|
408
|
+
function isValidMoneroPrivateKey(key) {
|
|
409
|
+
return key.length === 64 && isAlphaNumeric(key);
|
|
410
|
+
}
|
|
411
|
+
function isAlphaNumeric(str) {
|
|
412
|
+
return str.match(/^[a-z0-9]+$/i) !== null;
|
|
413
|
+
}
|
|
414
|
+
// strictly speaking according to the RFC 1035
|
|
415
|
+
// there is a limit of 63 chars per label
|
|
416
|
+
// and other rules like no leading or trailing hyphens, no dots in a row
|
|
417
|
+
function isValidDomainName(str) {
|
|
418
|
+
if (!str || str.length === 0 || str.length > 253) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
return str.match(/^[a-z0-9.\-_]+$/i) !== null;
|
|
422
|
+
}
|
|
423
|
+
// copied from seedphrase package to not introduce a dependency
|
|
424
|
+
export function walletRouteFromString(input) {
|
|
425
|
+
const parts = input.split("/");
|
|
426
|
+
if (parts.length < 1 || !parts[0]) {
|
|
427
|
+
return { ok: false, error: "missing identity" };
|
|
428
|
+
}
|
|
429
|
+
if (parts.length < 2 || !parts[1]) {
|
|
430
|
+
return { ok: false, error: "missing domain" };
|
|
431
|
+
}
|
|
432
|
+
if (parts.length < 3 || !parts[2]) {
|
|
433
|
+
return { ok: false, error: "missing wallet_type" };
|
|
434
|
+
}
|
|
435
|
+
if (parts.length < 4 || !parts[3]) {
|
|
436
|
+
return { ok: false, error: "missing wallet_slot" };
|
|
437
|
+
}
|
|
438
|
+
if (parts.length > 4) {
|
|
439
|
+
return {
|
|
440
|
+
ok: false,
|
|
441
|
+
error: "wallet route should only have 4 parts separated by /",
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
const [identity, domain, wallet_type, wallet_slot] = parts;
|
|
445
|
+
if (wallet_type !== "single" &&
|
|
446
|
+
wallet_type !== "sa_multi" &&
|
|
447
|
+
wallet_type !== "pl_multi") {
|
|
448
|
+
return { ok: false, error: `invalid wallet_type: "${wallet_type}"` };
|
|
449
|
+
}
|
|
450
|
+
if (Number.isNaN(parseInt(wallet_slot))) {
|
|
451
|
+
return { ok: false, error: `invalid wallet_slot: "${wallet_slot}"` };
|
|
452
|
+
}
|
|
453
|
+
if (parseInt(wallet_slot) < 0) {
|
|
454
|
+
return { ok: false, error: `invalid wallet_slot: "${wallet_slot} < 0"` };
|
|
455
|
+
}
|
|
456
|
+
if (!isAlphaNumeric(identity)) {
|
|
457
|
+
return {
|
|
458
|
+
ok: false,
|
|
459
|
+
error: `invalid identity, not alpha numeric: "${identity}"`,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
if (!isValidDomainName(domain)) {
|
|
463
|
+
return {
|
|
464
|
+
ok: false,
|
|
465
|
+
error: `invalid domain, : "${domain}"`,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
ok: true,
|
|
470
|
+
route: { identity, domain, wallet_type, wallet_slot },
|
|
471
|
+
};
|
|
472
|
+
}
|
|
@@ -122,7 +122,7 @@ export function parseDestination(destination) {
|
|
|
122
122
|
const url = new URL(destination);
|
|
123
123
|
return getDomainWithTLD(url.hostname);
|
|
124
124
|
}
|
|
125
|
-
export const OPEN_DOMAINS = ["monerochan.
|
|
125
|
+
export const OPEN_DOMAINS = ["monerochan.cash"];
|
|
126
126
|
// this validity check should happen in the contentscript when the link is clicked,
|
|
127
127
|
// not in the background script
|
|
128
128
|
// -> tor circuit is separated & compartmentalized
|
|
@@ -46,18 +46,23 @@ export class ViewPair extends WasmProcessor {
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
let init_viewpair_result = undefined;
|
|
49
|
+
let init_viewpair_error = undefined;
|
|
49
50
|
viewPair.readFromWasmMemory = (ptr, len) => {
|
|
50
51
|
init_viewpair_result = JSON.parse(viewPair.readString(ptr, len));
|
|
51
52
|
};
|
|
53
|
+
viewPair.readErrorFromWasmMemory = (ptr, len) => {
|
|
54
|
+
init_viewpair_error = JSON.parse(viewPair.readString(ptr, len));
|
|
55
|
+
};
|
|
52
56
|
//@ts-ignore
|
|
53
57
|
tinywasi.instance.exports.init_viewpair(primary_address.length, secret_view_key.length, subaddress_index);
|
|
58
|
+
if (init_viewpair_error && "error" in init_viewpair_error) {
|
|
59
|
+
throw new Error(`primary-address-not-valid (${primary_address.slice(0, 8)}...${primary_address.slice(-8)})`);
|
|
60
|
+
}
|
|
54
61
|
if (!init_viewpair_result) {
|
|
55
62
|
throw new Error("Failed to init viewpair");
|
|
56
63
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
viewPair._network = init_viewpair_result.network;
|
|
60
|
-
}
|
|
64
|
+
//@ts-ignore
|
|
65
|
+
viewPair._network = init_viewpair_result.network;
|
|
61
66
|
return viewPair;
|
|
62
67
|
}
|
|
63
68
|
/**
|