@spirobel/monero-wallet-api 0.3.1 → 0.3.3
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.
|
@@ -4,6 +4,8 @@ export type ScanSetting = {
|
|
|
4
4
|
subaddress_index?: number;
|
|
5
5
|
halted?: boolean;
|
|
6
6
|
wallet_route?: string;
|
|
7
|
+
wallet_name?: string;
|
|
8
|
+
wallet_index?: number;
|
|
7
9
|
};
|
|
8
10
|
export type WriteScanSettingParams = {
|
|
9
11
|
primary_address: string;
|
|
@@ -13,6 +15,8 @@ export type WriteScanSettingParams = {
|
|
|
13
15
|
scan_settings_path?: string;
|
|
14
16
|
node_url?: string;
|
|
15
17
|
wallet_route?: string;
|
|
18
|
+
wallet_name?: string;
|
|
19
|
+
wallet_index?: number;
|
|
16
20
|
};
|
|
17
21
|
export type ScanSettingOpened = {
|
|
18
22
|
primary_address: string;
|
|
@@ -23,6 +27,8 @@ export type ScanSettingOpened = {
|
|
|
23
27
|
halted?: boolean;
|
|
24
28
|
secret_spend_key?: string;
|
|
25
29
|
wallet_route?: string;
|
|
30
|
+
wallet_name?: string;
|
|
31
|
+
wallet_index?: number;
|
|
26
32
|
};
|
|
27
33
|
export type ScanSettings = {
|
|
28
34
|
wallets: ScanSetting[];
|
|
@@ -55,6 +61,11 @@ export type ScanSettingsOpened = {
|
|
|
55
61
|
* @throws Will throw if file writing fails (e.g., permissions, disk space).
|
|
56
62
|
*/
|
|
57
63
|
export declare function writeScanSettings(scan_settings: ScanSettings, settingsStorePath?: string): Promise<number>;
|
|
64
|
+
export type WriteScanSettingsFileParams = {
|
|
65
|
+
settingsStorePath?: string;
|
|
66
|
+
writeCallback: (settings: ScanSettings) => void | Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
export declare function writeScanSettingsFileDefaultLocationThrows(params: WriteScanSettingsFileParams): Promise<void>;
|
|
58
69
|
export declare function writeStartHeightToScanSettings(start_height: number | null, settingsStorePath?: string): Promise<number>;
|
|
59
70
|
export declare function writeDaemonHeightAsStartHeightToScanSettings(node_url: string, settingsStorePath?: string): Promise<number>;
|
|
60
71
|
export declare function cullTooLargeScanHeight(node_url: string, settingsStorePath?: string): Promise<number>;
|
|
@@ -89,6 +100,8 @@ export declare function walletSettingsPlusKeys(wallet_settings: ScanSettingOpene
|
|
|
89
100
|
subaddress_index?: number;
|
|
90
101
|
halted?: boolean;
|
|
91
102
|
wallet_route?: string;
|
|
103
|
+
wallet_name?: string;
|
|
104
|
+
wallet_index?: number;
|
|
92
105
|
}>;
|
|
93
106
|
export declare function writeWalletToScanSettings(params: WriteScanSettingParams): Promise<number>;
|
|
94
107
|
export declare function openScanSettingsFile(scan_settings_path?: string): Promise<ScanSettings | undefined>;
|
|
@@ -26,6 +26,20 @@ export const SCAN_SETTINGS_STORE_NAME_DEFAULT = "ScanSettings.json";
|
|
|
26
26
|
export async function writeScanSettings(scan_settings, settingsStorePath = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
27
27
|
return await atomicWrite(settingsStorePath, JSON.stringify(scan_settings, null, 2));
|
|
28
28
|
}
|
|
29
|
+
export async function writeScanSettingsFileDefaultLocationThrows(params) {
|
|
30
|
+
let settings = await openScanSettingsFile(params.settingsStorePath);
|
|
31
|
+
if (!settings) {
|
|
32
|
+
// Create empty ScanSettings object with default values
|
|
33
|
+
settings = {
|
|
34
|
+
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
35
|
+
wallets: [],
|
|
36
|
+
start_height: null,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
await params.writeCallback(settings);
|
|
40
|
+
// write to settings file
|
|
41
|
+
await writeScanSettings(settings, params.settingsStorePath);
|
|
42
|
+
}
|
|
29
43
|
export async function writeStartHeightToScanSettings(start_height, settingsStorePath = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
30
44
|
const scanSettings = (await openScanSettingsFile(settingsStorePath)) || {
|
|
31
45
|
node_url: "",
|
|
@@ -177,6 +191,8 @@ export async function writeWalletToScanSettings(params) {
|
|
|
177
191
|
subaddress_index: params.subaddress_index || 1,
|
|
178
192
|
halted: params.halted,
|
|
179
193
|
wallet_route: params.wallet_route,
|
|
194
|
+
wallet_name: params.wallet_name,
|
|
195
|
+
wallet_index: params.wallet_index,
|
|
180
196
|
},
|
|
181
197
|
],
|
|
182
198
|
node_url: params.node_url,
|
|
@@ -196,6 +212,8 @@ export async function writeWalletToScanSettings(params) {
|
|
|
196
212
|
subaddress_index: params.subaddress_index || 1,
|
|
197
213
|
halted: params.halted,
|
|
198
214
|
wallet_route: params.wallet_route,
|
|
215
|
+
wallet_name: params.wallet_name,
|
|
216
|
+
wallet_index: params.wallet_index,
|
|
199
217
|
});
|
|
200
218
|
}
|
|
201
219
|
else {
|
|
@@ -206,6 +224,8 @@ export async function writeWalletToScanSettings(params) {
|
|
|
206
224
|
params.subaddress_index || wallet.subaddress_index || 1;
|
|
207
225
|
wallet.halted = params.halted || wallet.halted;
|
|
208
226
|
wallet.wallet_route = params.wallet_route || wallet.wallet_route;
|
|
227
|
+
wallet.wallet_name = params.wallet_name || wallet.wallet_name;
|
|
228
|
+
wallet.wallet_index = params.wallet_index || wallet.wallet_index;
|
|
209
229
|
}
|
|
210
230
|
}
|
|
211
231
|
return await atomicWrite(params.scan_settings_path, JSON.stringify(scanSettings, null, 2));
|
|
@@ -20,6 +20,8 @@ export type CreateTransactionParams = {
|
|
|
20
20
|
export declare class ScanCacheOpened {
|
|
21
21
|
readonly view_pair: ViewPair;
|
|
22
22
|
readonly wallet_route: string | undefined;
|
|
23
|
+
readonly wallet_name: string | undefined;
|
|
24
|
+
readonly wallet_index: number | undefined;
|
|
23
25
|
readonly no_worker: boolean;
|
|
24
26
|
readonly masterCacheChanged: CacheChangedCallback | null;
|
|
25
27
|
private _start_height;
|
|
@@ -9,6 +9,8 @@ import { readWriteConnectionStatusFile, } from "../connectionStatus";
|
|
|
9
9
|
export class ScanCacheOpened {
|
|
10
10
|
view_pair;
|
|
11
11
|
wallet_route;
|
|
12
|
+
wallet_name;
|
|
13
|
+
wallet_index;
|
|
12
14
|
no_worker;
|
|
13
15
|
masterCacheChanged;
|
|
14
16
|
_start_height;
|
|
@@ -27,7 +29,7 @@ export class ScanCacheOpened {
|
|
|
27
29
|
// read secret_view_key and secret_spend_key from env
|
|
28
30
|
const walletSettingsWithKeys = await walletSettingsPlusKeys(walletSettings);
|
|
29
31
|
// create viewpair + ScanCacheOpened instance
|
|
30
|
-
const scanCacheOpen = new ScanCacheOpened(await ViewPair.create(params.primary_address, walletSettingsWithKeys.secret_view_key, walletSettings.subaddress_index, walletSettings.node_url), walletSettings.wallet_route, params.no_worker || false, params.masterCacheChanged || null, walletSettings.start_height, params.scan_settings_path, params.pathPrefix, params.workerError);
|
|
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_index, params.no_worker || false, params.masterCacheChanged || null, walletSettings.start_height, params.scan_settings_path, params.pathPrefix, params.workerError);
|
|
31
33
|
if (theCatchToBeOpened)
|
|
32
34
|
scanCacheOpen._cache = theCatchToBeOpened;
|
|
33
35
|
if (!walletSettings.halted) {
|
|
@@ -520,9 +522,11 @@ export class ScanCacheOpened {
|
|
|
520
522
|
primary_address: "",
|
|
521
523
|
};
|
|
522
524
|
worker = undefined;
|
|
523
|
-
constructor(view_pair, wallet_route, no_worker, masterCacheChanged, _start_height, scan_settings_path, pathPrefix, workerError) {
|
|
525
|
+
constructor(view_pair, wallet_route, wallet_name, wallet_index, no_worker, masterCacheChanged, _start_height, scan_settings_path, pathPrefix, workerError) {
|
|
524
526
|
this.view_pair = view_pair;
|
|
525
527
|
this.wallet_route = wallet_route;
|
|
528
|
+
this.wallet_name = wallet_name;
|
|
529
|
+
this.wallet_index = wallet_index;
|
|
526
530
|
this.no_worker = no_worker;
|
|
527
531
|
this.masterCacheChanged = masterCacheChanged;
|
|
528
532
|
this._start_height = _start_height;
|