@spirobel/monero-wallet-api 0.6.0 → 0.6.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.
Files changed (108) hide show
  1. package/README.md +40 -4
  2. package/dist/frost_dkg.wasm +0 -0
  3. package/dist/io/logging.js +1 -1
  4. package/dist/keypairs-seeds/keypairs.js +5 -5
  5. package/dist/monero_wallet_api.wasm +0 -0
  6. package/dist/multisig/DistributedKeyGenerator.js +3 -3
  7. package/dist/multisig/MultiSigTxSigner.js +2 -2
  8. package/dist/multisig/escrow.js +1 -1
  9. package/dist/multisig/multisig.js +4 -0
  10. package/dist/node-interaction/binaryEndpoints.d.ts +3 -3
  11. package/dist/node-interaction/nodeUrl.js +2 -2
  12. package/dist/scanning-syncing/backgroundWorker.d.ts +3 -0
  13. package/dist/scanning-syncing/backgroundWorker.js +38 -8
  14. package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.d.ts +1 -1
  15. package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.js +1 -1
  16. package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.d.ts +1 -1
  17. package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +1 -1
  18. package/dist/scanning-syncing/connectionStatus.d.ts +1 -1
  19. package/dist/scanning-syncing/connectionStatus.js +2 -2
  20. package/dist/scanning-syncing/openWallet.js +1 -1
  21. package/dist/scanning-syncing/scanresult/computeKeyImage.d.ts +1 -1
  22. package/dist/scanning-syncing/scanresult/computeKeyImage.js +2 -2
  23. package/dist/scanning-syncing/scanresult/scanCache.d.ts +1 -1
  24. package/dist/scanning-syncing/scanresult/scanCache.js +1 -1
  25. package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +1 -1
  26. package/dist/scanning-syncing/scanresult/scanCacheOpened.js +11 -8
  27. package/dist/scanning-syncing/scanresult/scanCoordination.d.ts +2 -2
  28. package/dist/scanning-syncing/scanresult/scanCoordination.js +2 -2
  29. package/dist/scanning-syncing/scanresult/scanLoop.d.ts +1 -1
  30. package/dist/scanning-syncing/scanresult/scanLoop.js +1 -1
  31. package/dist/scanning-syncing/scanresult/scanResult.d.ts +1 -1
  32. package/dist/scanning-syncing/scanresult/scanResult.js +3 -3
  33. package/dist/scanning-syncing/scanresult/scanStats.d.ts +1 -1
  34. package/dist/scanning-syncing/scanresult/scanStats.js +1 -2
  35. package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
  36. package/dist/scanning-syncing/worker-mains/cpubound-main.js +1 -1
  37. package/dist/scanning-syncing/worker-mains/multisig-main.d.ts +1 -1
  38. package/dist/scanning-syncing/worker-mains/multisig-main.js +1 -1
  39. package/dist/scanning-syncing/worker-mains/worker.js +9 -1
  40. package/dist/scansettings/scanSettings.js +1 -1
  41. package/dist/scansettings/scanSettingsOpened.d.ts +1 -1
  42. package/dist/scansettings/scanSettingsOpened.js +1 -1
  43. package/dist/send-functionality/inputSelection.d.ts +1 -1
  44. package/dist/send-functionality/transactionBuilding.d.ts +1 -1
  45. package/dist/send-functionality/transactionBuilding.js +3 -3
  46. package/dist/tools/content.js +1 -1
  47. package/dist/viewpair/ViewPair.d.ts +4 -4
  48. package/dist/viewpair/ViewPair.js +4 -4
  49. package/dist/wasm-processing/wasmLoader.d.ts +10 -0
  50. package/dist/wasm-processing/wasmLoader.js +108 -0
  51. package/dist/worker_unpacked.js +14055 -0
  52. package/dist/xmr3.d.ts +1 -0
  53. package/dist/xmr3.js +10 -0
  54. package/dist/{api.d.ts → xmr3_common.d.ts} +1 -1
  55. package/dist/{api.js → xmr3_common.js} +1 -1
  56. package/dist/xmr3_unpacked.d.ts +9 -0
  57. package/dist/xmr3_unpacked.js +14 -0
  58. package/package.json +14 -7
  59. package/dist/actionlog/actionLog.d.ts +0 -4
  60. package/dist/actionlog/actionLog.js +0 -9
  61. package/dist/actionlog/backend/jsonlBackend.d.ts +0 -19
  62. package/dist/actionlog/backend/jsonlBackend.js +0 -110
  63. package/dist/actionlog/backend/memoryBackend.d.ts +0 -11
  64. package/dist/actionlog/backend/memoryBackend.js +0 -31
  65. package/dist/actionlog/backend.d.ts +0 -12
  66. package/dist/actionlog/backend.js +0 -1
  67. package/dist/actionlog/idbBackend.d.ts +0 -19
  68. package/dist/actionlog/idbBackend.js +0 -98
  69. package/dist/actionlog/jsonlBackend.d.ts +0 -19
  70. package/dist/actionlog/jsonlBackend.js +0 -75
  71. package/dist/actionlog/memoryBackend.d.ts +0 -14
  72. package/dist/actionlog/memoryBackend.js +0 -38
  73. package/dist/actionlog/openMaps.d.ts +0 -11
  74. package/dist/actionlog/openMaps.js +0 -32
  75. package/dist/actionlog/sqliteBackend.d.ts +0 -18
  76. package/dist/actionlog/sqliteBackend.js +0 -105
  77. package/dist/actionlog/toolContext.d.ts +0 -36
  78. package/dist/actionlog/toolContext.js +0 -1
  79. package/dist/actionlog/types.d.ts +0 -62
  80. package/dist/actionlog/types.js +0 -62
  81. package/dist/scanning-syncing/blocksbuffer/getBlocksbinBuffer.d.ts +0 -28
  82. package/dist/scanning-syncing/blocksbuffer/getBlocksbinBuffer.js +0 -54
  83. package/dist/scanning-syncing/scanSettings.d.ts +0 -165
  84. package/dist/scanning-syncing/scanSettings.js +0 -338
  85. package/dist/scanning-syncing/scanresult/reorg.d.ts +0 -3
  86. package/dist/scanning-syncing/scanresult/reorg.js +0 -101
  87. package/dist/scanning-syncing/scansettings/scanSettings.d.ts +0 -165
  88. package/dist/scanning-syncing/scansettings/scanSettings.js +0 -338
  89. package/dist/send-functionality/multisig.d.ts +0 -72
  90. package/dist/send-functionality/multisig.js +0 -97
  91. package/dist/tools/calls/002-content.d.ts +0 -46
  92. package/dist/tools/calls/002-content.js +0 -135
  93. package/dist/tools/calls/002-fail-cleanup.d.ts +0 -27
  94. package/dist/tools/calls/002-fail-cleanup.js +0 -60
  95. package/dist/tools/counterparty.d.ts +0 -3
  96. package/dist/tools/counterparty.js +0 -1
  97. package/dist/tools/monero-tools-content.d.ts +0 -29
  98. package/dist/tools/monero-tools-content.js +0 -80
  99. package/dist/tools/runtimeMessages.d.ts +0 -4
  100. package/dist/tools/runtimeMessages.js +0 -18
  101. package/dist/tools/toolActionLogContext.d.ts +0 -33
  102. package/dist/tools/toolActionLogContext.js +0 -1
  103. package/dist/tools/toolArm.d.ts +0 -47
  104. package/dist/tools/toolArm.js +0 -1
  105. package/dist/tools/ui.d.ts +0 -2
  106. package/dist/tools/ui.js +0 -1
  107. package/dist/tools/worker.d.ts +0 -1
  108. package/dist/tools/worker.js +0 -1
