@spirobel/monero-wallet-api 0.3.4 → 0.3.6
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/dist/scanning-syncing/backgroundWorker.d.ts +1 -1
- package/dist/scanning-syncing/backgroundWorker.js +15 -5
- package/dist/scanning-syncing/scanSettings.js +4 -4
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +1 -1
- package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
- package/dist/scanning-syncing/worker-mains/worker.js +8 -3
- package/dist/tools/monero-tools.js +3 -1
- package/dist/viewpair/ViewPair.js +45 -43
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CacheChangedCallback, type CacheChangedCallbackParameters } from "./scanresult/scanCache";
|
|
2
2
|
export declare function scanWallets(cacheChanged?: CacheChangedCallback, stopSync?: AbortSignal, scan_settings_path?: string, pathPrefix?: string): Promise<void>;
|
|
3
|
-
export declare function createWebworker(handle_result?: (result: CacheChangedCallbackParameters) => void, scan_settings_path?: string, pathPrefix?: string, handle_error?: (error: unknown) => void): Worker
|
|
3
|
+
export declare function createWebworker(handle_result?: (result: CacheChangedCallbackParameters) => void, scan_settings_path?: string, pathPrefix?: string, handle_error?: (error: unknown) => void): Promise<Worker | undefined>;
|
|
4
4
|
export declare function makeWebworkerScript(scan_settings_path?: string, pathPrefix?: string): string;
|
|
5
5
|
export declare function startWebworker(worker_script: string, handle_result?: (result: unknown) => void, handle_error?: (error: unknown) => void): Worker;
|
|
6
6
|
export declare const WW_ERROR_FORWARDING_SNIPPET = "\n\nself.onerror = (e) => self.postMessage({ type: 'ERROR', payload: e });\nself.addEventListener('unhandledrejection', (e) => \n self.postMessage({ type: 'ERROR', payload: e.reason })\n); \n";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ViewPair } from "../api";
|
|
1
|
+
import { get_info, ViewPair } from "../api";
|
|
2
|
+
import { LOCAL_NODE_DEFAULT_URL } from "../node-interaction/nodeUrl";
|
|
2
3
|
import {} from "./scanresult/scanCache";
|
|
3
|
-
import { openNonHaltedWallets, walletSettingsPlusKeys } from "./scanSettings";
|
|
4
|
+
import { openNonHaltedWallets, readNodeUrlFromScanSettings, walletSettingsPlusKeys, } from "./scanSettings";
|
|
4
5
|
import { workerMainCode } from "./worker-entrypoints/worker";
|
|
5
6
|
export async function scanWallets(cacheChanged = (params) => console.log(params), stopSync, scan_settings_path, pathPrefix) {
|
|
6
7
|
const nonHaltedWallets = await openNonHaltedWallets(scan_settings_path);
|
|
@@ -11,9 +12,18 @@ export async function scanWallets(cacheChanged = (params) => console.log(params)
|
|
|
11
12
|
const masterViewPair = await ViewPair.create(masterWalletSettings.primary_address, masterWithKeys.secret_view_key, masterWalletSettings.subaddress_index, masterWalletSettings.node_url);
|
|
12
13
|
await masterViewPair.scan(cacheChanged, stopSync, scan_settings_path, pathPrefix);
|
|
13
14
|
}
|
|
14
|
-
export function createWebworker(handle_result, scan_settings_path, pathPrefix, handle_error) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export async function createWebworker(handle_result, scan_settings_path, pathPrefix, handle_error) {
|
|
16
|
+
try {
|
|
17
|
+
const node_url = (await readNodeUrlFromScanSettings(scan_settings_path)) ||
|
|
18
|
+
LOCAL_NODE_DEFAULT_URL;
|
|
19
|
+
// check if the node connection works before starting the sync worker
|
|
20
|
+
const getInfo = await get_info(node_url);
|
|
21
|
+
const worker_script = makeWebworkerScript(scan_settings_path, pathPrefix);
|
|
22
|
+
return startWebworker(worker_script, handle_result, handle_error);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
handle_error?.(error);
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
export function makeWebworkerScript(scan_settings_path, pathPrefix) {
|
|
19
29
|
const settingsPathLine = scan_settings_path
|
|
@@ -42,7 +42,7 @@ export async function writeScanSettingsFileDefaultLocation(params) {
|
|
|
42
42
|
}
|
|
43
43
|
export async function writeStartHeightToScanSettings(start_height, settingsStorePath = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
44
44
|
const scanSettings = (await openScanSettingsFile(settingsStorePath)) || {
|
|
45
|
-
node_url:
|
|
45
|
+
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
46
46
|
wallets: [],
|
|
47
47
|
start_height: null,
|
|
48
48
|
};
|
|
@@ -52,7 +52,7 @@ export async function writeStartHeightToScanSettings(start_height, settingsStore
|
|
|
52
52
|
export async function writeDaemonHeightAsStartHeightToScanSettings(node_url, settingsStorePath = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
53
53
|
const getInfo = await get_info(node_url);
|
|
54
54
|
const scanSettings = (await openScanSettingsFile(settingsStorePath)) || {
|
|
55
|
-
node_url:
|
|
55
|
+
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
56
56
|
wallets: [],
|
|
57
57
|
start_height: null,
|
|
58
58
|
};
|
|
@@ -63,7 +63,7 @@ export async function writeDaemonHeightAsStartHeightToScanSettings(node_url, set
|
|
|
63
63
|
export async function cullTooLargeScanHeight(node_url, settingsStorePath = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
64
64
|
const getInfo = await get_info(node_url);
|
|
65
65
|
const scanSettings = (await openScanSettingsFile(settingsStorePath)) || {
|
|
66
|
-
node_url:
|
|
66
|
+
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
67
67
|
wallets: [],
|
|
68
68
|
start_height: null,
|
|
69
69
|
};
|
|
@@ -76,7 +76,7 @@ export async function cullTooLargeScanHeight(node_url, settingsStorePath = SCAN_
|
|
|
76
76
|
}
|
|
77
77
|
export async function writeNodeUrlToScanSettings(node_url, settingsStorePath = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
78
78
|
const scanSettings = (await openScanSettingsFile(settingsStorePath)) || {
|
|
79
|
-
node_url:
|
|
79
|
+
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
80
80
|
wallets: [],
|
|
81
81
|
start_height: null,
|
|
82
82
|
};
|
|
@@ -427,7 +427,7 @@ export class ScanCacheOpened {
|
|
|
427
427
|
async unpause() {
|
|
428
428
|
// if worker does not exist yet, start it (if we are not slave / no_worker)
|
|
429
429
|
if (!this.worker && !this.no_worker) {
|
|
430
|
-
this.worker = createWebworker(async (params) => await this.feed(params), this.scan_settings_path, this.pathPrefix, (error) => {
|
|
430
|
+
this.worker = await createWebworker(async (params) => await this.feed(params), this.scan_settings_path, this.pathPrefix, (error) => {
|
|
431
431
|
const workerErrCB = this.workerError;
|
|
432
432
|
readWriteConnectionStatusFile((cs) => {
|
|
433
433
|
if (cs?.last_packet.status === "catastrophic_reorg")
|