@spirobel/monero-wallet-api 0.2.0 → 0.3.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.
- package/README.md +3 -3
- package/dist/api.d.ts +25 -96
- package/dist/api.js +23 -175
- package/dist/io/BunFileInterface.d.ts +32 -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 +12 -0
- package/dist/keypairs-seeds/writeKeypairs.js +78 -0
- package/dist/node-interaction/binaryEndpoints.d.ts +59 -14
- package/dist/node-interaction/binaryEndpoints.js +110 -54
- 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 +240 -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
- package/dist/testscrap.js +0 -36
- /package/dist/{testscrap.d.ts → io/BunFileInterface.js} +0 -0
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ rust release build
|
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
cd rust || cd ../rust
|
|
21
|
-
cargo
|
|
21
|
+
cargo build --target wasm32-wasip1 --release --lib
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
prerequisite: install rust
|
|
@@ -28,8 +28,8 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
rustup install 1.
|
|
32
|
-
rustup default 1.
|
|
31
|
+
rustup install 1.89.0
|
|
32
|
+
rustup default 1.89.0
|
|
33
33
|
rustup target add wasm32-wasip1
|
|
34
34
|
```
|
|
35
35
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,98 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import "./io/indexedDB";
|
|
2
|
+
export type { ScanResult, ScanResultCallback, } from "./scanning-syncing/scanresult/scanResult";
|
|
3
|
+
export type { CacheChangedCallback, CacheChangedCallbackParameters, } from "./scanning-syncing/scanresult/scanCache";
|
|
4
|
+
export { NodeUrl } from "./node-interaction/nodeUrl";
|
|
5
|
+
export { ViewPair } from "./viewpair/ViewPair";
|
|
6
|
+
export { ScanCacheOpened, ManyScanCachesOpened, } from "./scanning-syncing/scanresult/scanCacheOpened";
|
|
3
7
|
export * from "./node-interaction/binaryEndpoints";
|
|
4
8
|
export * from "./node-interaction/jsonEndpoints";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This function helps with making requests to the get_blocks.bin endpoint of the Monerod nodes.
|
|
26
|
-
* The difference compared to the getBlocksBin method is that it returns a Uint8Array that still has to be scanned for outputs.
|
|
27
|
-
* This is useful if you want to scan multiple viewpairs at once. You can take the Uint8Array and pass it to another ViewPair to scan for outputs.
|
|
28
|
-
* @param params params that will be turned into epee (monero lib that does binary serialization)
|
|
29
|
-
* @returns This method will return a Uint8Array that can subsequently be scanned for outputs with the getBlocksBinScanResponse method.
|
|
30
|
-
*/
|
|
31
|
-
getBlocksBinExecuteRequest(params: GetBlocksBinRequest): Promise<Uint8Array>;
|
|
32
|
-
/**
|
|
33
|
-
* This function helps with scanning the response of the getBlocksBinExecuteRequest method.
|
|
34
|
-
* It will parse the Uint8Array and return the outputs that belong to the ViewPair.
|
|
35
|
-
* (if outputs are found in the blocks that are contained in the Uint8Array that was returned by the getBlocksBinExecuteRequest method)
|
|
36
|
-
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin
|
|
37
|
-
* @param getBlocksBinResponseBuffer the Uint8Array that was returned by the getBlocksBinExecuteRequest method.(which contains the blocks in binary format, returned from the Monerod node)
|
|
38
|
-
* @param metaCallBack contains meta information about the getBlocksbin call (new sync height = start_height param + number of blocks)
|
|
39
|
-
* @returns It returns {@link ScanResult} (outputs that belong to viewpair)
|
|
40
|
-
*/
|
|
41
|
-
getBlocksBinScanResponse(getBlocksBinResponseBuffer: Uint8Array, metaCallBack?: GetBlocksBinMetaCallback): Promise<ScanResult | ErrorResponse>;
|
|
42
|
-
/**
|
|
43
|
-
* This method will use getBlocks.bin from start height to daemon height.
|
|
44
|
-
* This is CPU bound work, so it should be executed in a seperate thread (worker).
|
|
45
|
-
* The scanner.ts worker in the standard-checkout dir shows how to keep scanning after the tip is reached.
|
|
46
|
-
* It also shows how the outputs are saved (note the unqiue requirement for the stealth_adress).
|
|
47
|
-
* @param start_height the height to start syncing from.
|
|
48
|
-
* @param callback this function will get the new outputs as they are found as a parameter
|
|
49
|
-
*/
|
|
50
|
-
scan(start_height: number, callback: ScanResultCallback): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* This method makes an integrated Address for the Address of the Viewpair it was opened with.
|
|
53
|
-
* The network (mainnet, stagenet, testnet) is the same as the one of the Viewpairaddress.
|
|
54
|
-
* @param paymentId (u64 under the hood) you can use a random number or a primary key of an sqlite db to associate payments with customer sessions.
|
|
55
|
-
* @returns Adressstring
|
|
56
|
-
*/
|
|
57
|
-
makeIntegratedAddress(paymentId: number): string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* This class is useful to interact with Moneros DaemonRpc binary requests in a convenient way.
|
|
61
|
-
* (similar to how you would interact with a REST api that gives you json back.)
|
|
62
|
-
* The wasm part will handle the creation of the binary requests and parse the responses and return them as json.
|
|
63
|
-
* {@link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin}
|
|
64
|
-
*/
|
|
65
|
-
export declare class NodeUrl extends WasmProcessor {
|
|
66
|
-
static create(node_url?: string): Promise<NodeUrl>;
|
|
67
|
-
/**
|
|
68
|
-
* This request helps making requests to the get_blocks.bin endpoint of the Monerod nodes.
|
|
69
|
-
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin
|
|
70
|
-
* @param params params that will be turned into epee (moner lib that does binary serialization)
|
|
71
|
-
* @returns after the request is made it will return epee serialized objects that are then parsed into json.
|
|
72
|
-
*/
|
|
73
|
-
getBlocksBin(params: GetBlocksBinRequest): Promise<import("./api").GetBlocksBinResponse | ErrorResponse>;
|
|
74
|
-
}
|
|
75
|
-
export type AddressAndViewKey = {
|
|
76
|
-
primary_address: string;
|
|
77
|
-
secret_view_key: string;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* The ViewPairs class contains a set of ViewPair objects that can be used to scan multiple addresses at once.
|
|
81
|
-
* (while only retrieving the blocks from the node once)
|
|
82
|
-
*/
|
|
83
|
-
export declare class ViewPairs {
|
|
84
|
-
private viewPairs;
|
|
85
|
-
protected constructor();
|
|
86
|
-
static create(pairs: AddressAndViewKey[], node_url?: string): Promise<ViewPairs>;
|
|
87
|
-
addViewPair(primary_address: string, secret_view_key: string, node_url?: string): Promise<ViewPair>;
|
|
88
|
-
getViewPair(primary_address: string): ViewPair | undefined;
|
|
89
|
-
/**
|
|
90
|
-
* This method will use getBlocks.bin from start height to daemon height.
|
|
91
|
-
* This is CPU bound work, so it should be executed in a seperate thread (worker).
|
|
92
|
-
* The scanner.ts worker in the standard-checkout dir shows how to keep scanning after the tip is reached.
|
|
93
|
-
* It also shows how the outputs are saved (note the unqiue requirement for the stealth_adress).
|
|
94
|
-
* @param start_height the height to start syncing from.
|
|
95
|
-
* @param callback this function will get the new outputs as they are found as a parameter
|
|
96
|
-
*/
|
|
97
|
-
scan(start_height: number, callback: ScanResultCallback): Promise<void>;
|
|
98
|
-
}
|
|
9
|
+
export * from "./io/readDir";
|
|
10
|
+
export * from "./io/atomicWrite";
|
|
11
|
+
export * from "./io/sleep";
|
|
12
|
+
export { writeScanSettings, readScanSettings, } from "./scanning-syncing/scanSettings";
|
|
13
|
+
export { signTransaction, parseAddress, type ParsedAddress, type ParseAddressError, } from "./send-functionality/transactionBuilding";
|
|
14
|
+
export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
|
|
15
|
+
export { scanWallets, startWebworker, createWebworker, makeWebworkerScript, } from "./scanning-syncing/backgroundWorker";
|
|
16
|
+
export { spendable } from "./scanning-syncing/scanresult/scanResult";
|
|
17
|
+
export { openWallets, openWallet } from "./scanning-syncing/openWallet";
|
|
18
|
+
export * from "./scanning-syncing/connectionStatus";
|
|
19
|
+
export * from "./scanning-syncing/scanSettings";
|
|
20
|
+
export * from "./scanning-syncing/scanresult/scanResult";
|
|
21
|
+
export * from "./scanning-syncing/scanresult/scanStats";
|
|
22
|
+
export * from "./scanning-syncing/scanresult/scanCache";
|
|
23
|
+
export * from "./keypairs-seeds/writeKeypairs";
|
|
24
|
+
export * from "./keypairs-seeds/keypairs";
|
|
25
|
+
export * from "./send-functionality/conversion";
|
|
26
|
+
export * from "./send-functionality/inputSelection";
|
|
27
|
+
export * from "./tools/monero-tools";
|
package/dist/api.js
CHANGED
|
@@ -1,177 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import "./io/indexedDB";
|
|
2
|
+
export { NodeUrl } from "./node-interaction/nodeUrl";
|
|
3
|
+
export { ViewPair } from "./viewpair/ViewPair";
|
|
4
|
+
export { ScanCacheOpened, ManyScanCachesOpened, } from "./scanning-syncing/scanresult/scanCacheOpened";
|
|
4
5
|
export * from "./node-interaction/binaryEndpoints";
|
|
5
6
|
export * from "./node-interaction/jsonEndpoints";
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return viewPair;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* This function helps with making requests to the get_blocks.bin endpoint of the Monerod nodes. It does the Request and returns the outputs that belong to the ViewPair.
|
|
29
|
-
* (if outputs are found in the blocks that are returned)
|
|
30
|
-
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin
|
|
31
|
-
* @param params params that will be turned into epee (monero lib that does binary serialization)
|
|
32
|
-
* @param metaCallBack contains meta information about the getBlocksbin call (new sync height = start_height param + number of blocks)
|
|
33
|
-
* @returns The difference to the same method on NodeUrl is: It returns {@link ScanResult} (outputs that belong to viewpair) and not just the blocks as json.
|
|
34
|
-
*/
|
|
35
|
-
getBlocksBin(params, metaCallBack) {
|
|
36
|
-
return getBlocksBinScan(this, params, metaCallBack);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* This function helps with making requests to the get_blocks.bin endpoint of the Monerod nodes.
|
|
40
|
-
* The difference compared to the getBlocksBin method is that it returns a Uint8Array that still has to be scanned for outputs.
|
|
41
|
-
* This is useful if you want to scan multiple viewpairs at once. You can take the Uint8Array and pass it to another ViewPair to scan for outputs.
|
|
42
|
-
* @param params params that will be turned into epee (monero lib that does binary serialization)
|
|
43
|
-
* @returns This method will return a Uint8Array that can subsequently be scanned for outputs with the getBlocksBinScanResponse method.
|
|
44
|
-
*/
|
|
45
|
-
async getBlocksBinExecuteRequest(params) {
|
|
46
|
-
return await getBlocksBinExecuteRequest(this, params);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* This function helps with scanning the response of the getBlocksBinExecuteRequest method.
|
|
50
|
-
* It will parse the Uint8Array and return the outputs that belong to the ViewPair.
|
|
51
|
-
* (if outputs are found in the blocks that are contained in the Uint8Array that was returned by the getBlocksBinExecuteRequest method)
|
|
52
|
-
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin
|
|
53
|
-
* @param getBlocksBinResponseBuffer the Uint8Array that was returned by the getBlocksBinExecuteRequest method.(which contains the blocks in binary format, returned from the Monerod node)
|
|
54
|
-
* @param metaCallBack contains meta information about the getBlocksbin call (new sync height = start_height param + number of blocks)
|
|
55
|
-
* @returns It returns {@link ScanResult} (outputs that belong to viewpair)
|
|
56
|
-
*/
|
|
57
|
-
getBlocksBinScanResponse(getBlocksBinResponseBuffer, metaCallBack) {
|
|
58
|
-
return getBlocksBinScanResponse(this, getBlocksBinResponseBuffer, metaCallBack);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* This method will use getBlocks.bin from start height to daemon height.
|
|
62
|
-
* This is CPU bound work, so it should be executed in a seperate thread (worker).
|
|
63
|
-
* The scanner.ts worker in the standard-checkout dir shows how to keep scanning after the tip is reached.
|
|
64
|
-
* It also shows how the outputs are saved (note the unqiue requirement for the stealth_adress).
|
|
65
|
-
* @param start_height the height to start syncing from.
|
|
66
|
-
* @param callback this function will get the new outputs as they are found as a parameter
|
|
67
|
-
*/
|
|
68
|
-
async scan(start_height, callback) {
|
|
69
|
-
let latest_meta = {
|
|
70
|
-
new_height: start_height,
|
|
71
|
-
daemon_height: start_height + 1,
|
|
72
|
-
status: "",
|
|
73
|
-
primary_address: "",
|
|
74
|
-
};
|
|
75
|
-
while (latest_meta.new_height < latest_meta.daemon_height) {
|
|
76
|
-
const res = await this.getBlocksBin({
|
|
77
|
-
start_height: latest_meta.new_height - 1,
|
|
78
|
-
}, (meta) => {
|
|
79
|
-
latest_meta = meta;
|
|
80
|
-
});
|
|
81
|
-
callback(res);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* This method makes an integrated Address for the Address of the Viewpair it was opened with.
|
|
86
|
-
* The network (mainnet, stagenet, testnet) is the same as the one of the Viewpairaddress.
|
|
87
|
-
* @param paymentId (u64 under the hood) you can use a random number or a primary key of an sqlite db to associate payments with customer sessions.
|
|
88
|
-
* @returns Adressstring
|
|
89
|
-
*/
|
|
90
|
-
makeIntegratedAddress(paymentId) {
|
|
91
|
-
let address = "";
|
|
92
|
-
this.readFromWasmMemory = (ptr, len) => {
|
|
93
|
-
address = this.readString(ptr, len);
|
|
94
|
-
};
|
|
95
|
-
//@ts-ignore
|
|
96
|
-
this.tinywasi.instance.exports.make_integrated_address(BigInt(paymentId));
|
|
97
|
-
return address;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* This class is useful to interact with Moneros DaemonRpc binary requests in a convenient way.
|
|
102
|
-
* (similar to how you would interact with a REST api that gives you json back.)
|
|
103
|
-
* The wasm part will handle the creation of the binary requests and parse the responses and return them as json.
|
|
104
|
-
* {@link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin}
|
|
105
|
-
*/
|
|
106
|
-
export class NodeUrl extends WasmProcessor {
|
|
107
|
-
static async create(node_url) {
|
|
108
|
-
const nodeUrl = new NodeUrl(new TinyWASI(), node_url || "http://localhost:38081");
|
|
109
|
-
await nodeUrl.initWasmModule();
|
|
110
|
-
return nodeUrl;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* This request helps making requests to the get_blocks.bin endpoint of the Monerod nodes.
|
|
114
|
-
* @link https://docs.getmonero.org/rpc-library/monerod-rpc/#get_blocksbin
|
|
115
|
-
* @param params params that will be turned into epee (moner lib that does binary serialization)
|
|
116
|
-
* @returns after the request is made it will return epee serialized objects that are then parsed into json.
|
|
117
|
-
*/
|
|
118
|
-
getBlocksBin(params) {
|
|
119
|
-
return getBlocksBinJson(this, params);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* The ViewPairs class contains a set of ViewPair objects that can be used to scan multiple addresses at once.
|
|
124
|
-
* (while only retrieving the blocks from the node once)
|
|
125
|
-
*/
|
|
126
|
-
export class ViewPairs {
|
|
127
|
-
viewPairs;
|
|
128
|
-
constructor() {
|
|
129
|
-
this.viewPairs = new Map();
|
|
130
|
-
}
|
|
131
|
-
static async create(pairs, node_url) {
|
|
132
|
-
const viewPairs = new ViewPairs();
|
|
133
|
-
for (const element of pairs) {
|
|
134
|
-
const viewPair = await ViewPair.create(element.primary_address, element.secret_view_key, node_url);
|
|
135
|
-
viewPairs.viewPairs.set(element.primary_address, viewPair);
|
|
136
|
-
}
|
|
137
|
-
return viewPairs;
|
|
138
|
-
}
|
|
139
|
-
async addViewPair(primary_address, secret_view_key, node_url) {
|
|
140
|
-
const viewPair = await ViewPair.create(primary_address, secret_view_key, node_url);
|
|
141
|
-
this.viewPairs.set(primary_address, viewPair);
|
|
142
|
-
return viewPair;
|
|
143
|
-
}
|
|
144
|
-
getViewPair(primary_address) {
|
|
145
|
-
return this.viewPairs.get(primary_address);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* This method will use getBlocks.bin from start height to daemon height.
|
|
149
|
-
* This is CPU bound work, so it should be executed in a seperate thread (worker).
|
|
150
|
-
* The scanner.ts worker in the standard-checkout dir shows how to keep scanning after the tip is reached.
|
|
151
|
-
* It also shows how the outputs are saved (note the unqiue requirement for the stealth_adress).
|
|
152
|
-
* @param start_height the height to start syncing from.
|
|
153
|
-
* @param callback this function will get the new outputs as they are found as a parameter
|
|
154
|
-
*/
|
|
155
|
-
async scan(start_height, callback) {
|
|
156
|
-
let latest_meta = {
|
|
157
|
-
new_height: start_height,
|
|
158
|
-
daemon_height: start_height + 1,
|
|
159
|
-
status: "",
|
|
160
|
-
primary_address: "",
|
|
161
|
-
};
|
|
162
|
-
while (latest_meta.new_height < latest_meta.daemon_height) {
|
|
163
|
-
let firstResponse;
|
|
164
|
-
for (const [key, value] of this.viewPairs) {
|
|
165
|
-
if (!firstResponse) {
|
|
166
|
-
firstResponse = await value.getBlocksBinExecuteRequest({
|
|
167
|
-
start_height: latest_meta.new_height - 1,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
const res = await value.getBlocksBinScanResponse(firstResponse, (meta) => {
|
|
171
|
-
latest_meta = meta;
|
|
172
|
-
});
|
|
173
|
-
callback(res);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
7
|
+
export * from "./io/readDir";
|
|
8
|
+
export * from "./io/atomicWrite";
|
|
9
|
+
export * from "./io/sleep";
|
|
10
|
+
export { writeScanSettings, readScanSettings, } from "./scanning-syncing/scanSettings";
|
|
11
|
+
export { signTransaction, parseAddress, } from "./send-functionality/transactionBuilding";
|
|
12
|
+
export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
|
|
13
|
+
export { scanWallets, startWebworker, createWebworker, makeWebworkerScript, } from "./scanning-syncing/backgroundWorker";
|
|
14
|
+
export { spendable } from "./scanning-syncing/scanresult/scanResult";
|
|
15
|
+
export { openWallets, openWallet } from "./scanning-syncing/openWallet";
|
|
16
|
+
export * from "./scanning-syncing/connectionStatus";
|
|
17
|
+
export * from "./scanning-syncing/scanSettings";
|
|
18
|
+
export * from "./scanning-syncing/scanresult/scanResult";
|
|
19
|
+
export * from "./scanning-syncing/scanresult/scanStats";
|
|
20
|
+
export * from "./scanning-syncing/scanresult/scanCache";
|
|
21
|
+
export * from "./keypairs-seeds/writeKeypairs";
|
|
22
|
+
export * from "./keypairs-seeds/keypairs";
|
|
23
|
+
export * from "./send-functionality/conversion";
|
|
24
|
+
export * from "./send-functionality/inputSelection";
|
|
25
|
+
export * from "./tools/monero-tools";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface Bun {
|
|
2
|
+
stdin: BunFile;
|
|
3
|
+
stdout: BunFile;
|
|
4
|
+
stderr: BunFile;
|
|
5
|
+
file(path: string | number | URL, options?: {
|
|
6
|
+
type?: string;
|
|
7
|
+
}): BunFile;
|
|
8
|
+
write(destination: string | number | BunFile | URL, input: string | Blob | ArrayBuffer | SharedArrayBuffer | TypedArray | Response): Promise<number>;
|
|
9
|
+
}
|
|
10
|
+
export interface BunFile {
|
|
11
|
+
readonly size: number;
|
|
12
|
+
readonly type: string;
|
|
13
|
+
text(): Promise<string>;
|
|
14
|
+
stream(): ReadableStream;
|
|
15
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
16
|
+
json(): Promise<any>;
|
|
17
|
+
writer(params: {
|
|
18
|
+
highWaterMark?: number;
|
|
19
|
+
}): FileSink;
|
|
20
|
+
exists(): Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
export interface FileSink {
|
|
23
|
+
write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number | Promise<number>;
|
|
24
|
+
flush(): number | Promise<number>;
|
|
25
|
+
end(error?: Error): number | Promise<number>;
|
|
26
|
+
start(options?: {
|
|
27
|
+
highWaterMark?: number;
|
|
28
|
+
}): void;
|
|
29
|
+
ref(): void;
|
|
30
|
+
unref(): void;
|
|
31
|
+
}
|
|
32
|
+
export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Uint8ClampedArray;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export async function atomicWrite(targetPath, data) {
|
|
2
|
+
// in the browser we don't have rename + indexedDB writes are atomic in any case
|
|
3
|
+
if (areWeInTheBrowser)
|
|
4
|
+
return await Bun.write(targetPath, data);
|
|
5
|
+
const { rename } = await import("node:fs/promises");
|
|
6
|
+
const tempPath = targetPath + ".tmp";
|
|
7
|
+
const bytesWritten = await Bun.write(tempPath, data);
|
|
8
|
+
await rename(tempPath, targetPath);
|
|
9
|
+
return bytesWritten;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ExtensionRuntime {
|
|
2
|
+
id: string;
|
|
3
|
+
connect?: (extensionId?: string) => any;
|
|
4
|
+
sendMessage?: (message: any) => Promise<any> | ((callback: (response: any) => void) => void);
|
|
5
|
+
}
|
|
6
|
+
interface Chrome {
|
|
7
|
+
runtime?: ExtensionRuntime;
|
|
8
|
+
}
|
|
9
|
+
interface Browser {
|
|
10
|
+
runtime?: ExtensionRuntime;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
var chrome: Chrome | undefined;
|
|
14
|
+
var browser: Browser | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function isExtensionContext(): boolean;
|
|
17
|
+
export declare function getRuntime(): ExtensionRuntime | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function isExtensionContext() {
|
|
2
|
+
return !!((typeof chrome !== "undefined" && chrome.runtime?.id) ||
|
|
3
|
+
(typeof browser !== "undefined" && browser.runtime?.id));
|
|
4
|
+
}
|
|
5
|
+
export function getRuntime() {
|
|
6
|
+
if (chrome?.runtime?.id)
|
|
7
|
+
return chrome.runtime;
|
|
8
|
+
if (browser?.runtime?.id)
|
|
9
|
+
return browser.runtime;
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BunFile, Bun, TypedArray } from "./BunFileInterface";
|
|
2
|
+
export type PossibleBunFileContent = string | Blob | ArrayBuffer | SharedArrayBuffer | TypedArray | Response;
|
|
3
|
+
declare class IndexedDBBun implements Bun {
|
|
4
|
+
stdin: BunFile;
|
|
5
|
+
stdout: BunFile;
|
|
6
|
+
stderr: BunFile;
|
|
7
|
+
file(path: string | number | URL, options?: {
|
|
8
|
+
type?: string;
|
|
9
|
+
}): BunFile;
|
|
10
|
+
write(destination: string | number | BunFile | URL, input: PossibleBunFileContent): Promise<number>;
|
|
11
|
+
env: BunEnv;
|
|
12
|
+
}
|
|
13
|
+
export type BunEnv = {
|
|
14
|
+
[key: string]: string | undefined;
|
|
15
|
+
TZ?: string | undefined;
|
|
16
|
+
NODE_ENV?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type IndexedDBItem = string | Blob | ArrayBufferLike | ArrayBuffer | SharedArrayBuffer;
|
|
19
|
+
export declare function getItemLength(input: PossibleBunFileContent): Promise<[IndexedDBItem, number]>;
|
|
20
|
+
export declare function putFileIntoIndexedDB(path: string, content: PossibleBunFileContent): Promise<number>;
|
|
21
|
+
export declare function getFileFromIndexedDB(path: string): Promise<unknown>;
|
|
22
|
+
export declare function deleteFileFromIndexedDB(path: string): Promise<void>;
|
|
23
|
+
export declare const fileStoreName = "files";
|
|
24
|
+
export type BrowserGlobal = {
|
|
25
|
+
filesDb?: IDBDatabase;
|
|
26
|
+
Bun: IndexedDBBun;
|
|
27
|
+
areWeInTheBrowser: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare global {
|
|
30
|
+
var areWeInTheBrowser: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function refreshEnvIndexedDB(): Promise<void>;
|
|
33
|
+
export declare function writeEnvIndexedDB(key: string, value: string): Promise<void>;
|
|
34
|
+
export declare function readEnvIndexedDB(): Promise<{
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* useless function
|
|
39
|
+
* you can just do process.env[key] instead. Look at the code above.
|
|
40
|
+
* @param key
|
|
41
|
+
* @returns value
|
|
42
|
+
*/
|
|
43
|
+
export declare function readEnvIndexedDBLine(key: string): Promise<string>;
|
|
44
|
+
export declare function readdir(dirpath: string): Promise<string[]>;
|
|
45
|
+
export {};
|