onekey-monero-runtime 0.1.0-alpha.3 → 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 +17 -16
- package/onekey_monero_runtime.js +57 -42
- 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
|
|
|
@@ -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, 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, signable_hex?: string | null, review_json?: string | null): Promise<string>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Fetch the chain tip. Does not require an open wallet DB: account creation needs
|
|
@@ -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.
|
|
@@ -193,6 +192,8 @@ export function updateChainTip(account_id: bigint, tip: bigint): string;
|
|
|
193
192
|
*/
|
|
194
193
|
export function validateAddress(network: string, address: string): boolean;
|
|
195
194
|
|
|
195
|
+
export function verifySignedTransaction(signable_hex: string, review_json: string, raw_hex: string): string;
|
|
196
|
+
|
|
196
197
|
/**
|
|
197
198
|
* Validate actual payment effects before the host presents its confirmation.
|
|
198
199
|
*/
|
|
@@ -204,7 +205,7 @@ export interface InitOutput {
|
|
|
204
205
|
readonly memory: WebAssembly.Memory;
|
|
205
206
|
readonly addAccount: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => [number, number, number, number];
|
|
206
207
|
readonly balance: (a: bigint, b: number, c: bigint) => [number, number, number, number];
|
|
207
|
-
readonly broadcastTransaction: (a: bigint, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number) => any;
|
|
208
|
+
readonly broadcastTransaction: (a: bigint, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => any;
|
|
208
209
|
readonly chainTip: () => any;
|
|
209
210
|
readonly closeWallet: () => [number, number];
|
|
210
211
|
readonly deleteWallet: (a: number, b: number) => any;
|
|
@@ -213,7 +214,7 @@ export interface InitOutput {
|
|
|
213
214
|
readonly deriveSubaddress: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
214
215
|
readonly diagDatabase: () => [number, number, number, number];
|
|
215
216
|
readonly history: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
216
|
-
readonly
|
|
217
|
+
readonly importKeyImagesWithBip32Key: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
217
218
|
readonly init: () => any;
|
|
218
219
|
readonly listAccounts: () => [number, number, number, number];
|
|
219
220
|
readonly openWallet: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
@@ -223,14 +224,14 @@ export interface InitOutput {
|
|
|
223
224
|
readonly rewindTo: (a: bigint, b: bigint, c: bigint) => [number, number, number, number];
|
|
224
225
|
readonly setNodeUrl: (a: number, b: number) => any;
|
|
225
226
|
readonly setRequestHandler: (a: number) => void;
|
|
226
|
-
readonly
|
|
227
|
-
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];
|
|
228
228
|
readonly storageRequiresWorkerRestart: () => number;
|
|
229
229
|
readonly syncPeek: (a: bigint) => [number, number, number, number];
|
|
230
230
|
readonly syncStep: (a: bigint, b: bigint) => any;
|
|
231
231
|
readonly transactionDetails: (a: bigint, b: number, c: number) => [number, number, number, number];
|
|
232
232
|
readonly updateChainTip: (a: bigint, b: bigint) => [number, number, number, number];
|
|
233
233
|
readonly validateAddress: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
234
|
+
readonly verifySignedTransaction: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
234
235
|
readonly verifyTransaction: (a: number, b: number, c: number, d: number) => [number, number];
|
|
235
236
|
readonly rust_sqlite_wasm_abort: () => void;
|
|
236
237
|
readonly rust_sqlite_wasm_assert_fail: (a: number, b: number, c: number, d: number) => void;
|
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
|
|
@@ -73,16 +73,22 @@ export function balance(account_id, chain_tip) {
|
|
|
73
73
|
* @param {bigint} chain_tip
|
|
74
74
|
* @param {string | null} [outgoing_atomic]
|
|
75
75
|
* @param {string | null} [change_atomic]
|
|
76
|
+
* @param {string | null} [signable_hex]
|
|
77
|
+
* @param {string | null} [review_json]
|
|
76
78
|
* @returns {Promise<string>}
|
|
77
79
|
*/
|
|
78
|
-
export function broadcastTransaction(account_id, raw_hex, chain_tip, outgoing_atomic, change_atomic) {
|
|
80
|
+
export function broadcastTransaction(account_id, raw_hex, chain_tip, outgoing_atomic, change_atomic, signable_hex, review_json) {
|
|
79
81
|
const ptr0 = passStringToWasm0(raw_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
80
82
|
const len0 = WASM_VECTOR_LEN;
|
|
81
83
|
var ptr1 = isLikeNone(outgoing_atomic) ? 0 : passStringToWasm0(outgoing_atomic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
82
84
|
var len1 = WASM_VECTOR_LEN;
|
|
83
85
|
var ptr2 = isLikeNone(change_atomic) ? 0 : passStringToWasm0(change_atomic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
84
86
|
var len2 = WASM_VECTOR_LEN;
|
|
85
|
-
|
|
87
|
+
var ptr3 = isLikeNone(signable_hex) ? 0 : passStringToWasm0(signable_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
+
var len3 = WASM_VECTOR_LEN;
|
|
89
|
+
var ptr4 = isLikeNone(review_json) ? 0 : passStringToWasm0(review_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
90
|
+
var len4 = WASM_VECTOR_LEN;
|
|
91
|
+
const ret = wasm.broadcastTransaction(account_id, ptr0, len0, chain_tip, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
86
92
|
return ret;
|
|
87
93
|
}
|
|
88
94
|
|
|
@@ -147,7 +153,7 @@ export function dependencyVersions() {
|
|
|
147
153
|
* Matches OneKey V4 (`spend = sc_reduce32(key)`, `view = keccak(spend)`). Changing
|
|
148
154
|
* it would show existing users an empty wallet after importing the same mnemonic.
|
|
149
155
|
*
|
|
150
|
-
* Does not return the spend private key
|
|
156
|
+
* Does not return the spend private key.
|
|
151
157
|
* @param {string} network
|
|
152
158
|
* @param {string} bip32_private_key_hex
|
|
153
159
|
* @returns {string}
|
|
@@ -263,17 +269,20 @@ export function history(account_id, limit, offset) {
|
|
|
263
269
|
* Call as early as possible after unlock. Until then the balance is too high: a
|
|
264
270
|
* view-only wallet cannot detect spends, so spent outputs still look unspent. This
|
|
265
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.
|
|
266
275
|
* @param {bigint} account_id
|
|
267
|
-
* @param {string}
|
|
276
|
+
* @param {string} bip32_private_key_hex
|
|
268
277
|
* @returns {string}
|
|
269
278
|
*/
|
|
270
|
-
export function
|
|
279
|
+
export function importKeyImagesWithBip32Key(account_id, bip32_private_key_hex) {
|
|
271
280
|
let deferred3_0;
|
|
272
281
|
let deferred3_1;
|
|
273
282
|
try {
|
|
274
|
-
const ptr0 = passStringToWasm0(
|
|
283
|
+
const ptr0 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
275
284
|
const len0 = WASM_VECTOR_LEN;
|
|
276
|
-
const ret = wasm.
|
|
285
|
+
const ret = wasm.importKeyImagesWithBip32Key(account_id, ptr0, len0);
|
|
277
286
|
var ptr2 = ret[0];
|
|
278
287
|
var len2 = ret[1];
|
|
279
288
|
if (ret[3]) {
|
|
@@ -496,25 +505,26 @@ export function setRequestHandler(handler) {
|
|
|
496
505
|
/**
|
|
497
506
|
* Sign a prepared transaction. No network, no DB, no broadcast.
|
|
498
507
|
*
|
|
499
|
-
*
|
|
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.
|
|
500
510
|
* Returns `{ txid, rawHex, sizeBytes }`; the txid is fixed at signing, so the host
|
|
501
511
|
* can record the pending transaction before broadcasting.
|
|
502
512
|
* @param {string} signable_hex
|
|
503
|
-
* @param {string}
|
|
513
|
+
* @param {string} bip32_private_key_hex
|
|
504
514
|
* @param {string} review_json
|
|
505
515
|
* @returns {string}
|
|
506
516
|
*/
|
|
507
|
-
export function
|
|
517
|
+
export function signTransactionWithBip32Key(signable_hex, bip32_private_key_hex, review_json) {
|
|
508
518
|
let deferred5_0;
|
|
509
519
|
let deferred5_1;
|
|
510
520
|
try {
|
|
511
521
|
const ptr0 = passStringToWasm0(signable_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
512
522
|
const len0 = WASM_VECTOR_LEN;
|
|
513
|
-
const ptr1 = passStringToWasm0(
|
|
523
|
+
const ptr1 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
514
524
|
const len1 = WASM_VECTOR_LEN;
|
|
515
525
|
const ptr2 = passStringToWasm0(review_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
516
526
|
const len2 = WASM_VECTOR_LEN;
|
|
517
|
-
const ret = wasm.
|
|
527
|
+
const ret = wasm.signTransactionWithBip32Key(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
518
528
|
var ptr4 = ret[0];
|
|
519
529
|
var len4 = ret[1];
|
|
520
530
|
if (ret[3]) {
|
|
@@ -529,32 +539,6 @@ export function signTransaction(signable_hex, spend_private_key_hex, review_json
|
|
|
529
539
|
}
|
|
530
540
|
}
|
|
531
541
|
|
|
532
|
-
/**
|
|
533
|
-
* Spend scalar for signing, from a BIP-32 private key. Same reduction as `deriveAccount`.
|
|
534
|
-
* @param {string} bip32_private_key_hex
|
|
535
|
-
* @returns {string}
|
|
536
|
-
*/
|
|
537
|
-
export function spendScalar(bip32_private_key_hex) {
|
|
538
|
-
let deferred3_0;
|
|
539
|
-
let deferred3_1;
|
|
540
|
-
try {
|
|
541
|
-
const ptr0 = passStringToWasm0(bip32_private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
542
|
-
const len0 = WASM_VECTOR_LEN;
|
|
543
|
-
const ret = wasm.spendScalar(ptr0, len0);
|
|
544
|
-
var ptr2 = ret[0];
|
|
545
|
-
var len2 = ret[1];
|
|
546
|
-
if (ret[3]) {
|
|
547
|
-
ptr2 = 0; len2 = 0;
|
|
548
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
549
|
-
}
|
|
550
|
-
deferred3_0 = ptr2;
|
|
551
|
-
deferred3_1 = len2;
|
|
552
|
-
return getStringFromWasm0(ptr2, len2);
|
|
553
|
-
} finally {
|
|
554
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
542
|
/**
|
|
559
543
|
* Preserve a failed call's result, then retire its poisoned storage owner.
|
|
560
544
|
* @returns {boolean}
|
|
@@ -670,6 +654,37 @@ export function validateAddress(network, address) {
|
|
|
670
654
|
return ret[0] !== 0;
|
|
671
655
|
}
|
|
672
656
|
|
|
657
|
+
/**
|
|
658
|
+
* @param {string} signable_hex
|
|
659
|
+
* @param {string} review_json
|
|
660
|
+
* @param {string} raw_hex
|
|
661
|
+
* @returns {string}
|
|
662
|
+
*/
|
|
663
|
+
export function verifySignedTransaction(signable_hex, review_json, raw_hex) {
|
|
664
|
+
let deferred5_0;
|
|
665
|
+
let deferred5_1;
|
|
666
|
+
try {
|
|
667
|
+
const ptr0 = passStringToWasm0(signable_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
668
|
+
const len0 = WASM_VECTOR_LEN;
|
|
669
|
+
const ptr1 = passStringToWasm0(review_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
670
|
+
const len1 = WASM_VECTOR_LEN;
|
|
671
|
+
const ptr2 = passStringToWasm0(raw_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
672
|
+
const len2 = WASM_VECTOR_LEN;
|
|
673
|
+
const ret = wasm.verifySignedTransaction(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
674
|
+
var ptr4 = ret[0];
|
|
675
|
+
var len4 = ret[1];
|
|
676
|
+
if (ret[3]) {
|
|
677
|
+
ptr4 = 0; len4 = 0;
|
|
678
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
679
|
+
}
|
|
680
|
+
deferred5_0 = ptr4;
|
|
681
|
+
deferred5_1 = len4;
|
|
682
|
+
return getStringFromWasm0(ptr4, len4);
|
|
683
|
+
} finally {
|
|
684
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
673
688
|
/**
|
|
674
689
|
* Validate actual payment effects before the host presents its confirmation.
|
|
675
690
|
* @param {string} signable_hex
|
|
@@ -1115,12 +1130,12 @@ function __wbg_get_imports() {
|
|
|
1115
1130
|
return ret;
|
|
1116
1131
|
}, arguments); },
|
|
1117
1132
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1118
|
-
// 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`.
|
|
1119
1134
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h7657f6f35500acf9);
|
|
1120
1135
|
return ret;
|
|
1121
1136
|
},
|
|
1122
1137
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1123
|
-
// 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`.
|
|
1124
1139
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h38334fab7c782151);
|
|
1125
1140
|
return ret;
|
|
1126
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",
|