onekey-monero-runtime 0.1.0-alpha.2 → 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.
@@ -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, reservation_id: string, chain_tip: bigint, outgoing_atomic?: string | null, change_atomic?: string | null): Promise<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, build and reserve. Needs no spend private key; does not broadcast.
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 `{ reservationId, signableHex, feeAtomic, amountAtomic, changeAtomic,
112
- * inputsAtomic, inputCount }`. `feeAtomic` and `amountAtomic` are what the
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
- * Failure leaves no reservation. On success the host must call `signTransaction` +
116
- * `broadcastTransaction`, or `releaseReservation`; otherwise the inputs stay locked.
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, reservation_id: string, chain_tip: bigint, priority: string): Promise<string>;
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
  */
@@ -214,7 +204,7 @@ export interface InitOutput {
214
204
  readonly memory: WebAssembly.Memory;
215
205
  readonly addAccount: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => [number, number, number, number];
216
206
  readonly balance: (a: bigint, b: number, c: bigint) => [number, number, number, number];
217
- readonly broadcastTransaction: (a: bigint, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => any;
207
+ readonly broadcastTransaction: (a: bigint, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number) => any;
218
208
  readonly chainTip: () => any;
219
209
  readonly closeWallet: () => [number, number];
220
210
  readonly deleteWallet: (a: number, b: number) => any;
@@ -226,11 +216,9 @@ export interface InitOutput {
226
216
  readonly importKeyImages: (a: bigint, b: number, c: number) => [number, number, number, number];
227
217
  readonly init: () => any;
228
218
  readonly listAccounts: () => [number, number, number, number];
229
- readonly markReservationSigned: (a: number, b: number, c: number) => [number, number, number, number];
230
219
  readonly openWallet: (a: number, b: number, c: number, d: number) => [number, number, number, number];
231
- readonly prepareTransaction: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number) => any;
220
+ readonly prepareTransaction: (a: bigint, b: number, c: number, d: number, e: bigint, f: number, g: number) => any;
232
221
  readonly registerSubaddress: (a: bigint, b: number, c: number, d: number, e: number) => [number, number, number, number];
233
- readonly releaseReservation: (a: number, b: number) => [number, number, number, number];
234
222
  readonly removeAccount: (a: number, b: number) => [number, number, number, number];
235
223
  readonly rewindTo: (a: bigint, b: bigint, c: bigint) => [number, number, number, number];
236
224
  readonly setNodeUrl: (a: number, b: number) => any;
@@ -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, reservation_id, chain_tip, outgoing_atomic, change_atomic) {
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
- const ptr1 = passStringToWasm0(reservation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
83
- const len1 = WASM_VECTOR_LEN;
84
- var ptr2 = isLikeNone(outgoing_atomic) ? 0 : passStringToWasm0(outgoing_atomic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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
- var ptr3 = isLikeNone(change_atomic) ? 0 : passStringToWasm0(change_atomic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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, build and reserve. Needs no spend private key; does not broadcast.
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 `{ reservationId, signableHex, feeAtomic, amountAtomic, changeAtomic,
391
- * inputsAtomic, inputCount }`. `feeAtomic` and `amountAtomic` are what the
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
- * Failure leaves no reservation. On success the host must call `signTransaction` +
395
- * `broadcastTransaction`, or `releaseReservation`; otherwise the inputs stay locked.
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, reservation_id, chain_tip, priority) {
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(reservation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
376
+ const ptr1 = passStringToWasm0(priority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
408
377
  const len1 = WASM_VECTOR_LEN;
409
- const ptr2 = passStringToWasm0(priority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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
@@ -1174,12 +1115,12 @@ function __wbg_get_imports() {
1174
1115
  return ret;
1175
1116
  }, arguments); },
1176
1117
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1177
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 941, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
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`.
1178
1119
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7657f6f35500acf9);
1179
1120
  return ret;
1180
1121
  },
1181
1122
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1182
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 296, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1123
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 293, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1183
1124
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h38334fab7c782151);
1184
1125
  return ret;
1185
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.2",
5
+ "version": "0.1.0-alpha.3",
6
6
  "license": "Apache-2.0",
7
7
  "files": [
8
8
  "onekey_monero_runtime.js",