onekey-monero-runtime 0.1.0-alpha.1 → 0.1.0-alpha.3
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/onekey_monero_runtime.d.ts +16 -21
- package/onekey_monero_runtime.js +28 -74
- package/onekey_monero_runtime_bg.wasm +0 -0
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ export function balance(account_id: bigint, chain_tip?: bigint | null): string;
|
|
|
22
22
|
* are marked, the transaction goes in flight, and `broadcast: accepted | unknown` is
|
|
23
23
|
* returned. Only an explicit node rejection errors and releases the inputs.
|
|
24
24
|
*/
|
|
25
|
-
export function broadcastTransaction(account_id: bigint, raw_hex: string,
|
|
25
|
+
export function broadcastTransaction(account_id: bigint, raw_hex: string, chain_tip: bigint, outgoing_atomic?: string | null, change_atomic?: string | null): Promise<string>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Fetch the chain tip. Does not require an open wallet DB: account creation needs
|
|
@@ -89,18 +89,13 @@ export function init(): Promise<void>;
|
|
|
89
89
|
|
|
90
90
|
export function listAccounts(): string;
|
|
91
91
|
|
|
92
|
-
/**
|
|
93
|
-
* Called before signing; every selected input must still belong to this review.
|
|
94
|
-
*/
|
|
95
|
-
export function markReservationSigned(reservation_id: string, expected_inputs: number): string;
|
|
96
|
-
|
|
97
92
|
/**
|
|
98
93
|
* Open (or create) a wallet DB.
|
|
99
94
|
*/
|
|
100
95
|
export function openWallet(db_name: string, network: string): string;
|
|
101
96
|
|
|
102
97
|
/**
|
|
103
|
-
* Select inputs
|
|
98
|
+
* Select inputs and build. Needs no spend private key; does not broadcast.
|
|
104
99
|
*
|
|
105
100
|
* `recipientsJson` is `[{ "address": "...", "amountAtomic": "1000000000000" }]`.
|
|
106
101
|
*
|
|
@@ -108,25 +103,20 @@ export function openWallet(db_name: string, network: string): string;
|
|
|
108
103
|
* spendable total minus fee; the passed amount is ignored. Merely omitting change
|
|
109
104
|
* would fold the remainder into the fee.
|
|
110
105
|
*
|
|
111
|
-
* Returns `{
|
|
112
|
-
*
|
|
106
|
+
* Returns `{ signableHex, feeAtomic, amountAtomic, changeAtomic, inputsAtomic,
|
|
107
|
+
* inputCount }`. `feeAtomic` and `amountAtomic` are what the
|
|
113
108
|
* transaction will use: the confirmation page shows them and signing keeps them.
|
|
114
109
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
110
|
+
* Inputs are not reserved: a second prepare before broadcast may select the same
|
|
111
|
+
* ones, and broadcast then refuses the later transaction as `inputAlreadySpent`.
|
|
117
112
|
*/
|
|
118
|
-
export function prepareTransaction(account_id: bigint, recipients_json: string, max_send: boolean,
|
|
113
|
+
export function prepareTransaction(account_id: bigint, recipients_json: string, max_send: boolean, chain_tip: bigint, priority: string): Promise<string>;
|
|
119
114
|
|
|
120
115
|
/**
|
|
121
116
|
* Register a subaddress and return its address. Funds to unregistered subaddresses go undetected.
|
|
122
117
|
*/
|
|
123
118
|
export function registerSubaddress(account_id: bigint, major: number, minor: number, label?: string | null): string;
|
|
124
119
|
|
|
125
|
-
/**
|
|
126
|
-
* Release a reservation (user cancelled or construction failed).
|
|
127
|
-
*/
|
|
128
|
-
export function releaseReservation(reservation_id: string): string;
|
|
129
|
-
|
|
130
120
|
/**
|
|
131
121
|
* Delete an identity and all its data. Irreversible.
|
|
132
122
|
*/
|
|
@@ -143,6 +133,7 @@ export function rewindTo(account_id: bigint, height: bigint, tip: bigint): strin
|
|
|
143
133
|
*
|
|
144
134
|
* The old node is dropped before connecting the new one: a replaced or disabled
|
|
145
135
|
* node must receive no further requests, even if the new one fails to connect.
|
|
136
|
+
* If calls overlap, the last one wins.
|
|
146
137
|
*/
|
|
147
138
|
export function setNodeUrl(url: string): Promise<void>;
|
|
148
139
|
|
|
@@ -173,6 +164,11 @@ export function signTransaction(signable_hex: string, spend_private_key_hex: str
|
|
|
173
164
|
*/
|
|
174
165
|
export function spendScalar(bip32_private_key_hex: string): string;
|
|
175
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
169
|
+
*/
|
|
170
|
+
export function storageRequiresWorkerRestart(): boolean;
|
|
171
|
+
|
|
176
172
|
/**
|
|
177
173
|
* Read-only scan progress; no network requests. Shows which ranges sync intends to scan.
|
|
178
174
|
*/
|
|
@@ -208,7 +204,7 @@ export interface InitOutput {
|
|
|
208
204
|
readonly memory: WebAssembly.Memory;
|
|
209
205
|
readonly addAccount: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => [number, number, number, number];
|
|
210
206
|
readonly balance: (a: bigint, b: number, c: bigint) => [number, number, number, number];
|
|
211
|
-
readonly broadcastTransaction: (a: bigint, b: number, c: number, d:
|
|
207
|
+
readonly broadcastTransaction: (a: bigint, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number) => any;
|
|
212
208
|
readonly chainTip: () => any;
|
|
213
209
|
readonly closeWallet: () => [number, number];
|
|
214
210
|
readonly deleteWallet: (a: number, b: number) => any;
|
|
@@ -220,17 +216,16 @@ export interface InitOutput {
|
|
|
220
216
|
readonly importKeyImages: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
221
217
|
readonly init: () => any;
|
|
222
218
|
readonly listAccounts: () => [number, number, number, number];
|
|
223
|
-
readonly markReservationSigned: (a: number, b: number, c: number) => [number, number, number, number];
|
|
224
219
|
readonly openWallet: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
225
|
-
readonly prepareTransaction: (a: bigint, b: number, c: number, d: number, e:
|
|
220
|
+
readonly prepareTransaction: (a: bigint, b: number, c: number, d: number, e: bigint, f: number, g: number) => any;
|
|
226
221
|
readonly registerSubaddress: (a: bigint, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
227
|
-
readonly releaseReservation: (a: number, b: number) => [number, number, number, number];
|
|
228
222
|
readonly removeAccount: (a: number, b: number) => [number, number, number, number];
|
|
229
223
|
readonly rewindTo: (a: bigint, b: bigint, c: bigint) => [number, number, number, number];
|
|
230
224
|
readonly setNodeUrl: (a: number, b: number) => any;
|
|
231
225
|
readonly setRequestHandler: (a: number) => void;
|
|
232
226
|
readonly signTransaction: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
233
227
|
readonly spendScalar: (a: number, b: number) => [number, number, number, number];
|
|
228
|
+
readonly storageRequiresWorkerRestart: () => number;
|
|
234
229
|
readonly syncPeek: (a: bigint) => [number, number, number, number];
|
|
235
230
|
readonly syncStep: (a: bigint, b: bigint) => any;
|
|
236
231
|
readonly transactionDetails: (a: bigint, b: number, c: number) => [number, number, number, number];
|
package/onekey_monero_runtime.js
CHANGED
|
@@ -70,22 +70,19 @@ export function balance(account_id, chain_tip) {
|
|
|
70
70
|
* returned. Only an explicit node rejection errors and releases the inputs.
|
|
71
71
|
* @param {bigint} account_id
|
|
72
72
|
* @param {string} raw_hex
|
|
73
|
-
* @param {string} reservation_id
|
|
74
73
|
* @param {bigint} chain_tip
|
|
75
74
|
* @param {string | null} [outgoing_atomic]
|
|
76
75
|
* @param {string | null} [change_atomic]
|
|
77
76
|
* @returns {Promise<string>}
|
|
78
77
|
*/
|
|
79
|
-
export function broadcastTransaction(account_id, raw_hex,
|
|
78
|
+
export function broadcastTransaction(account_id, raw_hex, chain_tip, outgoing_atomic, change_atomic) {
|
|
80
79
|
const ptr0 = passStringToWasm0(raw_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
81
80
|
const len0 = WASM_VECTOR_LEN;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var ptr2 = isLikeNone(
|
|
81
|
+
var ptr1 = isLikeNone(outgoing_atomic) ? 0 : passStringToWasm0(outgoing_atomic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
82
|
+
var len1 = WASM_VECTOR_LEN;
|
|
83
|
+
var ptr2 = isLikeNone(change_atomic) ? 0 : passStringToWasm0(change_atomic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
85
84
|
var len2 = WASM_VECTOR_LEN;
|
|
86
|
-
|
|
87
|
-
var len3 = WASM_VECTOR_LEN;
|
|
88
|
-
const ret = wasm.broadcastTransaction(account_id, ptr0, len0, ptr1, len1, chain_tip, ptr2, len2, ptr3, len3);
|
|
85
|
+
const ret = wasm.broadcastTransaction(account_id, ptr0, len0, chain_tip, ptr1, len1, ptr2, len2);
|
|
89
86
|
return ret;
|
|
90
87
|
}
|
|
91
88
|
|
|
@@ -322,33 +319,6 @@ export function listAccounts() {
|
|
|
322
319
|
}
|
|
323
320
|
}
|
|
324
321
|
|
|
325
|
-
/**
|
|
326
|
-
* Called before signing; every selected input must still belong to this review.
|
|
327
|
-
* @param {string} reservation_id
|
|
328
|
-
* @param {number} expected_inputs
|
|
329
|
-
* @returns {string}
|
|
330
|
-
*/
|
|
331
|
-
export function markReservationSigned(reservation_id, expected_inputs) {
|
|
332
|
-
let deferred3_0;
|
|
333
|
-
let deferred3_1;
|
|
334
|
-
try {
|
|
335
|
-
const ptr0 = passStringToWasm0(reservation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
-
const len0 = WASM_VECTOR_LEN;
|
|
337
|
-
const ret = wasm.markReservationSigned(ptr0, len0, expected_inputs);
|
|
338
|
-
var ptr2 = ret[0];
|
|
339
|
-
var len2 = ret[1];
|
|
340
|
-
if (ret[3]) {
|
|
341
|
-
ptr2 = 0; len2 = 0;
|
|
342
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
343
|
-
}
|
|
344
|
-
deferred3_0 = ptr2;
|
|
345
|
-
deferred3_1 = len2;
|
|
346
|
-
return getStringFromWasm0(ptr2, len2);
|
|
347
|
-
} finally {
|
|
348
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
322
|
/**
|
|
353
323
|
* Open (or create) a wallet DB.
|
|
354
324
|
* @param {string} db_name
|
|
@@ -379,7 +349,7 @@ export function openWallet(db_name, network) {
|
|
|
379
349
|
}
|
|
380
350
|
|
|
381
351
|
/**
|
|
382
|
-
* Select inputs
|
|
352
|
+
* Select inputs and build. Needs no spend private key; does not broadcast.
|
|
383
353
|
*
|
|
384
354
|
* `recipientsJson` is `[{ "address": "...", "amountAtomic": "1000000000000" }]`.
|
|
385
355
|
*
|
|
@@ -387,28 +357,25 @@ export function openWallet(db_name, network) {
|
|
|
387
357
|
* spendable total minus fee; the passed amount is ignored. Merely omitting change
|
|
388
358
|
* would fold the remainder into the fee.
|
|
389
359
|
*
|
|
390
|
-
* Returns `{
|
|
391
|
-
*
|
|
360
|
+
* Returns `{ signableHex, feeAtomic, amountAtomic, changeAtomic, inputsAtomic,
|
|
361
|
+
* inputCount }`. `feeAtomic` and `amountAtomic` are what the
|
|
392
362
|
* transaction will use: the confirmation page shows them and signing keeps them.
|
|
393
363
|
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
364
|
+
* Inputs are not reserved: a second prepare before broadcast may select the same
|
|
365
|
+
* ones, and broadcast then refuses the later transaction as `inputAlreadySpent`.
|
|
396
366
|
* @param {bigint} account_id
|
|
397
367
|
* @param {string} recipients_json
|
|
398
368
|
* @param {boolean} max_send
|
|
399
|
-
* @param {string} reservation_id
|
|
400
369
|
* @param {bigint} chain_tip
|
|
401
370
|
* @param {string} priority
|
|
402
371
|
* @returns {Promise<string>}
|
|
403
372
|
*/
|
|
404
|
-
export function prepareTransaction(account_id, recipients_json, max_send,
|
|
373
|
+
export function prepareTransaction(account_id, recipients_json, max_send, chain_tip, priority) {
|
|
405
374
|
const ptr0 = passStringToWasm0(recipients_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
375
|
const len0 = WASM_VECTOR_LEN;
|
|
407
|
-
const ptr1 = passStringToWasm0(
|
|
376
|
+
const ptr1 = passStringToWasm0(priority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
377
|
const len1 = WASM_VECTOR_LEN;
|
|
409
|
-
const
|
|
410
|
-
const len2 = WASM_VECTOR_LEN;
|
|
411
|
-
const ret = wasm.prepareTransaction(account_id, ptr0, len0, max_send, ptr1, len1, chain_tip, ptr2, len2);
|
|
378
|
+
const ret = wasm.prepareTransaction(account_id, ptr0, len0, max_send, chain_tip, ptr1, len1);
|
|
412
379
|
return ret;
|
|
413
380
|
}
|
|
414
381
|
|
|
@@ -441,32 +408,6 @@ export function registerSubaddress(account_id, major, minor, label) {
|
|
|
441
408
|
}
|
|
442
409
|
}
|
|
443
410
|
|
|
444
|
-
/**
|
|
445
|
-
* Release a reservation (user cancelled or construction failed).
|
|
446
|
-
* @param {string} reservation_id
|
|
447
|
-
* @returns {string}
|
|
448
|
-
*/
|
|
449
|
-
export function releaseReservation(reservation_id) {
|
|
450
|
-
let deferred3_0;
|
|
451
|
-
let deferred3_1;
|
|
452
|
-
try {
|
|
453
|
-
const ptr0 = passStringToWasm0(reservation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
454
|
-
const len0 = WASM_VECTOR_LEN;
|
|
455
|
-
const ret = wasm.releaseReservation(ptr0, len0);
|
|
456
|
-
var ptr2 = ret[0];
|
|
457
|
-
var len2 = ret[1];
|
|
458
|
-
if (ret[3]) {
|
|
459
|
-
ptr2 = 0; len2 = 0;
|
|
460
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
461
|
-
}
|
|
462
|
-
deferred3_0 = ptr2;
|
|
463
|
-
deferred3_1 = len2;
|
|
464
|
-
return getStringFromWasm0(ptr2, len2);
|
|
465
|
-
} finally {
|
|
466
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
411
|
/**
|
|
471
412
|
* Delete an identity and all its data. Irreversible.
|
|
472
413
|
* @param {string} uuid
|
|
@@ -525,6 +466,7 @@ export function rewindTo(account_id, height, tip) {
|
|
|
525
466
|
*
|
|
526
467
|
* The old node is dropped before connecting the new one: a replaced or disabled
|
|
527
468
|
* node must receive no further requests, even if the new one fails to connect.
|
|
469
|
+
* If calls overlap, the last one wins.
|
|
528
470
|
* @param {string} url
|
|
529
471
|
* @returns {Promise<void>}
|
|
530
472
|
*/
|
|
@@ -613,6 +555,15 @@ export function spendScalar(bip32_private_key_hex) {
|
|
|
613
555
|
}
|
|
614
556
|
}
|
|
615
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
560
|
+
* @returns {boolean}
|
|
561
|
+
*/
|
|
562
|
+
export function storageRequiresWorkerRestart() {
|
|
563
|
+
const ret = wasm.storageRequiresWorkerRestart();
|
|
564
|
+
return ret !== 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
616
567
|
/**
|
|
617
568
|
* Read-only scan progress; no network requests. Shows which ranges sync intends to scan.
|
|
618
569
|
* @param {bigint} account_id
|
|
@@ -807,6 +758,9 @@ function __wbg_get_imports() {
|
|
|
807
758
|
const ret = clearTimeout(arg0);
|
|
808
759
|
return ret;
|
|
809
760
|
},
|
|
761
|
+
__wbg_close_cffebe146c546247: function(arg0) {
|
|
762
|
+
arg0.close();
|
|
763
|
+
},
|
|
810
764
|
__wbg_createSyncAccessHandle_e383ed6b08d0e3ee: function(arg0) {
|
|
811
765
|
const ret = arg0.createSyncAccessHandle();
|
|
812
766
|
return ret;
|
|
@@ -1161,12 +1115,12 @@ function __wbg_get_imports() {
|
|
|
1161
1115
|
return ret;
|
|
1162
1116
|
}, arguments); },
|
|
1163
1117
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1164
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1118
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 938, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1165
1119
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7657f6f35500acf9);
|
|
1166
1120
|
return ret;
|
|
1167
1121
|
},
|
|
1168
1122
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1169
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
1123
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 293, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1170
1124
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h38334fab7c782151);
|
|
1171
1125
|
return ret;
|
|
1172
1126
|
},
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "onekey-monero-runtime",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "OneKey Monero Runtime: wallet state over monero-oxide, persisted in SQLite",
|
|
5
|
-
"version": "0.1.0-alpha.
|
|
5
|
+
"version": "0.1.0-alpha.3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"onekey_monero_runtime.js",
|