@spirobel/monero-wallet-api 0.4.0 → 0.5.0
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 +80 -8
- package/dist/api.d.ts +4 -0
- package/dist/api.js +4 -0
- package/dist/io/atomicWrite.js +2 -1
- package/dist/io/logging.d.ts +40 -0
- package/dist/io/logging.js +174 -0
- package/dist/keypairs-seeds/keypairs.d.ts +8 -0
- package/dist/keypairs-seeds/keypairs.js +31 -3
- package/dist/multisig/DistributedKeyGenerator.d.ts +125 -0
- package/dist/multisig/DistributedKeyGenerator.js +197 -0
- package/dist/multisig/MultiSigTxSigner.d.ts +68 -0
- package/dist/multisig/MultiSigTxSigner.js +123 -0
- package/dist/multisig/escrow.d.ts +58 -0
- package/dist/multisig/escrow.js +104 -0
- package/dist/multisig/multisig.d.ts +36 -0
- package/dist/multisig/multisig.js +140 -0
- package/dist/node-interaction/nodeUrl.js +2 -1
- package/dist/scanning-syncing/backgroundWorker.d.ts +2 -0
- package/dist/scanning-syncing/backgroundWorker.js +20 -8
- package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.js +9 -7
- package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +2 -1
- package/dist/scanning-syncing/scanSettings.d.ts +11 -0
- package/dist/scanning-syncing/scanSettings.js +18 -3
- package/dist/scanning-syncing/scanresult/computeKeyImage.d.ts +2 -1
- package/dist/scanning-syncing/scanresult/computeKeyImage.js +4 -2
- package/dist/scanning-syncing/scanresult/scanCache.js +7 -3
- package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +11 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +104 -11
- package/dist/scanning-syncing/scanresult/scanCoordination.js +63 -72
- package/dist/scanning-syncing/scanresult/scanResult.d.ts +1 -1
- package/dist/scanning-syncing/scanresult/scanResult.js +19 -6
- package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
- package/dist/scanning-syncing/worker-mains/coordinator-main.js +3 -2
- package/dist/scanning-syncing/worker-mains/cpubound-main.js +24 -14
- package/dist/scanning-syncing/worker-mains/multisig-main.d.ts +13 -0
- package/dist/scanning-syncing/worker-mains/multisig-main.js +31 -0
- package/dist/scanning-syncing/worker-mains/worker.js +23 -7
- package/dist/send-functionality/multisig.d.ts +72 -0
- package/dist/send-functionality/multisig.js +97 -0
- package/dist/send-functionality/transactionBuilding.d.ts +1 -0
- package/dist/send-functionality/transactionBuilding.js +23 -2
- package/dist/viewpair/ViewPair.d.ts +8 -0
- package/dist/viewpair/ViewPair.js +16 -8
- package/dist/wasm-processing/wasmFile.d.ts +1 -0
- package/dist/wasm-processing/wasmFile.js +8 -3
- package/dist/wasm-processing/wasmProcessor.d.ts +2 -2
- package/dist/wasm-processing/wasmProcessor.js +4 -5
- package/package.json +6 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { coordinatorMainMultithreaded } from "../scanresult/scanCoordination";
|
|
2
|
+
import { log } from "../../io/logging";
|
|
2
3
|
export async function coordinatorMainWorker(scan_settings_path, pathPrefix, cpuPorts) {
|
|
3
|
-
|
|
4
|
+
log("coordinatorMainWorker", "cpuPorts=" + cpuPorts?.length);
|
|
4
5
|
try {
|
|
5
6
|
const gen = coordinatorMainMultithreaded(scan_settings_path, pathPrefix, cpuPorts);
|
|
6
7
|
for await (const event of gen) {
|
|
7
|
-
|
|
8
|
+
log("coordinatorMainWorker", ["event:", event]);
|
|
8
9
|
if (event.type === "scan_ready") {
|
|
9
10
|
self.postMessage({
|
|
10
11
|
type: "SCAN_RESULT",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { sleep, ViewPair } from "../../api";
|
|
2
|
+
import { log } from "../../io/logging";
|
|
2
3
|
import {} from "../scanresult/scanLoop";
|
|
3
4
|
/**
|
|
4
5
|
* handle a single scan work item dispatched from the coordinator.
|
|
@@ -7,24 +8,24 @@ import {} from "../scanresult/scanLoop";
|
|
|
7
8
|
let callcounter = 0;
|
|
8
9
|
export async function handleCpuboundScan(msg, port) {
|
|
9
10
|
callcounter++;
|
|
10
|
-
|
|
11
|
+
log("handleCpuboundScan", "callcounter=" + callcounter);
|
|
11
12
|
if (!msg) {
|
|
12
|
-
|
|
13
|
+
log("handleCpuboundScan", "no content msg! ( ScanLoopInput = undefined )");
|
|
13
14
|
throw new Error("[cpubound] no content msg! ( ScanLoopInput = undefined )");
|
|
14
15
|
}
|
|
15
16
|
if (msg === "cancel") {
|
|
16
|
-
|
|
17
|
+
log("handleCpuboundScan", "cancel msg! ( ScanLoopInput = cancel )");
|
|
17
18
|
throw new Error("[cpubound] no content msg! ( ScanLoopInput = undefined )");
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
log("handleCpuboundScan", "got scan msg, walletConfig=" +
|
|
20
21
|
msg.walletConfig?.primary_address?.slice(0, 6));
|
|
21
22
|
const walletConfig = msg.walletConfig;
|
|
22
23
|
const item = msg;
|
|
23
24
|
if (!port) {
|
|
24
|
-
|
|
25
|
+
log("handleCpuboundScan", "no port!");
|
|
25
26
|
throw new Error("[cpubound] no port");
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
log("handleCpuboundScan", "primed, feeding workItem uuid=" +
|
|
28
29
|
(item && typeof item === "object"
|
|
29
30
|
? item.work_uuid?.slice(0, 8)
|
|
30
31
|
: "cancel"));
|
|
@@ -78,17 +79,26 @@ export async function handleCpuboundScan(msg, port) {
|
|
|
78
79
|
// the reconciliation workitembuffer -> blocksbuffer is done on every workitembuffer marked done at the end of the workbuffer (left end)
|
|
79
80
|
blockCount++;
|
|
80
81
|
if (blockCount % 10 === 0) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
log("handleCpuboundScan", [
|
|
83
|
+
"scanned " +
|
|
84
|
+
blockCount +
|
|
85
|
+
" " +
|
|
86
|
+
walletConfig.primary_address.slice(0, 6),
|
|
87
|
+
"@",
|
|
88
|
+
heighfrom,
|
|
89
|
+
"-",
|
|
90
|
+
heightto,
|
|
91
|
+
]);
|
|
85
92
|
}
|
|
86
93
|
await sleep(10); // make sure the loop is not tight
|
|
87
94
|
}
|
|
88
|
-
|
|
89
|
-
blockCount +
|
|
90
|
-
"
|
|
91
|
-
|
|
95
|
+
log("handleCpuboundScan", [
|
|
96
|
+
"scan done " + blockCount + " " + walletConfig.primary_address.slice(0, 6),
|
|
97
|
+
"@",
|
|
98
|
+
heighfrom,
|
|
99
|
+
"-",
|
|
100
|
+
heightto,
|
|
101
|
+
]);
|
|
92
102
|
return {
|
|
93
103
|
type: "Ready",
|
|
94
104
|
work_uuid: item.work_uuid,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DistributedKeyGenerator, type DkgParticipateParams, type DkgVerifyParams } from "../../api";
|
|
2
|
+
export type MultiSigParticipateCall = {
|
|
3
|
+
type: "multisig-call";
|
|
4
|
+
functionName: "participate";
|
|
5
|
+
params: DkgParticipateParams;
|
|
6
|
+
};
|
|
7
|
+
export type MultiSigVerifyCallMsg = {
|
|
8
|
+
type: "multisig-call";
|
|
9
|
+
functionName: "verify";
|
|
10
|
+
params: DkgVerifyParams;
|
|
11
|
+
};
|
|
12
|
+
export type MultiSigWorkerCallMsg = MultiSigParticipateCall | MultiSigVerifyCallMsg;
|
|
13
|
+
export declare function multisigMainWorkerCall(msg: MultiSigWorkerCallMsg, dkg?: DistributedKeyGenerator): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DistributedKeyGenerator, } from "../../api";
|
|
2
|
+
import { log } from "../../io/logging";
|
|
3
|
+
export function multisigMainWorkerCall(msg, dkg) {
|
|
4
|
+
if (!dkg) {
|
|
5
|
+
const error = new Error("multisigMainWorkerCall called without setup DistributedKeyGenerator first");
|
|
6
|
+
console.error("[multisigMainWorkerCall] error:", error);
|
|
7
|
+
log("multisigMainWorkerCall", ["error:", error]);
|
|
8
|
+
self.postMessage({ type: "ERROR", payload: error });
|
|
9
|
+
}
|
|
10
|
+
else if (msg.type === "multisig-call") {
|
|
11
|
+
const functionName = msg.functionName;
|
|
12
|
+
const params = msg.params;
|
|
13
|
+
log("multisigMainWorkerCall", [
|
|
14
|
+
`received call to ${functionName}() with params:`,
|
|
15
|
+
params,
|
|
16
|
+
]);
|
|
17
|
+
let result;
|
|
18
|
+
if (functionName === "participate") {
|
|
19
|
+
result = dkg.participateNoThrow(params);
|
|
20
|
+
}
|
|
21
|
+
else if (functionName === "verify") {
|
|
22
|
+
result = dkg.verifyNoThrow(params);
|
|
23
|
+
}
|
|
24
|
+
log("multisigMainWorkerCall", [
|
|
25
|
+
`received call to ${functionName}() with params, got result`,
|
|
26
|
+
params,
|
|
27
|
+
result,
|
|
28
|
+
]);
|
|
29
|
+
self.postMessage({ type: "multisig-call-result", result });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { coordinatorMainWorker } from "./coordinator-main";
|
|
2
|
-
import {
|
|
2
|
+
import { handleCpuboundScanTry, sendFromCpuWorker } from "./cpubound-main";
|
|
3
|
+
import { log, setupLoggingPath } from "../../io/logging";
|
|
4
|
+
import { SCAN_SETTINGS_STORE_NAME_DEFAULT } from "../scanSettings";
|
|
5
|
+
import { multisigMainWorkerCall } from "./multisig-main";
|
|
6
|
+
import { DistributedKeyGenerator } from "../../api";
|
|
3
7
|
self.onerror = (e) => self.postMessage({ type: "ERROR", payload: e });
|
|
4
8
|
self.addEventListener("unhandledrejection", (e) => self.postMessage({ type: "ERROR", payload: e.reason }));
|
|
5
9
|
let SCAN_SETTINGS_PATH;
|
|
6
10
|
let PATH_PREFIX;
|
|
7
11
|
let cpuPort;
|
|
12
|
+
let multisig_dkg;
|
|
8
13
|
export function CPU_PORT_HANDLER(pe) {
|
|
9
14
|
if (!cpuPort)
|
|
10
15
|
throw new Error("[cpubound] cpuPort is undefined in port.onmessage");
|
|
11
|
-
|
|
16
|
+
log("CPU_PORT_HANDLER", "new workitem msg received");
|
|
12
17
|
cpuPort.postMessage({
|
|
13
18
|
type: "WORKSTART",
|
|
14
19
|
work_uuid: pe.data.work_uuid,
|
|
15
20
|
});
|
|
16
21
|
handleCpuboundScanTry(pe.data, cpuPort).then((result) => {
|
|
17
|
-
|
|
22
|
+
log("CPU_PORT_HANDLER", "work finished, sending result");
|
|
18
23
|
if (!cpuPort)
|
|
19
24
|
throw new Error("[cpubound] cpuPort is undefined in port.onmessage");
|
|
20
25
|
cpuPort.onmessage = CPU_PORT_HANDLER;
|
|
@@ -23,19 +28,21 @@ export function CPU_PORT_HANDLER(pe) {
|
|
|
23
28
|
}
|
|
24
29
|
const handleMessage = async (e) => {
|
|
25
30
|
const msg = e.data;
|
|
26
|
-
|
|
31
|
+
log("handleMessage", ["msg received", msg]);
|
|
27
32
|
if (msg.type === "setup") {
|
|
28
|
-
|
|
33
|
+
const settingsPath = msg.scan_settings_path || SCAN_SETTINGS_STORE_NAME_DEFAULT;
|
|
34
|
+
SCAN_SETTINGS_PATH = settingsPath;
|
|
29
35
|
PATH_PREFIX = msg.pathPrefix;
|
|
36
|
+
await setupLoggingPath(settingsPath, msg.pathPrefix ?? "", msg.role, msg.cpu_worker_id);
|
|
30
37
|
if (msg.role === "cpubound") {
|
|
31
38
|
cpuPort = e.ports[0];
|
|
32
39
|
if (cpuPort) {
|
|
33
40
|
cpuPort.onmessage = CPU_PORT_HANDLER;
|
|
34
41
|
cpuPort.addEventListener("message", (e) => {
|
|
35
|
-
|
|
42
|
+
log("handleMessage", ["message received", e]);
|
|
36
43
|
});
|
|
37
44
|
cpuPort.addEventListener("messageerror", (e) => {
|
|
38
|
-
|
|
45
|
+
log("handleMessage", ["messageerror received", e]);
|
|
39
46
|
});
|
|
40
47
|
}
|
|
41
48
|
}
|
|
@@ -48,6 +55,15 @@ const handleMessage = async (e) => {
|
|
|
48
55
|
});
|
|
49
56
|
});
|
|
50
57
|
}
|
|
58
|
+
else if (msg.role === "multisig") {
|
|
59
|
+
DistributedKeyGenerator.createAndSetupGenerators(msg.t, msg.n).then((dkg) => {
|
|
60
|
+
multisig_dkg = dkg;
|
|
61
|
+
self.postMessage({ type: "multisig-ready" });
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (msg.type === "multisig-call") {
|
|
66
|
+
multisigMainWorkerCall(msg, multisig_dkg);
|
|
51
67
|
}
|
|
52
68
|
};
|
|
53
69
|
function handleMessageTry(e) {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { WasmProcessor } from "../wasm-processing/wasmProcessor";
|
|
2
|
+
export type DkgGetPublicKeyResult = {
|
|
3
|
+
dkg_public_key: string;
|
|
4
|
+
};
|
|
5
|
+
export type DkgParticipateParams = {
|
|
6
|
+
dkg_secret_key: string;
|
|
7
|
+
context: string;
|
|
8
|
+
dkg_public_keys: string[];
|
|
9
|
+
t: number;
|
|
10
|
+
};
|
|
11
|
+
export type DkgParticipateResult = {
|
|
12
|
+
participation: string;
|
|
13
|
+
};
|
|
14
|
+
export type DkgVerifyParams = {
|
|
15
|
+
dkg_secret_key: string;
|
|
16
|
+
context: string;
|
|
17
|
+
t: number;
|
|
18
|
+
dkg_public_keys: string[];
|
|
19
|
+
participations: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
export type DkgVerifyValidResult = {
|
|
22
|
+
group_key: string;
|
|
23
|
+
t: number;
|
|
24
|
+
n: number;
|
|
25
|
+
};
|
|
26
|
+
export type DkgVerifyInvalidResult = {
|
|
27
|
+
faulty_participants: number[];
|
|
28
|
+
};
|
|
29
|
+
export type DkgVerifyNotEnoughResult = {
|
|
30
|
+
message: "NotEnoughParticipants";
|
|
31
|
+
};
|
|
32
|
+
export type DkgVerifyResult = DkgVerifyValidResult | DkgVerifyInvalidResult | DkgVerifyNotEnoughResult;
|
|
33
|
+
export type DkgErrorResponse = {
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
export declare class DistributedKeyGenerator extends WasmProcessor {
|
|
37
|
+
/**
|
|
38
|
+
* set up a distributed key generator with t threshold and n total participants
|
|
39
|
+
* @param t - total number of multisig participants
|
|
40
|
+
* @param n - threshold to sign a transaction
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static create(t: number, n: number): Promise<DistributedKeyGenerator>;
|
|
44
|
+
/**
|
|
45
|
+
* setupGenerators
|
|
46
|
+
* configure the max threshold and max participants for the DKG generators.
|
|
47
|
+
* if never called, defaults to 16, 16 used automatically on first DKG operation.
|
|
48
|
+
*/
|
|
49
|
+
setupGenerators(t: number, n: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* derive the DKG public key from a 64-byte DKG secret key.
|
|
52
|
+
*
|
|
53
|
+
* @param dkgSecretKeyBytes 64-byte DKG secret key (from seed function)
|
|
54
|
+
* @returns the DKG public key as a hex string, or an error object
|
|
55
|
+
*/
|
|
56
|
+
getPublicKey(dkgSecretKeyBytes: Uint8Array): DkgGetPublicKeyResult | DkgErrorResponse;
|
|
57
|
+
/**
|
|
58
|
+
* participate in a DKG round.
|
|
59
|
+
*
|
|
60
|
+
* @param params dkg_secret_key as 64-byte hex string, context, dkg_public_keys array (length is n implicitly), t (threshold)
|
|
61
|
+
* @returns The participation message as hex, or an error object
|
|
62
|
+
*/
|
|
63
|
+
participate(params: DkgParticipateParams): DkgParticipateResult | DkgErrorResponse;
|
|
64
|
+
/**
|
|
65
|
+
* verify DKG participations and extract the group key.
|
|
66
|
+
*
|
|
67
|
+
* @param params dkg_secret_key as 64-byte hex string, context, t (threshold), dkg_public_keys array (length is n implicitly),
|
|
68
|
+
* participations [ paricipant index -> hex participation message ]
|
|
69
|
+
* @returns The group key and params, faulty participants, not-enough message, or error
|
|
70
|
+
*/
|
|
71
|
+
verify(params: DkgVerifyParams): DkgVerifyResult | DkgErrorResponse;
|
|
72
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { frost_dkg_wasm } from "../wasm-processing/wasmFile";
|
|
2
|
+
import { WasmProcessor } from "../wasm-processing/wasmProcessor";
|
|
3
|
+
export class DistributedKeyGenerator extends WasmProcessor {
|
|
4
|
+
/**
|
|
5
|
+
* set up a distributed key generator with t threshold and n total participants
|
|
6
|
+
* @param t - total number of multisig participants
|
|
7
|
+
* @param n - threshold to sign a transaction
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
static async create(t, n) {
|
|
11
|
+
const dkg = new DistributedKeyGenerator();
|
|
12
|
+
await dkg.initWasmModule(frost_dkg_wasm);
|
|
13
|
+
dkg.setupGenerators(t, n);
|
|
14
|
+
return dkg;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* setupGenerators
|
|
18
|
+
* configure the max threshold and max participants for the DKG generators.
|
|
19
|
+
* if never called, defaults to 16, 16 used automatically on first DKG operation.
|
|
20
|
+
*/
|
|
21
|
+
setupGenerators(t, n) {
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
this.tinywasi.instance.exports.setup_generators(t, n);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* derive the DKG public key from a 64-byte DKG secret key.
|
|
27
|
+
*
|
|
28
|
+
* @param dkgSecretKeyBytes 64-byte DKG secret key (from seed function)
|
|
29
|
+
* @returns the DKG public key as a hex string, or an error object
|
|
30
|
+
*/
|
|
31
|
+
getPublicKey(dkgSecretKeyBytes) {
|
|
32
|
+
// set up write callback: rust will call input(64) to read the secret key bytes
|
|
33
|
+
this.writeToWasmMemory = (ptr, len) => {
|
|
34
|
+
this.writeArray(ptr, len, dkgSecretKeyBytes);
|
|
35
|
+
};
|
|
36
|
+
// set up read callback: rust will call output_string() to return the result JSON
|
|
37
|
+
let result;
|
|
38
|
+
this.readFromWasmMemory = (ptr, len) => {
|
|
39
|
+
result = JSON.parse(this.readString(ptr, len));
|
|
40
|
+
};
|
|
41
|
+
//@ts-ignore
|
|
42
|
+
this.tinywasi.instance.exports.dkg_get_public_key();
|
|
43
|
+
if (!result) {
|
|
44
|
+
return { message: "No response from dkg_get_public_key" };
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* participate in a DKG round.
|
|
50
|
+
*
|
|
51
|
+
* @param params dkg_secret_key as 64-byte hex string, context, dkg_public_keys array (length is n implicitly), t (threshold)
|
|
52
|
+
* @returns The participation message as hex, or an error object
|
|
53
|
+
*/
|
|
54
|
+
participate(params) {
|
|
55
|
+
const jsonStr = JSON.stringify(params);
|
|
56
|
+
// set up write callback: rust will call input_string(json_len) to read the JSON
|
|
57
|
+
this.writeToWasmMemory = (ptr, len) => {
|
|
58
|
+
this.writeString(ptr, len, jsonStr);
|
|
59
|
+
};
|
|
60
|
+
// set up read callback: rust will call output_string() to return the result JSON
|
|
61
|
+
let result;
|
|
62
|
+
this.readFromWasmMemory = (ptr, len) => {
|
|
63
|
+
result = JSON.parse(this.readString(ptr, len));
|
|
64
|
+
};
|
|
65
|
+
//@ts-ignore
|
|
66
|
+
this.tinywasi.instance.exports.dkg_participate(jsonStr.length);
|
|
67
|
+
if (!result) {
|
|
68
|
+
return { message: "No response from dkg_participate" };
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* verify DKG participations and extract the group key.
|
|
74
|
+
*
|
|
75
|
+
* @param params dkg_secret_key as 64-byte hex string, context, t (threshold), dkg_public_keys array (length is n implicitly),
|
|
76
|
+
* participations [ paricipant index -> hex participation message ]
|
|
77
|
+
* @returns The group key and params, faulty participants, not-enough message, or error
|
|
78
|
+
*/
|
|
79
|
+
verify(params) {
|
|
80
|
+
const jsonStr = JSON.stringify(params);
|
|
81
|
+
// set up write callback: rust will call input_string(json_len) to read the JSON
|
|
82
|
+
this.writeToWasmMemory = (ptr, len) => {
|
|
83
|
+
this.writeString(ptr, len, jsonStr);
|
|
84
|
+
};
|
|
85
|
+
// set up read callback: rust will call output_string() to return the result JSON
|
|
86
|
+
let result;
|
|
87
|
+
this.readFromWasmMemory = (ptr, len) => {
|
|
88
|
+
result = JSON.parse(this.readString(ptr, len));
|
|
89
|
+
};
|
|
90
|
+
//@ts-ignore
|
|
91
|
+
this.tinywasi.instance.exports.dkg_verify(jsonStr.length);
|
|
92
|
+
if (!result) {
|
|
93
|
+
return { message: "No response from dkg_verify" };
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -31,6 +31,7 @@ export type SendError = {
|
|
|
31
31
|
error: ErrorDetail;
|
|
32
32
|
message: string;
|
|
33
33
|
};
|
|
34
|
+
export declare function makeSweepTransaction<T extends WasmProcessor>(processor: T, params: MakeTransactionParams): UnsignedTransaction;
|
|
34
35
|
/**
|
|
35
36
|
* this function returns the unsigned transaction, throws {@link SendError}
|
|
36
37
|
* @param processor
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { monero_wallet_api_wasm } from "../wasm-processing/wasmFile";
|
|
1
2
|
import { WasmProcessor } from "../wasm-processing/wasmProcessor";
|
|
2
3
|
export function makeInput(processor, outputToBeSpent, candidates, get_outs_Response) {
|
|
3
4
|
const makeInputArgs = JSON.stringify({
|
|
@@ -41,6 +42,26 @@ export function sampleDecoys(processor, outputToBeSpentIndex, distribution, cand
|
|
|
41
42
|
}
|
|
42
43
|
return result;
|
|
43
44
|
}
|
|
45
|
+
export function makeSweepTransaction(processor, params) {
|
|
46
|
+
const jsonParams = JSON.stringify(params);
|
|
47
|
+
processor.writeToWasmMemory = (ptr, len) => {
|
|
48
|
+
processor.writeString(ptr, len, jsonParams);
|
|
49
|
+
};
|
|
50
|
+
let result = null;
|
|
51
|
+
let error = null;
|
|
52
|
+
processor.readFromWasmMemory = (ptr, len) => {
|
|
53
|
+
result = JSON.parse(processor.readString(ptr, len));
|
|
54
|
+
};
|
|
55
|
+
processor.readErrorFromWasmMemory = (ptr, len) => {
|
|
56
|
+
error = JSON.parse(processor.readString(ptr, len));
|
|
57
|
+
};
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
processor.tinywasi.instance.exports.make_external_sweep_transaction(jsonParams.length);
|
|
60
|
+
if (!result) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
return result["signable_transaction"];
|
|
64
|
+
}
|
|
44
65
|
/**
|
|
45
66
|
* this function returns the unsigned transaction, throws {@link SendError}
|
|
46
67
|
* @param processor
|
|
@@ -68,7 +89,7 @@ export function makeTransaction(processor, params) {
|
|
|
68
89
|
return result["signable_transaction"];
|
|
69
90
|
}
|
|
70
91
|
export async function signTransaction(tx, sender_spend_key) {
|
|
71
|
-
const wasmProcessor = await WasmProcessor.init();
|
|
92
|
+
const wasmProcessor = await WasmProcessor.init(monero_wallet_api_wasm);
|
|
72
93
|
wasmProcessor.writeToWasmMemory = (ptr, len) => {
|
|
73
94
|
wasmProcessor.writeString(ptr, len, tx);
|
|
74
95
|
wasmProcessor.writeToWasmMemory = (ptr, len) => {
|
|
@@ -87,7 +108,7 @@ export async function signTransaction(tx, sender_spend_key) {
|
|
|
87
108
|
return result["signed_transaction"];
|
|
88
109
|
}
|
|
89
110
|
export async function parseAddress(address) {
|
|
90
|
-
const wasmProcessor = await WasmProcessor.init();
|
|
111
|
+
const wasmProcessor = await WasmProcessor.init(monero_wallet_api_wasm);
|
|
91
112
|
wasmProcessor.writeToWasmMemory = (ptr, len) => {
|
|
92
113
|
wasmProcessor.writeString(ptr, len, address);
|
|
93
114
|
};
|
|
@@ -120,6 +120,14 @@ export declare class ViewPair extends WasmProcessor {
|
|
|
120
120
|
* @returns The serialized transaction as an array of numbers.
|
|
121
121
|
*/
|
|
122
122
|
makeTransaction(params: MakeTransactionParams): UnsignedTransaction;
|
|
123
|
+
/**
|
|
124
|
+
* makeSweepTransaction
|
|
125
|
+
* @param params - The transaction parameters. Must have exactly one payment,
|
|
126
|
+
* the amount will be overwritten by the total amount of the inputs - the necessary fee
|
|
127
|
+
*
|
|
128
|
+
* @returns The serialized transaction as an array of numbers
|
|
129
|
+
*/
|
|
130
|
+
makeSweepTransaction(params: MakeTransactionParams): string;
|
|
123
131
|
/**
|
|
124
132
|
* Retrieve block headers for a specified range of heights.
|
|
125
133
|
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_block_headers_range
|
|
@@ -2,16 +2,14 @@ import {} from "../scanning-syncing/scanresult/scanResult";
|
|
|
2
2
|
export {};
|
|
3
3
|
export { NodeUrl } from "../node-interaction/nodeUrl";
|
|
4
4
|
import { getBlocksBinScan, getBlocksBinExecuteRequest, getBlocksBinScanOneBlock, loadGetBlocksBinResponse, MAINNET_GENESIS_BLOCK_HASH, STAGENET_GENESIS_BLOCK_HASH, } from "../node-interaction/binaryEndpoints";
|
|
5
|
-
import {
|
|
6
|
-
import { makeTransaction, } from "../send-functionality/transactionBuilding";
|
|
5
|
+
import { lastRange, writeCacheFileDefaultLocationThrows, } from "../scanning-syncing/scanresult/scanCache";
|
|
6
|
+
import { makeSweepTransaction, makeTransaction, } from "../send-functionality/transactionBuilding";
|
|
7
|
+
import { monero_wallet_api_wasm } from "../wasm-processing/wasmFile";
|
|
7
8
|
import { WasmProcessor } from "../wasm-processing/wasmProcessor";
|
|
8
9
|
import { LOCAL_NODE_DEFAULT_URL, } from "../node-interaction/nodeUrl";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { initScanCache, readCacheFileDefaultLocation, } from "../scanning-syncing/scanresult/scanCache";
|
|
12
|
-
import { cullTooLargeScanHeight, openNonHaltedWallets, readWalletFromScanSettings, walletSettingsPlusKeys, } from "../scanning-syncing/scanSettings";
|
|
10
|
+
import { get_block_headers_range, get_info, } from "../api";
|
|
11
|
+
import { readWalletFromScanSettings } from "../scanning-syncing/scanSettings";
|
|
13
12
|
import { sleep } from "../io/sleep";
|
|
14
|
-
import { readWriteConnectionStatusFile, writeConnectionStatusFile, } from "../scanning-syncing/connectionStatus";
|
|
15
13
|
/**
|
|
16
14
|
* This class is useful to interact with Moneros DaemonRpc binary requests in a convenient way.
|
|
17
15
|
* (similar to how you would interact with a REST api that gives you json back.)
|
|
@@ -40,7 +38,7 @@ export class ViewPair extends WasmProcessor {
|
|
|
40
38
|
}
|
|
41
39
|
static async create(primary_address, secret_view_key, subaddress_index = 0, node_url) {
|
|
42
40
|
const viewPair = new ViewPair(node_url || LOCAL_NODE_DEFAULT_URL, primary_address);
|
|
43
|
-
const tinywasi = await viewPair.initWasmModule();
|
|
41
|
+
const tinywasi = await viewPair.initWasmModule(monero_wallet_api_wasm);
|
|
44
42
|
viewPair.writeToWasmMemory = (ptr, len) => {
|
|
45
43
|
viewPair.writeString(ptr, len, primary_address);
|
|
46
44
|
viewPair.writeToWasmMemory = (ptr, len) => {
|
|
@@ -266,6 +264,16 @@ export class ViewPair extends WasmProcessor {
|
|
|
266
264
|
makeTransaction(params) {
|
|
267
265
|
return makeTransaction(this, params);
|
|
268
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* makeSweepTransaction
|
|
269
|
+
* @param params - The transaction parameters. Must have exactly one payment,
|
|
270
|
+
* the amount will be overwritten by the total amount of the inputs - the necessary fee
|
|
271
|
+
*
|
|
272
|
+
* @returns The serialized transaction as an array of numbers
|
|
273
|
+
*/
|
|
274
|
+
makeSweepTransaction(params) {
|
|
275
|
+
return makeSweepTransaction(this, params);
|
|
276
|
+
}
|
|
269
277
|
/**
|
|
270
278
|
* Retrieve block headers for a specified range of heights.
|
|
271
279
|
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_block_headers_range
|