@spirobel/monero-wallet-api 0.3.0 → 0.3.2
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/keypairs-seeds/writeKeypairs.d.ts +1 -0
- package/dist/keypairs-seeds/writeKeypairs.js +3 -0
- package/dist/scanning-syncing/scanSettings.d.ts +9 -1
- package/dist/scanning-syncing/scanSettings.js +6 -3
- package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +2 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +6 -2
- package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ export declare function writeStagenetSpendViewKeysToDotEnv(spend_key?: string):
|
|
|
5
5
|
export declare function writeRegtestSpendViewKeysToDotEnvTestLocal(spend_key?: string): Promise<string>;
|
|
6
6
|
export declare function writeTestnetSpendViewKeysToDotEnvLocal(spend_key?: string): Promise<string>;
|
|
7
7
|
export declare function writeWalletSecretsToDotEnv(wallet_secret: Uint8Array): Promise<string>;
|
|
8
|
+
export declare function writeViewKeyToDotEnv(primary_address: string, view_key: string): Promise<void>;
|
|
8
9
|
export declare function writeEnvLineToDotEnvRefresh(key: string, value: string, path?: string): Promise<void>;
|
|
9
10
|
export declare function writeEnvLineToDotEnv(key: string, value: string, path?: string): Promise<void>;
|
|
10
11
|
export declare const STAGENET_FRESH_WALLET_HEIGHT_DEFAULT = 2014841;
|
|
@@ -44,6 +44,9 @@ export async function writeWalletSecretsToDotEnv(wallet_secret) {
|
|
|
44
44
|
await writeEnvLineToDotEnvRefresh(`sk${primary_address}`, spend_key);
|
|
45
45
|
return primary_address;
|
|
46
46
|
}
|
|
47
|
+
export async function writeViewKeyToDotEnv(primary_address, view_key) {
|
|
48
|
+
return await writeEnvLineToDotEnvRefresh(`vk${primary_address}`, view_key);
|
|
49
|
+
}
|
|
47
50
|
// this should be used in a web backend that does (non custodial) scanning
|
|
48
51
|
// to add new view / spend keys, received from the users without a restart.
|
|
49
52
|
export async function writeEnvLineToDotEnvRefresh(key, value, path = ".env") {
|
|
@@ -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[];
|
|
@@ -82,13 +88,15 @@ export declare function readWalletFromScanSettings(primary_address: string, scan
|
|
|
82
88
|
export declare function readWalletsFromScanSettings(scan_settings_path?: string): Promise<ScanSettingOpened[]>;
|
|
83
89
|
export declare function walletSettingsPlusKeys(wallet_settings: ScanSettingOpened, secret_view_key?: string, secret_spend_key?: string): Promise<{
|
|
84
90
|
secret_view_key: string;
|
|
85
|
-
secret_spend_key: string;
|
|
91
|
+
secret_spend_key: string | undefined;
|
|
86
92
|
primary_address: string;
|
|
87
93
|
start_height: number | null;
|
|
88
94
|
node_url: string;
|
|
89
95
|
subaddress_index?: number;
|
|
90
96
|
halted?: boolean;
|
|
91
97
|
wallet_route?: string;
|
|
98
|
+
wallet_name?: string;
|
|
99
|
+
wallet_index?: number;
|
|
92
100
|
}>;
|
|
93
101
|
export declare function writeWalletToScanSettings(params: WriteScanSettingParams): Promise<number>;
|
|
94
102
|
export declare function openScanSettingsFile(scan_settings_path?: string): Promise<ScanSettings | undefined>;
|
|
@@ -154,9 +154,6 @@ export async function walletSettingsPlusKeys(wallet_settings, secret_view_key, s
|
|
|
154
154
|
wallet_settings.primary_address);
|
|
155
155
|
if (!secret_spend_key)
|
|
156
156
|
secret_spend_key = Bun.env[`sk${wallet_settings.primary_address}`];
|
|
157
|
-
if (!secret_spend_key)
|
|
158
|
-
throw ("no secret_spend_key provided and not found in env for address: " +
|
|
159
|
-
wallet_settings.primary_address);
|
|
160
157
|
return {
|
|
161
158
|
...wallet_settings,
|
|
162
159
|
secret_view_key,
|
|
@@ -180,6 +177,8 @@ export async function writeWalletToScanSettings(params) {
|
|
|
180
177
|
subaddress_index: params.subaddress_index || 1,
|
|
181
178
|
halted: params.halted,
|
|
182
179
|
wallet_route: params.wallet_route,
|
|
180
|
+
wallet_name: params.wallet_name,
|
|
181
|
+
wallet_index: params.wallet_index,
|
|
183
182
|
},
|
|
184
183
|
],
|
|
185
184
|
node_url: params.node_url,
|
|
@@ -199,6 +198,8 @@ export async function writeWalletToScanSettings(params) {
|
|
|
199
198
|
subaddress_index: params.subaddress_index || 1,
|
|
200
199
|
halted: params.halted,
|
|
201
200
|
wallet_route: params.wallet_route,
|
|
201
|
+
wallet_name: params.wallet_name,
|
|
202
|
+
wallet_index: params.wallet_index,
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
205
|
else {
|
|
@@ -209,6 +210,8 @@ export async function writeWalletToScanSettings(params) {
|
|
|
209
210
|
params.subaddress_index || wallet.subaddress_index || 1;
|
|
210
211
|
wallet.halted = params.halted || wallet.halted;
|
|
211
212
|
wallet.wallet_route = params.wallet_route || wallet.wallet_route;
|
|
213
|
+
wallet.wallet_name = params.wallet_name || wallet.wallet_name;
|
|
214
|
+
wallet.wallet_index = params.wallet_index || wallet.wallet_index;
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
217
|
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;
|