onekey-monero-runtime 0.1.0-alpha.4 → 0.1.0-alpha.6
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 +14 -18
- package/onekey_monero_runtime.js +20 -44
- package/onekey_monero_runtime_bg.wasm +0 -0
- package/package.json +1 -1
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Register an identity (view key pair).
|
|
6
6
|
*
|
|
7
|
-
* `spendPublicKeyHex` and `viewPrivateKeyHex` are 32-byte hex.
|
|
8
|
-
*
|
|
7
|
+
* `spendPublicKeyHex` and `viewPrivateKeyHex` are 32-byte hex. No spend secret
|
|
8
|
+
* is taken here; see `signTransactionWithBip32Key`.
|
|
9
9
|
*/
|
|
10
10
|
export function addAccount(uuid: string, spend_public_key_hex: string, view_private_key_hex: string, birthday_height: bigint): string;
|
|
11
11
|
|
|
@@ -57,7 +57,7 @@ export function dependencyVersions(): string;
|
|
|
57
57
|
* Matches OneKey V4 (`spend = sc_reduce32(key)`, `view = keccak(spend)`). Changing
|
|
58
58
|
* it would show existing users an empty wallet after importing the same mnemonic.
|
|
59
59
|
*
|
|
60
|
-
* Does not return the spend private key
|
|
60
|
+
* Does not return the spend private key.
|
|
61
61
|
*/
|
|
62
62
|
export function deriveAccount(network: string, bip32_private_key_hex: string): string;
|
|
63
63
|
|
|
@@ -79,8 +79,11 @@ export function history(account_id: bigint, limit: number, offset: number): stri
|
|
|
79
79
|
* Call as early as possible after unlock. Until then the balance is too high: a
|
|
80
80
|
* view-only wallet cannot detect spends, so spent outputs still look unspent. This
|
|
81
81
|
* only affects blocks scanned afterwards; earlier spends need a rewind and rescan.
|
|
82
|
+
*
|
|
83
|
+
* Takes the account's BIP-32 key (as `deriveAccount`); the spend key is reduced
|
|
84
|
+
* here and wiped after use.
|
|
82
85
|
*/
|
|
83
|
-
export function
|
|
86
|
+
export function importKeyImagesWithBip32Key(account_id: bigint, bip32_private_key_hex: string): string;
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
89
|
* Install persistent storage. Must be called once before opening any DB.
|
|
@@ -143,26 +146,20 @@ export function setNodeUrl(url: string): Promise<void>;
|
|
|
143
146
|
* `handler` is `(url, contentType, body: Uint8Array) => Promise<Uint8Array>`;
|
|
144
147
|
* `undefined` uninstalls it.
|
|
145
148
|
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* background, desktop main process and mobile native code are not bound by those
|
|
149
|
-
* rules, so any node is reachable through them.
|
|
149
|
+
* Lets nodes that in-wasm fetch cannot reach (mixed content, no CORS headers) be
|
|
150
|
+
* used through the extension background, desktop main process or mobile native code.
|
|
150
151
|
*/
|
|
151
152
|
export function setRequestHandler(handler?: Function | null): void;
|
|
152
153
|
|
|
153
154
|
/**
|
|
154
155
|
* Sign a prepared transaction. No network, no DB, no broadcast.
|
|
155
156
|
*
|
|
156
|
-
*
|
|
157
|
+
* Takes the account's BIP-32 key (as `deriveAccount`); the spend key is reduced
|
|
158
|
+
* here, and both are wiped after use, never stored or returned.
|
|
157
159
|
* Returns `{ txid, rawHex, sizeBytes }`; the txid is fixed at signing, so the host
|
|
158
160
|
* can record the pending transaction before broadcasting.
|
|
159
161
|
*/
|
|
160
|
-
export function
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Spend scalar for signing, from a BIP-32 private key. Same reduction as `deriveAccount`.
|
|
164
|
-
*/
|
|
165
|
-
export function spendScalar(bip32_private_key_hex: string): string;
|
|
162
|
+
export function signTransactionWithBip32Key(signable_hex: string, bip32_private_key_hex: string, review_json: string): string;
|
|
166
163
|
|
|
167
164
|
/**
|
|
168
165
|
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
@@ -215,7 +212,7 @@ export interface InitOutput {
|
|
|
215
212
|
readonly deriveSubaddress: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
216
213
|
readonly diagDatabase: () => [number, number, number, number];
|
|
217
214
|
readonly history: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
218
|
-
readonly
|
|
215
|
+
readonly importKeyImagesWithBip32Key: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
219
216
|
readonly init: () => any;
|
|
220
217
|
readonly listAccounts: () => [number, number, number, number];
|
|
221
218
|
readonly openWallet: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
@@ -225,8 +222,7 @@ export interface InitOutput {
|
|
|
225
222
|
readonly rewindTo: (a: bigint, b: bigint, c: bigint) => [number, number, number, number];
|
|
226
223
|
readonly setNodeUrl: (a: number, b: number) => any;
|
|
227
224
|
readonly setRequestHandler: (a: number) => void;
|
|
228
|
-
readonly
|
|
229
|
-
readonly spendScalar: (a: number, b: number) => [number, number, number, number];
|
|
225
|
+
readonly signTransactionWithBip32Key: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
230
226
|
readonly storageRequiresWorkerRestart: () => number;
|
|
231
227
|
readonly syncPeek: (a: bigint) => [number, number, number, number];
|
|
232
228
|
readonly syncStep: (a: bigint, b: bigint) => any;
|
package/onekey_monero_runtime.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Register an identity (view key pair).
|
|
5
5
|
*
|
|
6
|
-
* `spendPublicKeyHex` and `viewPrivateKeyHex` are 32-byte hex.
|
|
7
|
-
*
|
|
6
|
+
* `spendPublicKeyHex` and `viewPrivateKeyHex` are 32-byte hex. No spend secret
|
|
7
|
+
* is taken here; see `signTransactionWithBip32Key`.
|
|
8
8
|
* @param {string} uuid
|
|
9
9
|
* @param {string} spend_public_key_hex
|
|
10
10
|
* @param {string} view_private_key_hex
|
|
@@ -153,7 +153,7 @@ export function dependencyVersions() {
|
|
|
153
153
|
* Matches OneKey V4 (`spend = sc_reduce32(key)`, `view = keccak(spend)`). Changing
|
|
154
154
|
* it would show existing users an empty wallet after importing the same mnemonic.
|
|
155
155
|
*
|
|
156
|
-
* Does not return the spend private key
|
|
156
|
+
* Does not return the spend private key.
|
|
157
157
|
* @param {string} network
|
|
158
158
|
* @param {string} bip32_private_key_hex
|
|
159
159
|
* @returns {string}
|
|
@@ -269,17 +269,20 @@ export function history(account_id, limit, offset) {
|
|
|
269
269
|
* Call as early as possible after unlock. Until then the balance is too high: a
|
|
270
270
|
* view-only wallet cannot detect spends, so spent outputs still look unspent. This
|
|
271
271
|
* only affects blocks scanned afterwards; earlier spends need a rewind and rescan.
|
|
272
|
+
*
|
|
273
|
+
* Takes the account's BIP-32 key (as `deriveAccount`); the spend key is reduced
|
|
274
|
+
* here and wiped after use.
|
|
272
275
|
* @param {bigint} account_id
|
|
273
|
-
* @param {string}
|
|
276
|
+
* @param {string} bip32_private_key_hex
|
|
274
277
|
* @returns {string}
|
|
275
278
|
*/
|
|
276
|
-
export function
|
|
279
|
+
export function importKeyImagesWithBip32Key(account_id, bip32_private_key_hex) {
|
|
277
280
|
let deferred3_0;
|
|
278
281
|
let deferred3_1;
|
|
279
282
|
try {
|
|
280
|
-
const ptr0 = passStringToWasm0(
|
|
283
|
+
const ptr0 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
281
284
|
const len0 = WASM_VECTOR_LEN;
|
|
282
|
-
const ret = wasm.
|
|
285
|
+
const ret = wasm.importKeyImagesWithBip32Key(account_id, ptr0, len0);
|
|
283
286
|
var ptr2 = ret[0];
|
|
284
287
|
var len2 = ret[1];
|
|
285
288
|
if (ret[3]) {
|
|
@@ -489,10 +492,8 @@ export function setNodeUrl(url) {
|
|
|
489
492
|
* `handler` is `(url, contentType, body: Uint8Array) => Promise<Uint8Array>`;
|
|
490
493
|
* `undefined` uninstalls it.
|
|
491
494
|
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
* background, desktop main process and mobile native code are not bound by those
|
|
495
|
-
* rules, so any node is reachable through them.
|
|
495
|
+
* Lets nodes that in-wasm fetch cannot reach (mixed content, no CORS headers) be
|
|
496
|
+
* used through the extension background, desktop main process or mobile native code.
|
|
496
497
|
* @param {Function | null} [handler]
|
|
497
498
|
*/
|
|
498
499
|
export function setRequestHandler(handler) {
|
|
@@ -502,25 +503,26 @@ export function setRequestHandler(handler) {
|
|
|
502
503
|
/**
|
|
503
504
|
* Sign a prepared transaction. No network, no DB, no broadcast.
|
|
504
505
|
*
|
|
505
|
-
*
|
|
506
|
+
* Takes the account's BIP-32 key (as `deriveAccount`); the spend key is reduced
|
|
507
|
+
* here, and both are wiped after use, never stored or returned.
|
|
506
508
|
* Returns `{ txid, rawHex, sizeBytes }`; the txid is fixed at signing, so the host
|
|
507
509
|
* can record the pending transaction before broadcasting.
|
|
508
510
|
* @param {string} signable_hex
|
|
509
|
-
* @param {string}
|
|
511
|
+
* @param {string} bip32_private_key_hex
|
|
510
512
|
* @param {string} review_json
|
|
511
513
|
* @returns {string}
|
|
512
514
|
*/
|
|
513
|
-
export function
|
|
515
|
+
export function signTransactionWithBip32Key(signable_hex, bip32_private_key_hex, review_json) {
|
|
514
516
|
let deferred5_0;
|
|
515
517
|
let deferred5_1;
|
|
516
518
|
try {
|
|
517
519
|
const ptr0 = passStringToWasm0(signable_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
518
520
|
const len0 = WASM_VECTOR_LEN;
|
|
519
|
-
const ptr1 = passStringToWasm0(
|
|
521
|
+
const ptr1 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
520
522
|
const len1 = WASM_VECTOR_LEN;
|
|
521
523
|
const ptr2 = passStringToWasm0(review_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
522
524
|
const len2 = WASM_VECTOR_LEN;
|
|
523
|
-
const ret = wasm.
|
|
525
|
+
const ret = wasm.signTransactionWithBip32Key(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
524
526
|
var ptr4 = ret[0];
|
|
525
527
|
var len4 = ret[1];
|
|
526
528
|
if (ret[3]) {
|
|
@@ -535,32 +537,6 @@ export function signTransaction(signable_hex, spend_private_key_hex, review_json
|
|
|
535
537
|
}
|
|
536
538
|
}
|
|
537
539
|
|
|
538
|
-
/**
|
|
539
|
-
* Spend scalar for signing, from a BIP-32 private key. Same reduction as `deriveAccount`.
|
|
540
|
-
* @param {string} bip32_private_key_hex
|
|
541
|
-
* @returns {string}
|
|
542
|
-
*/
|
|
543
|
-
export function spendScalar(bip32_private_key_hex) {
|
|
544
|
-
let deferred3_0;
|
|
545
|
-
let deferred3_1;
|
|
546
|
-
try {
|
|
547
|
-
const ptr0 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
548
|
-
const len0 = WASM_VECTOR_LEN;
|
|
549
|
-
const ret = wasm.spendScalar(ptr0, len0);
|
|
550
|
-
var ptr2 = ret[0];
|
|
551
|
-
var len2 = ret[1];
|
|
552
|
-
if (ret[3]) {
|
|
553
|
-
ptr2 = 0; len2 = 0;
|
|
554
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
555
|
-
}
|
|
556
|
-
deferred3_0 = ptr2;
|
|
557
|
-
deferred3_1 = len2;
|
|
558
|
-
return getStringFromWasm0(ptr2, len2);
|
|
559
|
-
} finally {
|
|
560
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
540
|
/**
|
|
565
541
|
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
566
542
|
* @returns {boolean}
|
|
@@ -1152,12 +1128,12 @@ function __wbg_get_imports() {
|
|
|
1152
1128
|
return ret;
|
|
1153
1129
|
}, arguments); },
|
|
1154
1130
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1155
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1131
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 935, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1156
1132
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7657f6f35500acf9);
|
|
1157
1133
|
return ret;
|
|
1158
1134
|
},
|
|
1159
1135
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1160
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
1136
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 290, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1161
1137
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h38334fab7c782151);
|
|
1162
1138
|
return ret;
|
|
1163
1139
|
},
|
|
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.6",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"onekey_monero_runtime.js",
|