@spirobel/monero-wallet-api 0.3.10 → 0.3.11
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/scanSettings.d.ts +4 -4
- package/dist/scanning-syncing/scanSettings.js +3 -3
- package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +1 -1
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +4 -4
- package/dist/tools/monero-tools.d.ts +6 -1
- package/dist/tools/monero-tools.js +26 -5
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ export type ScanSetting = {
|
|
|
5
5
|
halted?: boolean;
|
|
6
6
|
wallet_route?: string;
|
|
7
7
|
wallet_name?: string;
|
|
8
|
-
|
|
8
|
+
wallet_slot?: number;
|
|
9
9
|
};
|
|
10
10
|
export type WriteScanSettingParams = {
|
|
11
11
|
primary_address: string;
|
|
@@ -16,7 +16,7 @@ export type WriteScanSettingParams = {
|
|
|
16
16
|
node_url?: string;
|
|
17
17
|
wallet_route?: string;
|
|
18
18
|
wallet_name?: string;
|
|
19
|
-
|
|
19
|
+
wallet_slot?: number;
|
|
20
20
|
};
|
|
21
21
|
export type ScanSettingOpened = {
|
|
22
22
|
primary_address: string;
|
|
@@ -28,7 +28,7 @@ export type ScanSettingOpened = {
|
|
|
28
28
|
secret_spend_key?: string;
|
|
29
29
|
wallet_route?: string;
|
|
30
30
|
wallet_name?: string;
|
|
31
|
-
|
|
31
|
+
wallet_slot?: number;
|
|
32
32
|
};
|
|
33
33
|
export type ScanSettings = {
|
|
34
34
|
wallets: ScanSetting[];
|
|
@@ -101,7 +101,7 @@ export declare function walletSettingsPlusKeys(wallet_settings: ScanSettingOpene
|
|
|
101
101
|
halted?: boolean;
|
|
102
102
|
wallet_route?: string;
|
|
103
103
|
wallet_name?: string;
|
|
104
|
-
|
|
104
|
+
wallet_slot?: number;
|
|
105
105
|
}>;
|
|
106
106
|
export declare function writeWalletToScanSettings(params: WriteScanSettingParams): Promise<number>;
|
|
107
107
|
export declare function openScanSettingsFile(scan_settings_path?: string): Promise<ScanSettings | undefined>;
|
|
@@ -192,7 +192,7 @@ export async function writeWalletToScanSettings(params) {
|
|
|
192
192
|
halted: params.halted,
|
|
193
193
|
wallet_route: params.wallet_route,
|
|
194
194
|
wallet_name: params.wallet_name,
|
|
195
|
-
|
|
195
|
+
wallet_slot: params.wallet_slot,
|
|
196
196
|
},
|
|
197
197
|
],
|
|
198
198
|
node_url: params.node_url,
|
|
@@ -213,7 +213,7 @@ export async function writeWalletToScanSettings(params) {
|
|
|
213
213
|
halted: params.halted,
|
|
214
214
|
wallet_route: params.wallet_route,
|
|
215
215
|
wallet_name: params.wallet_name,
|
|
216
|
-
|
|
216
|
+
wallet_slot: params.wallet_slot,
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
else {
|
|
@@ -225,7 +225,7 @@ export async function writeWalletToScanSettings(params) {
|
|
|
225
225
|
wallet.halted = params.halted || wallet.halted;
|
|
226
226
|
wallet.wallet_route = params.wallet_route || wallet.wallet_route;
|
|
227
227
|
wallet.wallet_name = params.wallet_name || wallet.wallet_name;
|
|
228
|
-
wallet.
|
|
228
|
+
wallet.wallet_slot = params.wallet_slot || wallet.wallet_slot;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
return await atomicWrite(params.scan_settings_path, JSON.stringify(scanSettings, null, 2));
|
|
@@ -21,7 +21,7 @@ export declare class ScanCacheOpened {
|
|
|
21
21
|
readonly view_pair: ViewPair;
|
|
22
22
|
readonly wallet_route: string | undefined;
|
|
23
23
|
readonly wallet_name: string | undefined;
|
|
24
|
-
readonly
|
|
24
|
+
readonly wallet_slot: number | undefined;
|
|
25
25
|
readonly no_worker: boolean;
|
|
26
26
|
readonly masterCacheChanged: CacheChangedCallback | null;
|
|
27
27
|
private _start_height;
|
|
@@ -10,7 +10,7 @@ export class ScanCacheOpened {
|
|
|
10
10
|
view_pair;
|
|
11
11
|
wallet_route;
|
|
12
12
|
wallet_name;
|
|
13
|
-
|
|
13
|
+
wallet_slot;
|
|
14
14
|
no_worker;
|
|
15
15
|
masterCacheChanged;
|
|
16
16
|
_start_height;
|
|
@@ -29,7 +29,7 @@ export class ScanCacheOpened {
|
|
|
29
29
|
// read secret_view_key and secret_spend_key from env
|
|
30
30
|
const walletSettingsWithKeys = await walletSettingsPlusKeys(walletSettings);
|
|
31
31
|
// create viewpair + ScanCacheOpened instance
|
|
32
|
-
const scanCacheOpen = new ScanCacheOpened(await ViewPair.create(params.primary_address, walletSettingsWithKeys.secret_view_key, walletSettings.subaddress_index, walletSettings.node_url), walletSettings.wallet_route, walletSettings.wallet_name, walletSettings.
|
|
32
|
+
const scanCacheOpen = new ScanCacheOpened(await ViewPair.create(params.primary_address, walletSettingsWithKeys.secret_view_key, walletSettings.subaddress_index, walletSettings.node_url), walletSettings.wallet_route, walletSettings.wallet_name, walletSettings.wallet_slot, params.no_worker || false, params.masterCacheChanged || null, walletSettings.start_height, params.scan_settings_path, params.pathPrefix, params.workerError);
|
|
33
33
|
if (theCatchToBeOpened)
|
|
34
34
|
scanCacheOpen._cache = theCatchToBeOpened;
|
|
35
35
|
if (!walletSettings.halted) {
|
|
@@ -522,11 +522,11 @@ export class ScanCacheOpened {
|
|
|
522
522
|
primary_address: "",
|
|
523
523
|
};
|
|
524
524
|
worker = undefined;
|
|
525
|
-
constructor(view_pair, wallet_route, wallet_name,
|
|
525
|
+
constructor(view_pair, wallet_route, wallet_name, wallet_slot, no_worker, masterCacheChanged, _start_height, scan_settings_path, pathPrefix, workerError) {
|
|
526
526
|
this.view_pair = view_pair;
|
|
527
527
|
this.wallet_route = wallet_route;
|
|
528
528
|
this.wallet_name = wallet_name;
|
|
529
|
-
this.
|
|
529
|
+
this.wallet_slot = wallet_slot;
|
|
530
530
|
this.no_worker = no_worker;
|
|
531
531
|
this.masterCacheChanged = masterCacheChanged;
|
|
532
532
|
this._start_height = _start_height;
|
|
@@ -57,5 +57,10 @@ export type ShareViewkeyResult = {
|
|
|
57
57
|
successUrl: string | null;
|
|
58
58
|
};
|
|
59
59
|
export declare function shareViewKey002(payload: ShareViewkeyPayload): Promise<ShareViewkeyResult>;
|
|
60
|
+
export type ShareViewkey002Pruned = {
|
|
61
|
+
viewkey: string;
|
|
62
|
+
primary_address: string;
|
|
63
|
+
wallet_slot: string;
|
|
64
|
+
};
|
|
60
65
|
export declare function potentialSuccessRedirect002(payload: ShareViewkeyPayload): Promise<void>;
|
|
61
|
-
export declare function
|
|
66
|
+
export declare function handle002ShareRequest(req: Request, parsed_cb: (parsed_body: ShareViewkey002Pruned) => Promise<void>, successUrl?: string): Promise<ShareViewkeyResult>;
|
|
@@ -189,6 +189,7 @@ export async function shareViewKey002(payload) {
|
|
|
189
189
|
body: JSON.stringify({
|
|
190
190
|
viewkey: payload.viewkey,
|
|
191
191
|
primary_address: payload.primary_address,
|
|
192
|
+
wallet_slot: invo.tool.payload.wallet_slot,
|
|
192
193
|
}),
|
|
193
194
|
});
|
|
194
195
|
if (result.ok) {
|
|
@@ -213,15 +214,35 @@ export async function shareViewKey002(payload) {
|
|
|
213
214
|
};
|
|
214
215
|
}
|
|
215
216
|
}
|
|
217
|
+
// client wallet side
|
|
216
218
|
export async function potentialSuccessRedirect002(payload) {
|
|
217
219
|
const shareVKresult = await shareViewKey002(payload);
|
|
218
220
|
if (shareVKresult.ok && shareVKresult.successUrl) {
|
|
219
221
|
window.location.href = shareVKresult.successUrl;
|
|
222
|
+
window.location.reload();
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
// backend response
|
|
226
|
+
export async function handle002ShareRequest(req, parsed_cb, successUrl) {
|
|
227
|
+
try {
|
|
228
|
+
const json_body = await req.json();
|
|
229
|
+
const { viewkey, primary_address, wallet_slot } = json_body;
|
|
230
|
+
if (Number.isNaN(parseInt(wallet_slot))) {
|
|
231
|
+
return { ok: false, successUrl: null };
|
|
232
|
+
}
|
|
233
|
+
if (typeof viewkey !== "string" ||
|
|
234
|
+
viewkey.trim().length === 0 ||
|
|
235
|
+
typeof primary_address !== "string" ||
|
|
236
|
+
primary_address.trim().length === 0) {
|
|
237
|
+
return { ok: false, successUrl: null };
|
|
238
|
+
}
|
|
239
|
+
await parsed_cb({ viewkey, primary_address, wallet_slot });
|
|
240
|
+
return {
|
|
241
|
+
ok: true,
|
|
242
|
+
successUrl: successUrl ?? null,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return { ok: false, successUrl: null };
|
|
247
|
+
}
|
|
227
248
|
}
|