@spirobel/monero-wallet-api 0.1.2 → 0.3.0
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/README.md +13 -1
- package/dist/api.d.ts +25 -53
- package/dist/api.js +23 -101
- package/dist/io/BunFileInterface.d.ts +32 -0
- package/dist/io/BunFileInterface.js +1 -0
- package/dist/io/atomicWrite.d.ts +2 -0
- package/dist/io/atomicWrite.js +10 -0
- package/dist/io/extension.d.ts +18 -0
- package/dist/io/extension.js +11 -0
- package/dist/io/indexedDB.d.ts +45 -0
- package/dist/io/indexedDB.js +221 -0
- package/dist/io/readDir.d.ts +1 -0
- package/dist/io/readDir.js +7 -0
- package/dist/io/sleep.d.ts +1 -0
- package/dist/io/sleep.js +1 -0
- package/dist/keypairs-seeds/keypairs.d.ts +29 -0
- package/dist/keypairs-seeds/keypairs.js +207 -0
- package/dist/keypairs-seeds/writeKeypairs.d.ts +11 -0
- package/dist/keypairs-seeds/writeKeypairs.js +75 -0
- package/dist/node-interaction/binaryEndpoints.d.ts +67 -10
- package/dist/node-interaction/binaryEndpoints.js +127 -53
- package/dist/node-interaction/jsonEndpoints.d.ts +249 -187
- package/dist/node-interaction/jsonEndpoints.js +287 -0
- package/dist/node-interaction/nodeUrl.d.ts +129 -0
- package/dist/node-interaction/nodeUrl.js +113 -0
- package/dist/scanning-syncing/backgroundWorker.d.ts +6 -0
- package/dist/scanning-syncing/backgroundWorker.js +56 -0
- package/dist/scanning-syncing/connectionStatus.d.ts +15 -0
- package/dist/scanning-syncing/connectionStatus.js +35 -0
- package/dist/scanning-syncing/openWallet.d.ts +28 -0
- package/dist/scanning-syncing/openWallet.js +57 -0
- package/dist/scanning-syncing/scanSettings.d.ts +96 -0
- package/dist/scanning-syncing/scanSettings.js +243 -0
- package/dist/scanning-syncing/scanresult/computeKeyImage.d.ts +3 -0
- package/dist/scanning-syncing/scanresult/computeKeyImage.js +21 -0
- package/dist/scanning-syncing/scanresult/getBlocksbinBuffer.d.ts +28 -0
- package/dist/scanning-syncing/scanresult/getBlocksbinBuffer.js +52 -0
- package/dist/scanning-syncing/scanresult/reorg.d.ts +14 -0
- package/dist/scanning-syncing/scanresult/reorg.js +78 -0
- package/dist/scanning-syncing/scanresult/scanCache.d.ts +84 -0
- package/dist/scanning-syncing/scanresult/scanCache.js +134 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +149 -0
- package/dist/scanning-syncing/scanresult/scanCacheOpened.js +648 -0
- package/dist/scanning-syncing/scanresult/scanResult.d.ts +64 -0
- package/dist/scanning-syncing/scanresult/scanResult.js +213 -0
- package/dist/scanning-syncing/scanresult/scanStats.d.ts +60 -0
- package/dist/scanning-syncing/scanresult/scanStats.js +273 -0
- package/dist/scanning-syncing/worker-entrypoints/worker.d.ts +1 -0
- package/dist/scanning-syncing/worker-entrypoints/worker.js +8 -0
- package/dist/scanning-syncing/worker-mains/worker.d.ts +1 -0
- package/dist/scanning-syncing/worker-mains/worker.js +7 -0
- package/dist/send-functionality/conversion.d.ts +4 -0
- package/dist/send-functionality/conversion.js +75 -0
- package/dist/send-functionality/inputSelection.d.ts +13 -0
- package/dist/send-functionality/inputSelection.js +8 -0
- package/dist/send-functionality/transactionBuilding.d.ts +51 -0
- package/dist/send-functionality/transactionBuilding.js +111 -0
- package/dist/tools/monero-tools.d.ts +46 -0
- package/dist/tools/monero-tools.js +165 -0
- package/dist/viewpair/ViewPair.d.ts +157 -0
- package/dist/viewpair/ViewPair.js +346 -0
- package/dist/wasm-processing/wasi.js +1 -2
- package/dist/wasm-processing/wasmFile.d.ts +1 -1
- package/dist/wasm-processing/wasmFile.js +2 -2
- package/dist/wasm-processing/wasmProcessor.d.ts +16 -4
- package/dist/wasm-processing/wasmProcessor.js +23 -7
- package/package.json +29 -6
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type KeyImage } from "./computeKeyImage";
|
|
2
|
+
import type { ReorgInfo } from "./reorg";
|
|
3
|
+
import type { BlockInfo, FeeEstimateResponse, GetBlockHeadersRange, GetBlockHeadersRangeParams, Output, SendRawTransactionResult, ViewPair } from "../../api";
|
|
4
|
+
import type { Payment } from "../../send-functionality/inputSelection";
|
|
5
|
+
export declare function initScanCache(viewpair: ViewPair, start_height: number, scan_settings_path?: string, pathPrefix?: string): Promise<CacheRange>;
|
|
6
|
+
export declare function readCacheFile(cacheFilePath: string): Promise<ScanCache | undefined>;
|
|
7
|
+
export declare function cacheFileDefaultLocation(primary_address: string, pathPrefix?: string): string;
|
|
8
|
+
export declare function readCacheFileDefaultLocation(primary_address: string, pathPrefix?: string): Promise<ScanCache | undefined>;
|
|
9
|
+
export type WriteCacheFileParams = {
|
|
10
|
+
primary_address: string;
|
|
11
|
+
pathPrefix?: string;
|
|
12
|
+
writeCallback: (cache: ScanCache) => void | Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export declare function writeCacheFileDefaultLocationThrows(params: WriteCacheFileParams): Promise<void>;
|
|
15
|
+
export declare function writeCacheToFile(cache: ScanCache, pathPrefix?: string): Promise<number>;
|
|
16
|
+
export declare function lastRange(ranges: CacheRange[]): CacheRange | undefined;
|
|
17
|
+
export declare function mergeRanges(ranges: CacheRange[]): CacheRange[];
|
|
18
|
+
export declare const findRange: (ranges: CacheRange[], value: number) => CacheRange | null;
|
|
19
|
+
export type CacheRange = {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
block_hashes: BlockInfo[];
|
|
23
|
+
};
|
|
24
|
+
export type GlobalOutputId = string;
|
|
25
|
+
export type OutputsCache = Record<GlobalOutputId, Output>;
|
|
26
|
+
export type OwnKeyImages = Record<KeyImage, GlobalOutputId>;
|
|
27
|
+
export type Subaddress = {
|
|
28
|
+
minor: number;
|
|
29
|
+
address: string;
|
|
30
|
+
created_at_height: number;
|
|
31
|
+
created_at_timestamp: number;
|
|
32
|
+
not_yet_included?: boolean;
|
|
33
|
+
received_amount?: bigint;
|
|
34
|
+
pending_amount?: bigint;
|
|
35
|
+
};
|
|
36
|
+
export type ScanCache = {
|
|
37
|
+
outputs: OutputsCache;
|
|
38
|
+
own_key_images: OwnKeyImages;
|
|
39
|
+
scanned_ranges: CacheRange[];
|
|
40
|
+
primary_address: string;
|
|
41
|
+
tx_logs?: TxLog[];
|
|
42
|
+
pending_spent_utxos?: Record<GlobalOutputId, number>;
|
|
43
|
+
subaddresses?: Subaddress[];
|
|
44
|
+
reorg_info?: ReorgInfo;
|
|
45
|
+
daemon_height: number;
|
|
46
|
+
};
|
|
47
|
+
export type TxLog = {
|
|
48
|
+
inputs_index: string[];
|
|
49
|
+
payments: Payment[];
|
|
50
|
+
node_url: string;
|
|
51
|
+
height: number;
|
|
52
|
+
timestamp: number;
|
|
53
|
+
feeEstimate?: FeeEstimateResponse;
|
|
54
|
+
sendResult?: SendRawTransactionResult;
|
|
55
|
+
error?: string;
|
|
56
|
+
};
|
|
57
|
+
export type ChangeReason = "spent" | "added" | "ownspend" | "reorged" | "reorged_spent" | "burned";
|
|
58
|
+
export type ChangedOutput = {
|
|
59
|
+
output: Output;
|
|
60
|
+
change_reason: ChangeReason;
|
|
61
|
+
};
|
|
62
|
+
export type CacheChangedCallbackParameters = {
|
|
63
|
+
newCache: ScanCache;
|
|
64
|
+
changed_outputs: ChangedOutput[];
|
|
65
|
+
};
|
|
66
|
+
export type CacheChangedCallbackSync<R = void> = (params: CacheChangedCallbackParameters) => R;
|
|
67
|
+
export type CacheChangedCallbackAsync = CacheChangedCallbackSync<Promise<void>>;
|
|
68
|
+
/**
|
|
69
|
+
* Callback invoked when the scan cache changes.
|
|
70
|
+
*
|
|
71
|
+
* @param params - The callback parameters.
|
|
72
|
+
* @param params.newCache - The updated scan cache.
|
|
73
|
+
* @param params.changed_outputs - Contains output and change_reason. {@link ChangedOutput}
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
export type CacheChangedCallback = CacheChangedCallbackSync | CacheChangedCallbackAsync;
|
|
77
|
+
export interface HasGetBlockHeadersRangeMethod {
|
|
78
|
+
getBlockHeadersRange: (params: GetBlockHeadersRangeParams) => Promise<GetBlockHeadersRange>;
|
|
79
|
+
}
|
|
80
|
+
export interface HasPrimaryAddress {
|
|
81
|
+
primary_address: string;
|
|
82
|
+
}
|
|
83
|
+
export declare function handleScanError(error: unknown): void;
|
|
84
|
+
export declare function isConnectionError(error: unknown): true | undefined;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {} from "./computeKeyImage";
|
|
2
|
+
import { atomicWrite } from "../../io/atomicWrite";
|
|
3
|
+
export async function initScanCache(viewpair, start_height, scan_settings_path, pathPrefix) {
|
|
4
|
+
const initialCache = await readCacheFileDefaultLocation(viewpair.primary_address, pathPrefix);
|
|
5
|
+
let cache = {
|
|
6
|
+
daemon_height: 0,
|
|
7
|
+
outputs: {},
|
|
8
|
+
own_key_images: {},
|
|
9
|
+
scanned_ranges: [],
|
|
10
|
+
primary_address: viewpair.primary_address,
|
|
11
|
+
};
|
|
12
|
+
if (initialCache)
|
|
13
|
+
cache = initialCache;
|
|
14
|
+
let current_height = start_height;
|
|
15
|
+
// merge existing ranges & find end of current range
|
|
16
|
+
cache.scanned_ranges = mergeRanges(cache.scanned_ranges);
|
|
17
|
+
let current_range = findRange(cache.scanned_ranges, current_height);
|
|
18
|
+
let start_block_hash = current_range?.block_hashes[0];
|
|
19
|
+
if (!start_block_hash) {
|
|
20
|
+
const blockHeaderResponse = (await viewpair.getBlockHeadersRange({
|
|
21
|
+
start_height,
|
|
22
|
+
end_height: start_height,
|
|
23
|
+
})).headers[0];
|
|
24
|
+
start_block_hash = {
|
|
25
|
+
block_hash: blockHeaderResponse.hash,
|
|
26
|
+
block_height: blockHeaderResponse.height,
|
|
27
|
+
block_timestamp: blockHeaderResponse.timestamp,
|
|
28
|
+
};
|
|
29
|
+
const newRange = {
|
|
30
|
+
start: start_block_hash.block_height,
|
|
31
|
+
end: start_block_hash.block_height,
|
|
32
|
+
block_hashes: [start_block_hash, start_block_hash, start_block_hash],
|
|
33
|
+
};
|
|
34
|
+
current_range = newRange;
|
|
35
|
+
cache.scanned_ranges.push(newRange);
|
|
36
|
+
}
|
|
37
|
+
if (!start_block_hash)
|
|
38
|
+
throw new Error("could not find start block hash");
|
|
39
|
+
if (current_range == null || !current_range?.block_hashes.length)
|
|
40
|
+
throw new Error("current_range was malformed. block_hashes is empty");
|
|
41
|
+
await viewpair.addSubaddressesToScanCache(cache, scan_settings_path);
|
|
42
|
+
// write to cache
|
|
43
|
+
await writeCacheToFile(cache, pathPrefix);
|
|
44
|
+
return current_range;
|
|
45
|
+
}
|
|
46
|
+
export async function readCacheFile(cacheFilePath) {
|
|
47
|
+
const jsonString = await Bun.file(cacheFilePath)
|
|
48
|
+
.text()
|
|
49
|
+
.catch(() => undefined);
|
|
50
|
+
return jsonString
|
|
51
|
+
? JSON.parse(jsonString, (key, value) => {
|
|
52
|
+
if (key === "amount")
|
|
53
|
+
return BigInt(value);
|
|
54
|
+
return value;
|
|
55
|
+
})
|
|
56
|
+
: undefined;
|
|
57
|
+
}
|
|
58
|
+
export function cacheFileDefaultLocation(primary_address, pathPrefix) {
|
|
59
|
+
return `${pathPrefix ?? ""}${primary_address}_cache.json`;
|
|
60
|
+
}
|
|
61
|
+
export async function readCacheFileDefaultLocation(primary_address, pathPrefix) {
|
|
62
|
+
return await readCacheFile(cacheFileDefaultLocation(primary_address, pathPrefix));
|
|
63
|
+
}
|
|
64
|
+
export async function writeCacheFileDefaultLocationThrows(params) {
|
|
65
|
+
const cache = await readCacheFileDefaultLocation(params.primary_address, params.pathPrefix);
|
|
66
|
+
if (!cache)
|
|
67
|
+
throw new Error(`cache not found for primary address: ${params.primary_address}, and path prefix: ${params.pathPrefix}`);
|
|
68
|
+
await params.writeCallback(cache);
|
|
69
|
+
// write to cache
|
|
70
|
+
await writeCacheToFile(cache, params.pathPrefix);
|
|
71
|
+
}
|
|
72
|
+
export async function writeCacheToFile(cache, pathPrefix) {
|
|
73
|
+
// write to cache
|
|
74
|
+
return await atomicWrite(cacheFileDefaultLocation(cache.primary_address, pathPrefix), JSON.stringify(cache, (key, value) => (typeof value === "bigint" ? value.toString() : value), 2));
|
|
75
|
+
}
|
|
76
|
+
export function lastRange(ranges) {
|
|
77
|
+
if (!ranges.length)
|
|
78
|
+
return undefined;
|
|
79
|
+
return ranges.reduce((maxRange, current) => (current.end > maxRange.end ? current : maxRange), ranges[0]);
|
|
80
|
+
}
|
|
81
|
+
export function mergeRanges(ranges) {
|
|
82
|
+
if (ranges.length <= 1)
|
|
83
|
+
return ranges.map((r) => ({ ...r }));
|
|
84
|
+
const sorted = [...ranges].sort((a, b) => a.start - b.start);
|
|
85
|
+
const merged = [sorted[0]];
|
|
86
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
87
|
+
const curr = sorted[i];
|
|
88
|
+
const last = merged[merged.length - 1];
|
|
89
|
+
// If last range overlaps or touches current range
|
|
90
|
+
if (curr.start <= last.end) {
|
|
91
|
+
// Extend last range to cover both (take max end value)
|
|
92
|
+
last.end = Math.max(last.end, curr.end);
|
|
93
|
+
last.block_hashes = curr.block_hashes;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// No overlap: add current range as new merged interval
|
|
97
|
+
merged.push(curr);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return merged;
|
|
101
|
+
}
|
|
102
|
+
// find the cache range that contains the given height, if not found return null
|
|
103
|
+
export const findRange = (ranges, value) => ranges.find((r) => value >= r.start && value <= r.end) ?? null;
|
|
104
|
+
export function handleScanError(error) {
|
|
105
|
+
// treat errno 0 code "ConnectionRefused" as non fatal outcome, and rethrow,
|
|
106
|
+
// so that UI can be informed after catching it higher up
|
|
107
|
+
if (isConnectionError(error)) {
|
|
108
|
+
console.log("Scan stopped. node might be offline. Connection Refused");
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
// Treat AbortError as a normal, non-fatal outcome
|
|
112
|
+
if (error &&
|
|
113
|
+
typeof error === "object" &&
|
|
114
|
+
(("name" in error && error.name === "AbortError") ||
|
|
115
|
+
("code" in error && error.code === 20))) {
|
|
116
|
+
console.log("Scan was aborted.");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
console.log(error, "\n, scanWithCache in scanning-syncing/scanWithCache.ts`");
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export function isConnectionError(error) {
|
|
125
|
+
if (error &&
|
|
126
|
+
typeof error === "object" &&
|
|
127
|
+
(("code" in error && error.code === "ConnectionRefused") ||
|
|
128
|
+
("errno" in error && error.errno === 0))) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ViewPair, type FeeEstimateResponse, type Output, type SendRawTransactionResult } from "../../api";
|
|
2
|
+
import { type Payment } from "../../send-functionality/inputSelection";
|
|
3
|
+
import { type CacheChangedCallback, type CacheChangedCallbackParameters, type ScanCache, type Subaddress, type TxLog } from "./scanCache";
|
|
4
|
+
import { type FoundTransaction, type PrePendingTx } from "./scanStats";
|
|
5
|
+
export type SlaveScanCache = boolean;
|
|
6
|
+
export type ScanCacheOpenedCreateParams = {
|
|
7
|
+
primary_address: string;
|
|
8
|
+
scan_settings_path?: string;
|
|
9
|
+
pathPrefix?: string;
|
|
10
|
+
no_worker?: boolean;
|
|
11
|
+
no_stats?: boolean;
|
|
12
|
+
masterCacheChanged?: CacheChangedCallback;
|
|
13
|
+
workerError?: (error: unknown) => void;
|
|
14
|
+
};
|
|
15
|
+
export type CreateTransactionParams = {
|
|
16
|
+
payments: Payment[];
|
|
17
|
+
inputs?: Output[];
|
|
18
|
+
no_fee_circuit_breaker?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class ScanCacheOpened {
|
|
21
|
+
readonly view_pair: ViewPair;
|
|
22
|
+
readonly wallet_route: string | undefined;
|
|
23
|
+
readonly no_worker: boolean;
|
|
24
|
+
readonly masterCacheChanged: CacheChangedCallback | null;
|
|
25
|
+
private _start_height;
|
|
26
|
+
private scan_settings_path?;
|
|
27
|
+
private pathPrefix?;
|
|
28
|
+
private workerError?;
|
|
29
|
+
static create(params: ScanCacheOpenedCreateParams): Promise<ScanCacheOpened>;
|
|
30
|
+
get start_height(): number | null;
|
|
31
|
+
get current_height(): number | null;
|
|
32
|
+
get current_top_range_height(): number | null;
|
|
33
|
+
changeStartHeight(start_height: number | null): Promise<void>;
|
|
34
|
+
get cache(): ScanCache;
|
|
35
|
+
get prepending_txs(): PrePendingTx[];
|
|
36
|
+
get transactions(): FoundTransaction[];
|
|
37
|
+
get primary_address(): string;
|
|
38
|
+
get node_url(): string;
|
|
39
|
+
private set node_url(value);
|
|
40
|
+
changeNodeUrlAndStartHeight(node_url?: string, start_height?: number | null): Promise<void>;
|
|
41
|
+
changeNodeUrl(node_url: string): Promise<void>;
|
|
42
|
+
retry(): Promise<boolean>;
|
|
43
|
+
sendTransaction(signedTx: string): Promise<SendRawTransactionResult>;
|
|
44
|
+
signTransaction(unsignedTx: string): Promise<string>;
|
|
45
|
+
calculateFeeAndSelectInputs(params: CreateTransactionParams): Promise<{
|
|
46
|
+
selectedInputs: Output[];
|
|
47
|
+
feeEstimate: {
|
|
48
|
+
status: string;
|
|
49
|
+
fee: number;
|
|
50
|
+
quantization_mask: number;
|
|
51
|
+
fees?: number[] | undefined;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
makeTransactionFromSelectedInputs(payments: Payment[], selectedInputs: Output[], feeEstimate: FeeEstimateResponse): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* this function returns the unsigned transaction, throws {@link SendError}
|
|
57
|
+
*/
|
|
58
|
+
makeTransaction(params: CreateTransactionParams): Promise<string>;
|
|
59
|
+
get daemon_height(): number;
|
|
60
|
+
get amount(): bigint;
|
|
61
|
+
get pending_amount(): bigint;
|
|
62
|
+
get subaddresses(): Subaddress[];
|
|
63
|
+
get tx_logs(): TxLog[];
|
|
64
|
+
makeSignSendTransaction(params: CreateTransactionParams): Promise<SendRawTransactionResult>;
|
|
65
|
+
/**
|
|
66
|
+
* makeStandardTransaction
|
|
67
|
+
*/
|
|
68
|
+
makeStandardTransaction(destination_address: string, amount: string): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* makeIntegratedAddress
|
|
71
|
+
*/
|
|
72
|
+
makeIntegratedAddress(paymentId: number): string;
|
|
73
|
+
/**
|
|
74
|
+
* This method makes a Subaddress for the Address of the Viewpair it was opened with.
|
|
75
|
+
* The network (mainnet, stagenet, testnet) is the same as the one of the Viewpairaddress.
|
|
76
|
+
* will increment minor by 1 on major 0 in "ScanSettings.json" subaddresses definition
|
|
77
|
+
*
|
|
78
|
+
* if there is an active scan going on, call this here on ScanCacheOpened, so the new subaddress will be scanned
|
|
79
|
+
* (and not on a viewpair / scancacheopened instance that is not conducting the scan, aka where no_worker is true)
|
|
80
|
+
*
|
|
81
|
+
* @returns Adressstring
|
|
82
|
+
*/
|
|
83
|
+
makeSubaddress(): Promise<Subaddress>;
|
|
84
|
+
/**
|
|
85
|
+
* notify
|
|
86
|
+
*
|
|
87
|
+
* ChangeReason = "added" | "ownspend" | "reorged" | "burned";
|
|
88
|
+
*/
|
|
89
|
+
notify(callback: CacheChangedCallback): {
|
|
90
|
+
remove: () => null;
|
|
91
|
+
};
|
|
92
|
+
pause(): Promise<number>;
|
|
93
|
+
stopWorker(): void;
|
|
94
|
+
unpause(): Promise<number>;
|
|
95
|
+
/**
|
|
96
|
+
* selectInputs returns array of inputs, whose sum is larger than amount
|
|
97
|
+
* adds approximate fee for 10kb transaction to amount if feePerByte is supplied
|
|
98
|
+
*/
|
|
99
|
+
selectInputs(amount: bigint, feePerByte?: bigint): Output[];
|
|
100
|
+
/**
|
|
101
|
+
* selectOneInput larger than amount, (smallest one matching this amount)
|
|
102
|
+
*/
|
|
103
|
+
selectOneInput(amount: bigint): Output | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* selectMultipleInputs larger than amount, sorted from largest to smallest until total reaches amount
|
|
106
|
+
*/
|
|
107
|
+
selectMultipleInputs(amount: bigint): Output[];
|
|
108
|
+
/**
|
|
109
|
+
* get spendableInputs
|
|
110
|
+
*/
|
|
111
|
+
spendableInputs(): Output[];
|
|
112
|
+
/**
|
|
113
|
+
* feed the ScanCacheOpened with new ScanCache as syncing happens
|
|
114
|
+
* if primary_address does not match, do not feed
|
|
115
|
+
* if masterCacheChanged is set, it will be called here
|
|
116
|
+
* for all primary addresses
|
|
117
|
+
*/
|
|
118
|
+
feed(params: CacheChangedCallbackParameters): Promise<void>;
|
|
119
|
+
private _cache;
|
|
120
|
+
private worker?;
|
|
121
|
+
private constructor();
|
|
122
|
+
private _stats;
|
|
123
|
+
private notifyListeners;
|
|
124
|
+
}
|
|
125
|
+
export type ManyScanCachesOpenedCreateOptions = {
|
|
126
|
+
scan_settings_path?: string;
|
|
127
|
+
pathPrefix?: string;
|
|
128
|
+
no_worker?: boolean;
|
|
129
|
+
notifyMasterChanged?: CacheChangedCallback;
|
|
130
|
+
no_stats?: boolean;
|
|
131
|
+
workerError?: (error: unknown) => void;
|
|
132
|
+
};
|
|
133
|
+
export declare class ManyScanCachesOpened {
|
|
134
|
+
readonly wallets: ScanCacheOpened[];
|
|
135
|
+
get start_height(): number | null;
|
|
136
|
+
get current_height(): number | null;
|
|
137
|
+
get node_url(): string;
|
|
138
|
+
changeNodeUrlAndStartHeight(node_url?: string, start_height?: number | null): Promise<void>;
|
|
139
|
+
retry(): Promise<boolean>;
|
|
140
|
+
stopWorker(): void;
|
|
141
|
+
changeNodeUrl(node_url: string): Promise<void>;
|
|
142
|
+
changeStartHeight(start_height: number | null): Promise<void>;
|
|
143
|
+
static create({ scan_settings_path, pathPrefix, no_worker, notifyMasterChanged, no_stats, workerError, }: ManyScanCachesOpenedCreateOptions): Promise<ManyScanCachesOpened | undefined>;
|
|
144
|
+
/**
|
|
145
|
+
* feed the master wallet and therefore all wallets
|
|
146
|
+
*/
|
|
147
|
+
feed(params: CacheChangedCallbackParameters): Promise<void>;
|
|
148
|
+
private constructor();
|
|
149
|
+
}
|