@@ -1,105 +0,0 @@
1
- import { OpenInvocationMaps } from "./openMaps";
2
- /** bun-only sqlite backend. do not import from browser worker graphs. */
3
- export class ActionLogSqliteBackend {
4
- open = new OpenInvocationMaps();
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- sql;
7
- constructor(sql) {
8
- this.sql = sql;
9
- }
10
- static async open(filename) {
11
- const { SQL } = await import("bun");
12
- const sql = new SQL({
13
- adapter: "sqlite",
14
- filename,
15
- create: true,
16
- });
17
- await sql `PRAGMA journal_mode = WAL`;
18
- await sql `
19
- CREATE TABLE IF NOT EXISTS actionlog_events (
20
- id TEXT PRIMARY KEY,
21
- timestamp TEXT NOT NULL,
22
- invocationId TEXT NOT NULL,
23
- stage TEXT NOT NULL,
24
- type TEXT NOT NULL,
25
- toolId TEXT NOT NULL,
26
- body TEXT NOT NULL
27
- )
28
- `;
29
- await sql `
30
- CREATE INDEX IF NOT EXISTS idx_actionlog_invocation
31
- ON actionlog_events (invocationId)
32
- `;
33
- await sql `
34
- CREATE INDEX IF NOT EXISTS idx_actionlog_tool
35
- ON actionlog_events (toolId)
36
- `;
37
- await sql `
38
- CREATE INDEX IF NOT EXISTS idx_actionlog_invocation_ts
39
- ON actionlog_events (invocationId, timestamp)
40
- `;
41
- const backend = new ActionLogSqliteBackend(sql);
42
- await backend.rebuildOpenMaps();
43
- return backend;
44
- }
45
- async rebuildOpenMaps() {
46
- this.open.clear();
47
- const rows = (await this.sql `
48
- SELECT body FROM actionlog_events ORDER BY rowid ASC
49
- `);
50
- if (!Array.isArray(rows))
51
- return;
52
- for (const row of rows) {
53
- this.open.apply(JSON.parse(row.body));
54
- }
55
- }
56
- async append(event) {
57
- const body = JSON.stringify(event);
58
- await this.sql `
59
- INSERT INTO actionlog_events (id, timestamp, invocationId, stage, type, toolId, body)
60
- VALUES (
61
- ${event.id},
62
- ${event.timestamp},
63
- ${event.invocationId},
64
- ${event.stage},
65
- ${event.type},
66
- ${event.toolId},
67
- ${body}
68
- )
69
- `;
70
- this.open.apply(event);
71
- }
72
- async getBranch(invocationId) {
73
- const rows = (await this.sql `
74
- SELECT body FROM actionlog_events
75
- WHERE invocationId = ${invocationId}
76
- ORDER BY rowid ASC
77
- `);
78
- if (!Array.isArray(rows))
79
- return [];
80
- return rows.map((r) => JSON.parse(r.body));
81
- }
82
- async getTip(invocationId) {
83
- const branch = await this.getBranch(invocationId);
84
- return branch.length ? branch[branch.length - 1] : null;
85
- }
86
- async getOpenByToolId(toolId) {
87
- return this.open.getOpenByToolId(toolId);
88
- }
89
- async getOpenInvocations() {
90
- return this.open.getOpenInvocations();
91
- }
92
- async feed(events) {
93
- for (const event of events) {
94
- try {
95
- await this.append(event);
96
- }
97
- catch {
98
- // skip duplicate
99
- }
100
- }
101
- }
102
- async reload() {
103
- await this.rebuildOpenMaps();
104
- }
105
- }
@@ -1,36 +0,0 @@
1
- import type { ActionLogEvent, ActionLogOpened } from "./actionLogOpened";
2
- import type { ToolPermission } from "./types";
3
- /** durable plate notice — title/message are tool-owned STE text */
4
- export type ToolNotice = {
5
- id: string;
6
- permission: ToolPermission;
7
- /** short STE title for the notice plate hole */
8
- title: string;
9
- /** full STE body for the notice plate hole */
10
- message: string;
11
- context_domain?: string;
12
- context_href?: string;
13
- wallet_slot?: number;
14
- timestamp?: number | string;
15
- };
16
- /** static STE strings for open-invocation plate holes */
17
- export type ToolUiCopy = {
18
- openTitle: string;
19
- acceptLabel?: string;
20
- dismissLabel?: string;
21
- };
22
- /**
23
- * context ActionLog passes into per-tool actionlog writers.
24
- * lives next to ActionLog — tools import this, not the other way around for placement.
25
- */
26
- export type ToolActionLogContext = {
27
- log: ActionLogOpened;
28
- getWallets?: () => unknown;
29
- /** host reopens wallets after tool changes scan settings */
30
- reloadWallets?: () => void | Promise<void>;
31
- getPort: (invocationId: string) => {
32
- postMessage: (msg: unknown) => void;
33
- } | undefined;
34
- postToPort: (invocationId: string, msg: unknown) => void;
35
- broadcast: (events: ActionLogEvent[]) => void;
36
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,62 +0,0 @@
1
- import type { ToolId } from "../tools/monero-tools";
2
- import type { ExtensionPort, ToolInvocationValidity, ToolPermission } from "../tools/globals";
3
- import type { ActionLogOpened } from "./actionLogOpened";
4
- export type { ToolPermission };
5
- export type ActionLogEventType = "session_start" | "validate_start" | "validate_result" | "accept" | "dismiss" | "execute_start" | "execute_error" | "execute_result" | "aborted";
6
- export type ActionLogStage = "recognized" | "invoked" | "validated" | "accepted" | "executed";
7
- export type ActionLogEvent = {
8
- type: ActionLogEventType;
9
- id: string;
10
- timestamp: string;
11
- invocationId: string;
12
- stage: ActionLogStage;
13
- toolId: ToolId;
14
- valid?: ToolInvocationValidity;
15
- amount?: string;
16
- address?: string;
17
- no_check?: boolean;
18
- wallet_slot?: number;
19
- context_domain?: string;
20
- destination_domain?: string;
21
- context_href?: string;
22
- found_in?: "link" | "linkText";
23
- link?: string;
24
- linkText?: string;
25
- wallet_to_send_from_pa?: string;
26
- ok?: boolean;
27
- error?: string;
28
- [key: string]: unknown;
29
- };
30
- export type OpenInvocationState = {
31
- invocationId: string;
32
- toolId: ToolId;
33
- stage: ActionLogStage;
34
- lastType: ActionLogEventType;
35
- valid?: ToolInvocationValidity;
36
- amount?: string;
37
- address?: string;
38
- no_check?: boolean;
39
- wallet_slot?: number;
40
- context_domain?: string;
41
- destination_domain?: string;
42
- context_href?: string;
43
- found_in?: "link" | "linkText";
44
- link?: string;
45
- linkText?: string;
46
- timestamp?: string;
47
- wallet_to_send_from_pa?: string;
48
- ok?: boolean;
49
- error?: string;
50
- };
51
- export declare const TERMINAL_EVENT_TYPES: ReadonlySet<ActionLogEventType>;
52
- export declare function isTerminalEventType(type: ActionLogEventType): boolean;
53
- export declare function newEventId(): string;
54
- export declare function nowTimestamp(): string;
55
- export type ToolWorkerContext = {
56
- log: ActionLogOpened;
57
- getWallets?: () => unknown;
58
- reloadWallets?: () => void | Promise<void>;
59
- getPort: (invocationId: string) => ExtensionPort | undefined;
60
- };
61
- export declare function applyEventToState(prev: OpenInvocationState | null, event: ActionLogEvent): OpenInvocationState;
62
- export declare function isOpenState(state: OpenInvocationState): boolean;
@@ -1,62 +0,0 @@
1
- export const TERMINAL_EVENT_TYPES = new Set([
2
- "dismiss",
3
- "execute_result",
4
- "aborted",
5
- ]);
6
- export function isTerminalEventType(type) {
7
- return TERMINAL_EVENT_TYPES.has(type);
8
- }
9
- export function newEventId() {
10
- return crypto.randomUUID();
11
- }
12
- export function nowTimestamp() {
13
- return new Date().toISOString();
14
- }
15
- export function applyEventToState(prev, event) {
16
- const base = prev ?? {
17
- invocationId: event.invocationId,
18
- toolId: event.toolId,
19
- stage: event.stage,
20
- lastType: event.type,
21
- };
22
- const next = {
23
- ...base,
24
- invocationId: event.invocationId,
25
- toolId: event.toolId,
26
- stage: event.stage,
27
- lastType: event.type,
28
- timestamp: event.timestamp,
29
- };
30
- if (event.valid !== undefined)
31
- next.valid = event.valid;
32
- if (event.amount !== undefined)
33
- next.amount = event.amount;
34
- if (event.address !== undefined)
35
- next.address = event.address;
36
- if (event.no_check !== undefined)
37
- next.no_check = event.no_check;
38
- if (event.wallet_slot !== undefined)
39
- next.wallet_slot = event.wallet_slot;
40
- if (event.context_domain !== undefined)
41
- next.context_domain = event.context_domain;
42
- if (event.destination_domain !== undefined)
43
- next.destination_domain = event.destination_domain;
44
- if (event.context_href !== undefined)
45
- next.context_href = event.context_href;
46
- if (event.found_in !== undefined)
47
- next.found_in = event.found_in;
48
- if (event.link !== undefined)
49
- next.link = event.link;
50
- if (event.linkText !== undefined)
51
- next.linkText = event.linkText;
52
- if (event.wallet_to_send_from_pa !== undefined)
53
- next.wallet_to_send_from_pa = event.wallet_to_send_from_pa;
54
- if (event.ok !== undefined)
55
- next.ok = event.ok;
56
- if (event.error !== undefined)
57
- next.error = event.error;
58
- return next;
59
- }
60
- export function isOpenState(state) {
61
- return !isTerminalEventType(state.lastType);
62
- }
@@ -1,28 +0,0 @@
1
- import type { BlockInfo, GetBlocksBinRequest, ViewPair } from "../../api";
2
- import type { ScanSetting } from "../scanSettings";
3
- import { type CacheRange } from "../scanresult/scanCache";
4
- export declare function writeGetblocksBinBuffer(getBlocksBinResponseContent: Uint8Array, block_infos: BlockInfo[], pathPrefix?: string): Promise<GetBlocksBinBufferItemFilename | undefined>;
5
- export type GetBlocksBinBufferItemFilename = {
6
- start: number;
7
- end: number;
8
- filename: string;
9
- date: string;
10
- last_block_hash: string;
11
- };
12
- export declare function readGetblocksBinBuffer(current_height: number, pathPrefix?: string): Promise<GetBlocksBinBufferItemFilename[]>;
13
- export type BlocksGenerator = AsyncGenerator<Uint8Array>;
14
- export type SlaveViewPair = {
15
- viewpair: ViewPair;
16
- current_range: CacheRange;
17
- secret_spend_key?: string;
18
- };
19
- declare module "bun" {
20
- interface BunFile {
21
- delete(): Promise<void>;
22
- }
23
- }
24
- export declare function trimGetBlocksBinBuffer(nonHaltedWallets: ScanSetting[], pathPrefix?: string): Promise<void>;
25
- export declare function readGetblocksBinBufferItems(pathPrefix?: string): Promise<GetBlocksBinBufferItemFilename[]>;
26
- export interface HasGetBlocksBinExecuteRequestMethod {
27
- getBlocksBinExecuteRequest: (params: GetBlocksBinRequest, stopSync?: AbortSignal) => Promise<Uint8Array>;
28
- }
@@ -1,54 +0,0 @@
1
- import { atomicWrite } from "../../io/atomicWrite";
2
- import { readDir } from "../../io/readDir";
3
- import { readCacheFileDefaultLocation, } from "../scanresult/scanCache";
4
- export async function writeGetblocksBinBuffer(getBlocksBinResponseContent, block_infos, pathPrefix) {
5
- if (!block_infos.length)
6
- return;
7
- const start = block_infos[0].block_height;
8
- const end = block_infos.at(-1).block_height;
9
- const block_hash = block_infos.at(-1).block_hash;
10
- const bufferItems = await readGetblocksBinBufferItems(pathPrefix);
11
- if (bufferItems.find((bi) => bi.last_block_hash === block_hash))
12
- return;
13
- const date = Date.now().toString();
14
- const filename = `${date}-${start}-${end}-${block_hash}-getblocks.bin`;
15
- await atomicWrite(`${pathPrefix ?? ""}getblocksbinbuffer/${filename}`, getBlocksBinResponseContent);
16
- return { start, end, filename, date, last_block_hash: block_hash };
17
- }
18
- export async function readGetblocksBinBuffer(current_height, pathPrefix) {
19
- const bufferItems = await readGetblocksBinBufferItems(pathPrefix);
20
- const start_buffer = bufferItems.find((r) => current_height >= r.start && current_height <= r.end) ?? null;
21
- if (start_buffer)
22
- return [
23
- start_buffer,
24
- ...bufferItems.filter((r) => r.date > start_buffer?.date),
25
- ];
26
- return [];
27
- }
28
- export async function trimGetBlocksBinBuffer(nonHaltedWallets, pathPrefix) {
29
- const snail = Math.min(...(await Promise.all(nonHaltedWallets
30
- .slice(1)
31
- .map(async (wallet) => (await readCacheFileDefaultLocation(wallet.primary_address, pathPrefix))?.scanned_ranges[0]?.end))).filter((x) => x !== undefined));
32
- // if all wallets have higher start than end of blocksbufferitem, delete
33
- const bufferItems = await readGetblocksBinBufferItems(pathPrefix);
34
- for (const bufferItem of bufferItems) {
35
- if (bufferItem.end <= snail) {
36
- await Bun.file(`${pathPrefix ?? ""}getblocksbinbuffer/${bufferItem.filename}`).delete();
37
- }
38
- }
39
- }
40
- export async function readGetblocksBinBufferItems(pathPrefix) {
41
- const bufferItems = await readDir(`${pathPrefix ?? ""}getblocksbinbuffer/`).catch(() => []);
42
- const ranges = [];
43
- for (const filename of bufferItems) {
44
- const [date, start, end, last_block_hash] = filename.split("-");
45
- ranges.push({
46
- start: parseInt(start),
47
- end: parseInt(end),
48
- filename,
49
- date,
50
- last_block_hash,
51
- });
52
- }
53
- return ranges;
54
- }
@@ -1,165 +0,0 @@
1
- import type { LogSetting, PossibleLogs } from "../io/logging";
2
- export declare const SCAN_SETTINGS_STORE_NAME_DEFAULT = "ScanSettings.json";
3
- export declare const SUB_ADDRESS_INDEX_DEFAULT_VALUE = 1;
4
- export type ScanSetting = {
5
- primary_address: string;
6
- subaddress_index?: number;
7
- halted?: boolean;
8
- wallet_route?: string;
9
- wallet_name?: string;
10
- wallet_slot?: number;
11
- };
12
- export type WriteScanSettingParams = {
13
- primary_address: string;
14
- start_height?: number | null;
15
- subaddress_index?: number;
16
- halted?: boolean;
17
- scan_settings_path?: string;
18
- node_url?: string;
19
- wallet_route?: string;
20
- wallet_name?: string;
21
- wallet_slot?: number;
22
- logs?: LogSetting;
23
- logs_include?: PossibleLogs[];
24
- logs_exclude?: PossibleLogs[];
25
- };
26
- export type ScanSettingOpened = {
27
- primary_address: string;
28
- start_height: number | null;
29
- node_url: string;
30
- subaddress_index?: number;
31
- secret_view_key?: string;
32
- halted?: boolean;
33
- secret_spend_key?: string;
34
- wallet_route?: string;
35
- wallet_name?: string;
36
- wallet_slot?: number;
37
- };
38
- export type ScanSettings = {
39
- wallets: ScanSetting[];
40
- node_url: string;
41
- start_height: number | null;
42
- merchant_confirmations?: number | null;
43
- cpu_worker_count?: number;
44
- logs?: LogSetting;
45
- logs_include?: PossibleLogs[];
46
- logs_exclude?: PossibleLogs[];
47
- };
48
- export type ScanSettingsOpened = {
49
- wallets: (ScanSettingOpened | undefined)[];
50
- node_url: string;
51
- start_height: number | null;
52
- merchant_confirmations?: number | null;
53
- cpu_worker_count?: number;
54
- logs?: LogSetting;
55
- logs_include?: PossibleLogs[];
56
- logs_exclude?: PossibleLogs[];
57
- };
58
- /**
59
- * Writes scan settings to the default or specified storage file in json.
60
- *
61
- * @example
62
- * ```
63
- * const settings: ScanSettings = {
64
- * wallets: [{
65
- * primary_address: "5dsf...",
66
- * start_height: 1741707,
67
- * }],
68
- * node_urls: ["https://monerooo.roooo"]
69
- * };
70
- * await writeScanSettings(settings);
71
- * ```
72
- *
73
- * @param scan_settings - The complete {@link ScanSettings} configuration to persist.
74
- * @param scan_settings_path - Optional path for the settings file. Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
75
- * @returns A promise that resolves when the file is successfully written.
76
- * @throws Will throw if file writing fails (e.g., permissions, disk space).
77
- */
78
- export declare function writeScanSettings(scan_settings: ScanSettings, scan_settings_path?: string): Promise<number>;
79
- export type WriteScanSettingsFileParams = {
80
- scan_settings_path?: string;
81
- writeCallback: (settings: ScanSettings) => void | Promise<void>;
82
- };
83
- export declare function writeScanSettingsFileDefaultLocation(params: WriteScanSettingsFileParams): Promise<void>;
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
- /**
90
- * Writes the merchant confirmation threshold to scan settings.
91
- *
92
- * This setting only has effect when the wallet is run as part of a checkout system,
93
- * that accepts payments.
94
- * It determines after how many confirmations a transaction is accepted
95
- * for a payment. The actual enforcement of this policy is left to the
96
- * custom payment-system code that consumes this library.
97
- *
98
- * @param merchant_confirmations - Number of confirmations required before
99
- * accepting a payment, or `null` to leave it unset.
100
- * @param scan_settings_path - Optional path for the settings file.
101
- * Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
102
- * @returns A promise that resolves when the file is successfully written.
103
- */
104
- export declare function writeMerchantConfirmationsToScanSettings(merchant_confirmations: number | null, scan_settings_path?: string): Promise<number>;
105
- /**
106
- * Reads the merchant confirmation threshold from scan settings.
107
- *
108
- * This setting only has effect when the wallet is run as part of a checkout system,
109
- * that accepts payments.
110
- *
111
- * It determines after how many confirmations a transaction is accepted
112
- * for a payment. The actual enforcement of this policy is left to the
113
- * custom payment-system code that consumes this library.
114
- *
115
- * @param scan_settings_path - Optional path for the settings file.
116
- * Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
117
- * @returns The configured number of confirmations, null, or `undefined`
118
- * if the setting has not been persisted yet.
119
- */
120
- export declare function readMerchantConfirmationsFromScanSettings(scan_settings_path?: string): Promise<number | null | undefined>;
121
- /**
122
- * Reads scan settings from the default or specified storage file.
123
- * secret_view_key and spend_private_key are read from environment variables
124
- *
125
- * @example
126
- * ```
127
- * const settings = await readScanSettings();
128
- * if (settings) {
129
- * console.log(settings.wallets?.primary_address);
130
- * }
131
- * ```
132
- *
133
- * @param scan_settings_path - Path to the settings file. Defaults to `SCAN_SETTINGS_STORE_NAME_DEFAULT`.
134
- * @returns The parsed {@link ScanSettings} object if file exists and is valid JSON, otherwise `undefined`.
135
- */
136
- export declare function readScanSettings(scan_settings_path?: string): Promise<ScanSettingsOpened | undefined>;
137
- export declare function readPrivateSpendKeyFromEnv(primary_address: string): string | undefined;
138
- export declare function readPrivateViewKeyFromEnv(primary_address: string): string | undefined;
139
- export declare function readWalletFromScanSettings(primary_address: string, scan_settings_path?: string): Promise<ScanSettingOpened | undefined>;
140
- export declare function readWalletsFromScanSettings(scan_settings_path?: string): Promise<ScanSettingOpened[]>;
141
- export declare function walletSettingsPlusKeys(wallet_settings: ScanSettingOpened, secret_view_key?: string, secret_spend_key?: string): Promise<{
142
- secret_view_key: string;
143
- secret_spend_key: string | undefined;
144
- primary_address: string;
145
- start_height: number | null;
146
- node_url: string;
147
- subaddress_index?: number;
148
- halted?: boolean;
149
- wallet_route?: string;
150
- wallet_name?: string;
151
- wallet_slot?: number;
152
- }>;
153
- export declare function writeWalletToScanSettings(params: WriteScanSettingParams): Promise<number>;
154
- export declare function openScanSettingsFile(scan_settings_path?: string): Promise<ScanSettings | undefined>;
155
- export declare function openNonHaltedWallets(scan_settings_path?: string): Promise<ScanSettingOpened[]>;
156
- export declare function getNonHaltedWallets(scan_settings?: ScanSettings): ScanSetting[];
157
- export declare function doesScanSettingsFileExist(scan_settings_path?: string): Promise<boolean>;
158
- /**
159
- * Either 1. the consumer explicitly sets a pathprefix, we extract it from the scan_settings_path
160
- * or we pick the default which is nothing
161
- * @param scan_settings_path optional scan settings path
162
- * @param pathPrefix optional path prefix
163
- * @returns definite path prefix
164
- */
165
- export declare function getPathPrefix(scan_settings_path?: string, pathPrefix?: string): string;