@spirobel/monero-wallet-api 0.5.3 → 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 +2 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +81 -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.js +3 -6
- 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");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LOCAL_NODE_DEFAULT_URL } from "../node-interaction/nodeUrl";
|
|
2
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";
|
|
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;
|
|
@@ -309,7 +309,8 @@ export class ScanSettingsOpened {
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
static _validateAddress(address) {
|
|
312
|
-
|
|
312
|
+
const parsed = parseAddress(address);
|
|
313
|
+
if ("error" in parsed) {
|
|
313
314
|
throw new Error(`invalid monero address: ${address}`);
|
|
314
315
|
}
|
|
315
316
|
}
|
|
@@ -404,10 +405,6 @@ export class ScanSettingsOpened {
|
|
|
404
405
|
await writeScanSettings(this._settings, this._scan_settings_path);
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
|
-
function isValidMoneroAddress(address) {
|
|
408
|
-
// basic sanity check
|
|
409
|
-
return (address.length >= 95 && address.length <= 106 && isAlphaNumeric(address));
|
|
410
|
-
}
|
|
411
408
|
function isValidMoneroPrivateKey(key) {
|
|
412
409
|
return key.length === 64 && isAlphaNumeric(key);
|
|
413
410
|
}
|
|
@@ -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
|
/**
|