@spirobel/monero-wallet-api 0.5.0 → 0.5.1
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.
|
@@ -71,21 +71,21 @@ export type ScanSettingsOpened = {
|
|
|
71
71
|
* ```
|
|
72
72
|
*
|
|
73
73
|
* @param scan_settings - The complete {@link ScanSettings} configuration to persist.
|
|
74
|
-
* @param
|
|
74
|
+
* @param scan_settings_path - Optional path for the settings file. Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
75
75
|
* @returns A promise that resolves when the file is successfully written.
|
|
76
76
|
* @throws Will throw if file writing fails (e.g., permissions, disk space).
|
|
77
77
|
*/
|
|
78
|
-
export declare function writeScanSettings(scan_settings: ScanSettings,
|
|
78
|
+
export declare function writeScanSettings(scan_settings: ScanSettings, scan_settings_path?: string): Promise<number>;
|
|
79
79
|
export type WriteScanSettingsFileParams = {
|
|
80
|
-
|
|
80
|
+
scan_settings_path?: string;
|
|
81
81
|
writeCallback: (settings: ScanSettings) => void | Promise<void>;
|
|
82
82
|
};
|
|
83
83
|
export declare function writeScanSettingsFileDefaultLocation(params: WriteScanSettingsFileParams): Promise<void>;
|
|
84
|
-
export declare function writeStartHeightToScanSettings(start_height: number | null,
|
|
85
|
-
export declare function writeDaemonHeightAsStartHeightToScanSettings(node_url: string,
|
|
86
|
-
export declare function cullTooLargeScanHeight(node_url: string,
|
|
87
|
-
export declare function writeNodeUrlToScanSettings(node_url: string,
|
|
88
|
-
export declare function readNodeUrlFromScanSettings(
|
|
84
|
+
export declare function writeStartHeightToScanSettings(start_height: number | null, scan_settings_path?: string): Promise<number>;
|
|
85
|
+
export declare function writeDaemonHeightAsStartHeightToScanSettings(node_url: string, scan_settings_path?: string): Promise<number>;
|
|
86
|
+
export declare function cullTooLargeScanHeight(node_url: string, scan_settings_path?: string): Promise<number>;
|
|
87
|
+
export declare function writeNodeUrlToScanSettings(node_url: string, scan_settings_path?: string): Promise<number>;
|
|
88
|
+
export declare function readNodeUrlFromScanSettings(scan_settings_path?: string): Promise<string | undefined>;
|
|
89
89
|
/**
|
|
90
90
|
* Writes the merchant confirmation threshold to scan settings.
|
|
91
91
|
*
|
|
@@ -97,11 +97,11 @@ export declare function readNodeUrlFromScanSettings(settingsStorePath?: string):
|
|
|
97
97
|
*
|
|
98
98
|
* @param merchant_confirmations - Number of confirmations required before
|
|
99
99
|
* accepting a payment, or `null` to leave it unset.
|
|
100
|
-
* @param
|
|
100
|
+
* @param scan_settings_path - Optional path for the settings file.
|
|
101
101
|
* Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
102
102
|
* @returns A promise that resolves when the file is successfully written.
|
|
103
103
|
*/
|
|
104
|
-
export declare function writeMerchantConfirmationsToScanSettings(merchant_confirmations: number | null,
|
|
104
|
+
export declare function writeMerchantConfirmationsToScanSettings(merchant_confirmations: number | null, scan_settings_path?: string): Promise<number>;
|
|
105
105
|
/**
|
|
106
106
|
* Reads the merchant confirmation threshold from scan settings.
|
|
107
107
|
*
|
|
@@ -112,12 +112,12 @@ export declare function writeMerchantConfirmationsToScanSettings(merchant_confir
|
|
|
112
112
|
* for a payment. The actual enforcement of this policy is left to the
|
|
113
113
|
* custom payment-system code that consumes this library.
|
|
114
114
|
*
|
|
115
|
-
* @param
|
|
115
|
+
* @param scan_settings_path - Optional path for the settings file.
|
|
116
116
|
* Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
117
117
|
* @returns The configured number of confirmations, null, or `undefined`
|
|
118
118
|
* if the setting has not been persisted yet.
|
|
119
119
|
*/
|
|
120
|
-
export declare function readMerchantConfirmationsFromScanSettings(
|
|
120
|
+
export declare function readMerchantConfirmationsFromScanSettings(scan_settings_path?: string): Promise<number | null | undefined>;
|
|
121
121
|
/**
|
|
122
122
|
* Reads scan settings from the default or specified storage file.
|
|
123
123
|
* secret_view_key and spend_private_key are read from environment variables
|
|
@@ -130,7 +130,7 @@ export declare function readMerchantConfirmationsFromScanSettings(settingsStoreP
|
|
|
130
130
|
* }
|
|
131
131
|
* ```
|
|
132
132
|
*
|
|
133
|
-
* @param
|
|
133
|
+
* @param scan_settings_path - Path to the settings file. Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
134
134
|
* @returns The parsed {@link ScanSettings} object if file exists and is valid JSON, otherwise `undefined`.
|
|
135
135
|
*/
|
|
136
136
|
export declare function readScanSettings(scan_settings_path?: string): Promise<ScanSettingsOpened | undefined>;
|
|
@@ -23,15 +23,15 @@ export const SUB_ADDRESS_INDEX_DEFAULT_VALUE = 1;
|
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
25
|
* @param scan_settings - The complete {@link ScanSettings} configuration to persist.
|
|
26
|
-
* @param
|
|
26
|
+
* @param scan_settings_path - Optional path for the settings file. Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
27
27
|
* @returns A promise that resolves when the file is successfully written.
|
|
28
28
|
* @throws Will throw if file writing fails (e.g., permissions, disk space).
|
|
29
29
|
*/
|
|
30
|
-
export async function writeScanSettings(scan_settings,
|
|
31
|
-
return await atomicWrite(
|
|
30
|
+
export async function writeScanSettings(scan_settings, scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
31
|
+
return await atomicWrite(scan_settings_path, JSON.stringify(scan_settings, null, 2));
|
|
32
32
|
}
|
|
33
33
|
export async function writeScanSettingsFileDefaultLocation(params) {
|
|
34
|
-
let settings = await openScanSettingsFile(params.
|
|
34
|
+
let settings = await openScanSettingsFile(params.scan_settings_path);
|
|
35
35
|
if (!settings) {
|
|
36
36
|
// Create empty ScanSettings object with default values
|
|
37
37
|
settings = {
|
|
@@ -42,10 +42,10 @@ export async function writeScanSettingsFileDefaultLocation(params) {
|
|
|
42
42
|
}
|
|
43
43
|
await params.writeCallback(settings);
|
|
44
44
|
// write to settings file
|
|
45
|
-
await writeScanSettings(settings, params.
|
|
45
|
+
await writeScanSettings(settings, params.scan_settings_path);
|
|
46
46
|
}
|
|
47
|
-
export async function writeStartHeightToScanSettings(start_height,
|
|
48
|
-
const scanSettings = (await openScanSettingsFile(
|
|
47
|
+
export async function writeStartHeightToScanSettings(start_height, scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
48
|
+
const scanSettings = (await openScanSettingsFile(scan_settings_path)) || {
|
|
49
49
|
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
50
50
|
wallets: [],
|
|
51
51
|
start_height: null,
|
|
@@ -53,20 +53,20 @@ export async function writeStartHeightToScanSettings(start_height, settingsStore
|
|
|
53
53
|
scanSettings.start_height = start_height;
|
|
54
54
|
return await atomicWrite(SCAN_SETTINGS_STORE_NAME_DEFAULT, JSON.stringify(scanSettings, null, 2));
|
|
55
55
|
}
|
|
56
|
-
export async function writeDaemonHeightAsStartHeightToScanSettings(node_url,
|
|
56
|
+
export async function writeDaemonHeightAsStartHeightToScanSettings(node_url, scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
57
57
|
const getInfo = await get_info(node_url);
|
|
58
|
-
const scanSettings = (await openScanSettingsFile(
|
|
58
|
+
const scanSettings = (await openScanSettingsFile(scan_settings_path)) || {
|
|
59
59
|
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
60
60
|
wallets: [],
|
|
61
61
|
start_height: null,
|
|
62
62
|
};
|
|
63
63
|
scanSettings.start_height = getInfo.height - 1;
|
|
64
|
-
await atomicWrite(
|
|
64
|
+
await atomicWrite(scan_settings_path, JSON.stringify(scanSettings, null, 2));
|
|
65
65
|
return getInfo.height;
|
|
66
66
|
}
|
|
67
|
-
export async function cullTooLargeScanHeight(node_url,
|
|
67
|
+
export async function cullTooLargeScanHeight(node_url, scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
68
68
|
const getInfo = await get_info(node_url);
|
|
69
|
-
const scanSettings = (await openScanSettingsFile(
|
|
69
|
+
const scanSettings = (await openScanSettingsFile(scan_settings_path)) || {
|
|
70
70
|
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
71
71
|
wallets: [],
|
|
72
72
|
start_height: null,
|
|
@@ -74,21 +74,21 @@ export async function cullTooLargeScanHeight(node_url, settingsStorePath = SCAN_
|
|
|
74
74
|
if (scanSettings.start_height === null ||
|
|
75
75
|
scanSettings.start_height > getInfo.height - 1) {
|
|
76
76
|
scanSettings.start_height = getInfo.height - 1;
|
|
77
|
-
await atomicWrite(
|
|
77
|
+
await atomicWrite(scan_settings_path, JSON.stringify(scanSettings, null, 2));
|
|
78
78
|
}
|
|
79
79
|
return scanSettings.start_height;
|
|
80
80
|
}
|
|
81
|
-
export async function writeNodeUrlToScanSettings(node_url,
|
|
82
|
-
const scanSettings = (await openScanSettingsFile(
|
|
81
|
+
export async function writeNodeUrlToScanSettings(node_url, scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
82
|
+
const scanSettings = (await openScanSettingsFile(scan_settings_path)) || {
|
|
83
83
|
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
84
84
|
wallets: [],
|
|
85
85
|
start_height: null,
|
|
86
86
|
};
|
|
87
87
|
scanSettings.node_url = node_url;
|
|
88
|
-
return await atomicWrite(
|
|
88
|
+
return await atomicWrite(scan_settings_path, JSON.stringify(scanSettings, null, 2));
|
|
89
89
|
}
|
|
90
|
-
export async function readNodeUrlFromScanSettings(
|
|
91
|
-
const scanSettings = await openScanSettingsFile(
|
|
90
|
+
export async function readNodeUrlFromScanSettings(scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
91
|
+
const scanSettings = await openScanSettingsFile(scan_settings_path);
|
|
92
92
|
return scanSettings?.node_url;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -102,18 +102,18 @@ export async function readNodeUrlFromScanSettings(settingsStorePath = SCAN_SETTI
|
|
|
102
102
|
*
|
|
103
103
|
* @param merchant_confirmations - Number of confirmations required before
|
|
104
104
|
* accepting a payment, or `null` to leave it unset.
|
|
105
|
-
* @param
|
|
105
|
+
* @param scan_settings_path - Optional path for the settings file.
|
|
106
106
|
* Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
107
107
|
* @returns A promise that resolves when the file is successfully written.
|
|
108
108
|
*/
|
|
109
|
-
export async function writeMerchantConfirmationsToScanSettings(merchant_confirmations,
|
|
110
|
-
const scanSettings = (await openScanSettingsFile(
|
|
109
|
+
export async function writeMerchantConfirmationsToScanSettings(merchant_confirmations, scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
110
|
+
const scanSettings = (await openScanSettingsFile(scan_settings_path)) || {
|
|
111
111
|
node_url: LOCAL_NODE_DEFAULT_URL,
|
|
112
112
|
wallets: [],
|
|
113
113
|
start_height: null,
|
|
114
114
|
};
|
|
115
115
|
scanSettings.merchant_confirmations = merchant_confirmations;
|
|
116
|
-
return await atomicWrite(
|
|
116
|
+
return await atomicWrite(scan_settings_path, JSON.stringify(scanSettings, null, 2));
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Reads the merchant confirmation threshold from scan settings.
|
|
@@ -125,13 +125,13 @@ export async function writeMerchantConfirmationsToScanSettings(merchant_confirma
|
|
|
125
125
|
* for a payment. The actual enforcement of this policy is left to the
|
|
126
126
|
* custom payment-system code that consumes this library.
|
|
127
127
|
*
|
|
128
|
-
* @param
|
|
128
|
+
* @param scan_settings_path - Optional path for the settings file.
|
|
129
129
|
* Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
130
130
|
* @returns The configured number of confirmations, null, or `undefined`
|
|
131
131
|
* if the setting has not been persisted yet.
|
|
132
132
|
*/
|
|
133
|
-
export async function readMerchantConfirmationsFromScanSettings(
|
|
134
|
-
const scanSettings = await openScanSettingsFile(
|
|
133
|
+
export async function readMerchantConfirmationsFromScanSettings(scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|
|
134
|
+
const scanSettings = await openScanSettingsFile(scan_settings_path);
|
|
135
135
|
return scanSettings?.merchant_confirmations;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
@@ -146,7 +146,7 @@ export async function readMerchantConfirmationsFromScanSettings(settingsStorePat
|
|
|
146
146
|
* }
|
|
147
147
|
* ```
|
|
148
148
|
*
|
|
149
|
-
* @param
|
|
149
|
+
* @param scan_settings_path - Path to the settings file. Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
|
|
150
150
|
* @returns The parsed {@link ScanSettings} object if file exists and is valid JSON, otherwise `undefined`.
|
|
151
151
|
*/
|
|
152
152
|
export async function readScanSettings(scan_settings_path = SCAN_SETTINGS_STORE_NAME_DEFAULT) {
|