onekey-monero-runtime 0.1.0-alpha.4 → 0.1.0-alpha.5
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 +12 -14
- package/onekey_monero_runtime.js +18 -40
- 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.
|
|
@@ -153,16 +156,12 @@ export function setRequestHandler(handler?: Function | null): void;
|
|
|
153
156
|
/**
|
|
154
157
|
* Sign a prepared transaction. No network, no DB, no broadcast.
|
|
155
158
|
*
|
|
156
|
-
*
|
|
159
|
+
* Takes the account's BIP-32 key (as `deriveAccount`); the spend key is reduced
|
|
160
|
+
* here, and both are wiped after use, never stored or returned.
|
|
157
161
|
* Returns `{ txid, rawHex, sizeBytes }`; the txid is fixed at signing, so the host
|
|
158
162
|
* can record the pending transaction before broadcasting.
|
|
159
163
|
*/
|
|
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;
|
|
164
|
+
export function signTransactionWithBip32Key(signable_hex: string, bip32_private_key_hex: string, review_json: string): string;
|
|
166
165
|
|
|
167
166
|
/**
|
|
168
167
|
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
@@ -215,7 +214,7 @@ export interface InitOutput {
|
|
|
215
214
|
readonly deriveSubaddress: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
216
215
|
readonly diagDatabase: () => [number, number, number, number];
|
|
217
216
|
readonly history: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
218
|
-
readonly
|
|
217
|
+
readonly importKeyImagesWithBip32Key: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
219
218
|
readonly init: () => any;
|
|
220
219
|
readonly listAccounts: () => [number, number, number, number];
|
|
221
220
|
readonly openWallet: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
@@ -225,8 +224,7 @@ export interface InitOutput {
|
|
|
225
224
|
readonly rewindTo: (a: bigint, b: bigint, c: bigint) => [number, number, number, number];
|
|
226
225
|
readonly setNodeUrl: (a: number, b: number) => any;
|
|
227
226
|
readonly setRequestHandler: (a: number) => void;
|
|
228
|
-
readonly
|
|
229
|
-
readonly spendScalar: (a: number, b: number) => [number, number, number, number];
|
|
227
|
+
readonly signTransactionWithBip32Key: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
230
228
|
readonly storageRequiresWorkerRestart: () => number;
|
|
231
229
|
readonly syncPeek: (a: bigint) => [number, number, number, number];
|
|
232
230
|
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]) {
|
|
@@ -502,25 +505,26 @@ export function setRequestHandler(handler) {
|
|
|
502
505
|
/**
|
|
503
506
|
* Sign a prepared transaction. No network, no DB, no broadcast.
|
|
504
507
|
*
|
|
505
|
-
*
|
|
508
|
+
* Takes the account's BIP-32 key (as `deriveAccount`); the spend key is reduced
|
|
509
|
+
* here, and both are wiped after use, never stored or returned.
|
|
506
510
|
* Returns `{ txid, rawHex, sizeBytes }`; the txid is fixed at signing, so the host
|
|
507
511
|
* can record the pending transaction before broadcasting.
|
|
508
512
|
* @param {string} signable_hex
|
|
509
|
-
* @param {string}
|
|
513
|
+
* @param {string} bip32_private_key_hex
|
|
510
514
|
* @param {string} review_json
|
|
511
515
|
* @returns {string}
|
|
512
516
|
*/
|
|
513
|
-
export function
|
|
517
|
+
export function signTransactionWithBip32Key(signable_hex, bip32_private_key_hex, review_json) {
|
|
514
518
|
let deferred5_0;
|
|
515
519
|
let deferred5_1;
|
|
516
520
|
try {
|
|
517
521
|
const ptr0 = passStringToWasm0(signable_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
518
522
|
const len0 = WASM_VECTOR_LEN;
|
|
519
|
-
const ptr1 = passStringToWasm0(
|
|
523
|
+
const ptr1 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
520
524
|
const len1 = WASM_VECTOR_LEN;
|
|
521
525
|
const ptr2 = passStringToWasm0(review_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
522
526
|
const len2 = WASM_VECTOR_LEN;
|
|
523
|
-
const ret = wasm.
|
|
527
|
+
const ret = wasm.signTransactionWithBip32Key(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
524
528
|
var ptr4 = ret[0];
|
|
525
529
|
var len4 = ret[1];
|
|
526
530
|
if (ret[3]) {
|
|
@@ -535,32 +539,6 @@ export function signTransaction(signable_hex, spend_private_key_hex, review_json
|
|
|
535
539
|
}
|
|
536
540
|
}
|
|
537
541
|
|
|
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
542
|
/**
|
|
565
543
|
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
566
544
|
* @returns {boolean}
|
|
@@ -1152,12 +1130,12 @@ function __wbg_get_imports() {
|
|
|
1152
1130
|
return ret;
|
|
1153
1131
|
}, arguments); },
|
|
1154
1132
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1155
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1133
|
+
// 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
1134
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7657f6f35500acf9);
|
|
1157
1135
|
return ret;
|
|
1158
1136
|
},
|
|
1159
1137
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1160
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx:
|
|
1138
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 290, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1161
1139
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h38334fab7c782151);
|
|
1162
1140
|
return ret;
|
|
1163
1141
|
},
|
|
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.5",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"onekey_monero_runtime.js",
|