@bitgo/wasm-utxo 1.6.0 → 1.8.0
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/dist/cjs/js/bip32.d.ts +140 -0
- package/dist/cjs/js/bip32.js +177 -0
- package/dist/cjs/js/ecpair.d.ts +96 -0
- package/dist/cjs/js/ecpair.js +134 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +242 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +274 -0
- package/dist/cjs/js/fixedScriptWallet/ReplayProtection.d.ts +58 -0
- package/dist/cjs/js/fixedScriptWallet/ReplayProtection.js +89 -0
- package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.d.ts +66 -0
- package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.js +108 -0
- package/dist/cjs/js/fixedScriptWallet/address.d.ts +20 -0
- package/dist/cjs/js/fixedScriptWallet/address.js +29 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +4 -0
- package/dist/cjs/js/fixedScriptWallet/index.js +12 -0
- package/dist/cjs/js/index.d.ts +5 -1
- package/dist/cjs/js/index.js +11 -2
- package/dist/cjs/js/utxolibCompat.d.ts +0 -18
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +333 -15
- package/dist/cjs/js/wasm/wasm_utxo.js +1311 -201
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +64 -15
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/js/bip32.d.ts +140 -0
- package/dist/esm/js/bip32.js +173 -0
- package/dist/esm/js/ecpair.d.ts +96 -0
- package/dist/esm/js/ecpair.js +130 -0
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +242 -0
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +270 -0
- package/dist/esm/js/fixedScriptWallet/ReplayProtection.d.ts +58 -0
- package/dist/esm/js/fixedScriptWallet/ReplayProtection.js +85 -0
- package/dist/esm/js/fixedScriptWallet/RootWalletKeys.d.ts +66 -0
- package/dist/esm/js/fixedScriptWallet/RootWalletKeys.js +104 -0
- package/dist/esm/js/fixedScriptWallet/address.d.ts +20 -0
- package/dist/esm/js/fixedScriptWallet/address.js +25 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +4 -0
- package/dist/esm/js/fixedScriptWallet/index.js +4 -0
- package/dist/esm/js/index.d.ts +5 -1
- package/dist/esm/js/index.js +8 -1
- package/dist/esm/js/utxolibCompat.d.ts +0 -18
- package/dist/esm/js/wasm/wasm_utxo.d.ts +333 -15
- package/dist/esm/js/wasm/wasm_utxo_bg.js +1301 -199
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +64 -15
- package/dist/esm/test/bip32.js +242 -0
- package/dist/esm/test/ecpair.d.ts +1 -0
- package/dist/esm/test/ecpair.js +137 -0
- package/dist/esm/test/fixedScript/fixtureUtil.d.ts +12 -2
- package/dist/esm/test/fixedScript/fixtureUtil.js +28 -7
- package/dist/esm/test/fixedScript/musig2Nonces.d.ts +1 -0
- package/dist/esm/test/fixedScript/musig2Nonces.js +77 -0
- package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.js +7 -7
- package/dist/esm/test/fixedScript/signAndVerifySignature.d.ts +1 -0
- package/dist/esm/test/fixedScript/signAndVerifySignature.js +268 -0
- package/dist/esm/test/fixedScript/walletKeys.util.d.ts +12 -0
- package/dist/esm/test/fixedScript/walletKeys.util.js +17 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/cjs/js/fixedScriptWallet.d.ts +0 -146
- package/dist/cjs/js/fixedScriptWallet.js +0 -138
- package/dist/esm/js/fixedScriptWallet.d.ts +0 -146
- package/dist/esm/js/fixedScriptWallet.js +0 -132
- package/dist/esm/test/fixedScript/verifySignature.js +0 -141
- /package/dist/esm/test/{fixedScript/verifySignature.d.ts → bip32.d.ts} +0 -0
|
@@ -64,6 +64,18 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
64
64
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
function dropObject(idx) {
|
|
68
|
+
if (idx < 132) return;
|
|
69
|
+
heap[idx] = heap_next;
|
|
70
|
+
heap_next = idx;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function takeObject(idx) {
|
|
74
|
+
const ret = getObject(idx);
|
|
75
|
+
dropObject(idx);
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
function isLikeNone(x) {
|
|
68
80
|
return x === undefined || x === null;
|
|
69
81
|
}
|
|
@@ -131,18 +143,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
131
143
|
return ptr;
|
|
132
144
|
}
|
|
133
145
|
|
|
134
|
-
function dropObject(idx) {
|
|
135
|
-
if (idx < 132) return;
|
|
136
|
-
heap[idx] = heap_next;
|
|
137
|
-
heap_next = idx;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function takeObject(idx) {
|
|
141
|
-
const ret = getObject(idx);
|
|
142
|
-
dropObject(idx);
|
|
143
|
-
return ret;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
146
|
function passArray8ToWasm0(arg, malloc) {
|
|
147
147
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
148
148
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -150,12 +150,30 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
150
150
|
return ptr;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
154
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
155
|
+
const mem = getDataViewMemory0();
|
|
156
|
+
for (let i = 0; i < array.length; i++) {
|
|
157
|
+
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
|
|
158
|
+
}
|
|
159
|
+
WASM_VECTOR_LEN = array.length;
|
|
160
|
+
return ptr;
|
|
161
|
+
}
|
|
162
|
+
|
|
153
163
|
function _assertClass(instance, klass) {
|
|
154
164
|
if (!(instance instanceof klass)) {
|
|
155
165
|
throw new Error(`expected instance of ${klass.name}`);
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
168
|
|
|
169
|
+
let stack_pointer = 128;
|
|
170
|
+
|
|
171
|
+
function addBorrowedObject(obj) {
|
|
172
|
+
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
173
|
+
heap[--stack_pointer] = obj;
|
|
174
|
+
return stack_pointer;
|
|
175
|
+
}
|
|
176
|
+
|
|
159
177
|
const AddressNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
160
178
|
? { register: () => {}, unregister: () => {} }
|
|
161
179
|
: new FinalizationRegistry(ptr => wasm.__wbg_addressnamespace_free(ptr >>> 0, 1));
|
|
@@ -310,37 +328,71 @@ export class BitGoPsbt {
|
|
|
310
328
|
}
|
|
311
329
|
}
|
|
312
330
|
/**
|
|
313
|
-
*
|
|
331
|
+
* Sign a single input with an extended private key (xpriv)
|
|
314
332
|
*
|
|
315
|
-
* This method
|
|
316
|
-
*
|
|
317
|
-
*
|
|
333
|
+
* This method signs a specific input using the provided xpriv. It accepts:
|
|
334
|
+
* - An xpriv (WasmBIP32) for wallet inputs - derives the key and signs
|
|
335
|
+
*
|
|
336
|
+
* This method automatically detects and handles different input types:
|
|
337
|
+
* - For regular inputs: uses standard PSBT signing
|
|
338
|
+
* - For MuSig2 inputs: uses the FirstRound state stored by generate_musig2_nonces()
|
|
339
|
+
* - For replay protection inputs: returns error (use sign_with_privkey instead)
|
|
318
340
|
*
|
|
319
341
|
* # Arguments
|
|
320
|
-
* - `input_index`: The index of the input to
|
|
321
|
-
* - `
|
|
342
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
343
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
322
344
|
*
|
|
323
345
|
* # Returns
|
|
324
|
-
* - `Ok(
|
|
325
|
-
* - `
|
|
326
|
-
* - `Err(WasmUtxoError)` if the input index is out of bounds, xpub is invalid, derivation fails, or verification fails
|
|
346
|
+
* - `Ok(())` if signing was successful
|
|
347
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
327
348
|
* @param {number} input_index
|
|
328
|
-
* @param {
|
|
329
|
-
* @returns {boolean}
|
|
349
|
+
* @param {WasmBIP32} xpriv
|
|
330
350
|
*/
|
|
331
|
-
|
|
351
|
+
sign_with_xpriv(input_index, xpriv) {
|
|
332
352
|
try {
|
|
333
353
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
wasm.bitgopsbt_verify_signature(retptr, this.__wbg_ptr, input_index, ptr0, len0);
|
|
354
|
+
_assertClass(xpriv, WasmBIP32);
|
|
355
|
+
wasm.bitgopsbt_sign_with_xpriv(retptr, this.__wbg_ptr, input_index, xpriv.__wbg_ptr);
|
|
337
356
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
338
357
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
358
|
+
if (r1) {
|
|
359
|
+
throw takeObject(r0);
|
|
360
|
+
}
|
|
361
|
+
} finally {
|
|
362
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Sign a single input with a raw private key
|
|
367
|
+
*
|
|
368
|
+
* This method signs a specific input using the provided ECPair. It accepts:
|
|
369
|
+
* - A raw privkey (WasmECPair) for replay protection inputs - signs directly
|
|
370
|
+
*
|
|
371
|
+
* This method automatically detects and handles different input types:
|
|
372
|
+
* - For replay protection inputs: signs with legacy P2SH sighash
|
|
373
|
+
* - For regular inputs: uses standard PSBT signing
|
|
374
|
+
* - For MuSig2 inputs: returns error (requires FirstRound, use sign_with_xpriv instead)
|
|
375
|
+
*
|
|
376
|
+
* # Arguments
|
|
377
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
378
|
+
* - `ecpair`: The ECPair containing the private key
|
|
379
|
+
*
|
|
380
|
+
* # Returns
|
|
381
|
+
* - `Ok(())` if signing was successful
|
|
382
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
383
|
+
* @param {number} input_index
|
|
384
|
+
* @param {WasmECPair} ecpair
|
|
385
|
+
*/
|
|
386
|
+
sign_with_privkey(input_index, ecpair) {
|
|
387
|
+
try {
|
|
388
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
389
|
+
_assertClass(ecpair, WasmECPair);
|
|
390
|
+
wasm.bitgopsbt_sign_with_privkey(retptr, this.__wbg_ptr, input_index, ecpair.__wbg_ptr);
|
|
391
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
392
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
393
|
+
if (r1) {
|
|
394
|
+
throw takeObject(r0);
|
|
342
395
|
}
|
|
343
|
-
return r0 !== 0;
|
|
344
396
|
} finally {
|
|
345
397
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
346
398
|
}
|
|
@@ -384,297 +436,1289 @@ export class BitGoPsbt {
|
|
|
384
436
|
* - `Ok(())` if all inputs were successfully finalized
|
|
385
437
|
* - `Err(WasmUtxoError)` if any input failed to finalize
|
|
386
438
|
*/
|
|
387
|
-
finalize_all_inputs() {
|
|
439
|
+
finalize_all_inputs() {
|
|
440
|
+
try {
|
|
441
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
442
|
+
wasm.bitgopsbt_finalize_all_inputs(retptr, this.__wbg_ptr);
|
|
443
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
444
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
445
|
+
if (r1) {
|
|
446
|
+
throw takeObject(r0);
|
|
447
|
+
}
|
|
448
|
+
} finally {
|
|
449
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Combine/merge data from another PSBT into this one
|
|
454
|
+
*
|
|
455
|
+
* This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
|
|
456
|
+
* source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
|
|
457
|
+
* and signature collection phases.
|
|
458
|
+
*
|
|
459
|
+
* # Arguments
|
|
460
|
+
* * `source_psbt` - The source PSBT containing data to merge
|
|
461
|
+
*
|
|
462
|
+
* # Returns
|
|
463
|
+
* Ok(()) if data was successfully merged
|
|
464
|
+
*
|
|
465
|
+
* # Errors
|
|
466
|
+
* Returns error if networks don't match
|
|
467
|
+
* @param {BitGoPsbt} source_psbt
|
|
468
|
+
*/
|
|
469
|
+
combine_musig2_nonces(source_psbt) {
|
|
470
|
+
try {
|
|
471
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
472
|
+
_assertClass(source_psbt, BitGoPsbt);
|
|
473
|
+
wasm.bitgopsbt_combine_musig2_nonces(retptr, this.__wbg_ptr, source_psbt.__wbg_ptr);
|
|
474
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
475
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
476
|
+
if (r1) {
|
|
477
|
+
throw takeObject(r0);
|
|
478
|
+
}
|
|
479
|
+
} finally {
|
|
480
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Generate and store MuSig2 nonces for all MuSig2 inputs
|
|
485
|
+
*
|
|
486
|
+
* This method generates nonces using the State-Machine API and stores them in the PSBT.
|
|
487
|
+
* The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
|
|
488
|
+
* After ALL participants have generated their nonces, they can sign MuSig2 inputs using
|
|
489
|
+
* sign_with_xpriv().
|
|
490
|
+
*
|
|
491
|
+
* # Arguments
|
|
492
|
+
* * `xpriv` - The extended private key (xpriv) for signing
|
|
493
|
+
* * `session_id_bytes` - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
|
|
494
|
+
* On mainnets, a secure random session ID is always generated automatically.
|
|
495
|
+
* Must be unique per signing session.
|
|
496
|
+
*
|
|
497
|
+
* # Returns
|
|
498
|
+
* Ok(()) if nonces were successfully generated and stored
|
|
499
|
+
*
|
|
500
|
+
* # Errors
|
|
501
|
+
* Returns error if:
|
|
502
|
+
* - Nonce generation fails
|
|
503
|
+
* - session_id length is invalid
|
|
504
|
+
* - Custom session_id is provided on a mainnet (security restriction)
|
|
505
|
+
*
|
|
506
|
+
* # Security
|
|
507
|
+
* The session_id MUST be cryptographically random and unique for each signing session.
|
|
508
|
+
* Never reuse a session_id with the same key! On mainnets, session_id is always randomly
|
|
509
|
+
* generated for security. Custom session_id is only allowed on testnets for testing purposes.
|
|
510
|
+
* @param {WasmBIP32} xpriv
|
|
511
|
+
* @param {Uint8Array | null} [session_id_bytes]
|
|
512
|
+
*/
|
|
513
|
+
generate_musig2_nonces(xpriv, session_id_bytes) {
|
|
514
|
+
try {
|
|
515
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
516
|
+
_assertClass(xpriv, WasmBIP32);
|
|
517
|
+
var ptr0 = isLikeNone(session_id_bytes) ? 0 : passArray8ToWasm0(session_id_bytes, wasm.__wbindgen_export_1);
|
|
518
|
+
var len0 = WASM_VECTOR_LEN;
|
|
519
|
+
wasm.bitgopsbt_generate_musig2_nonces(retptr, this.__wbg_ptr, xpriv.__wbg_ptr, ptr0, len0);
|
|
520
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
521
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
522
|
+
if (r1) {
|
|
523
|
+
throw takeObject(r0);
|
|
524
|
+
}
|
|
525
|
+
} finally {
|
|
526
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Verify if a valid signature exists for a given ECPair key at the specified input index
|
|
531
|
+
*
|
|
532
|
+
* This method verifies the signature directly with the provided ECPair's public key. It supports:
|
|
533
|
+
* - ECDSA signatures (for legacy/SegWit inputs)
|
|
534
|
+
* - Schnorr signatures (for Taproot script path inputs)
|
|
535
|
+
*
|
|
536
|
+
* Note: This method does NOT support MuSig2 inputs, as MuSig2 requires derivation from xpubs.
|
|
537
|
+
* Use `verify_signature_with_xpub` for MuSig2 inputs.
|
|
538
|
+
*
|
|
539
|
+
* # Arguments
|
|
540
|
+
* - `input_index`: The index of the input to check
|
|
541
|
+
* - `ecpair`: The ECPair key (uses the public key for verification)
|
|
542
|
+
*
|
|
543
|
+
* # Returns
|
|
544
|
+
* - `Ok(true)` if a valid signature exists for the public key
|
|
545
|
+
* - `Ok(false)` if no signature exists for the public key
|
|
546
|
+
* - `Err(WasmUtxoError)` if the input index is out of bounds or verification fails
|
|
547
|
+
* @param {number} input_index
|
|
548
|
+
* @param {WasmECPair} ecpair
|
|
549
|
+
* @returns {boolean}
|
|
550
|
+
*/
|
|
551
|
+
verify_signature_with_pub(input_index, ecpair) {
|
|
552
|
+
try {
|
|
553
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
554
|
+
_assertClass(ecpair, WasmECPair);
|
|
555
|
+
wasm.bitgopsbt_verify_signature_with_pub(retptr, this.__wbg_ptr, input_index, ecpair.__wbg_ptr);
|
|
556
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
557
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
558
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
559
|
+
if (r2) {
|
|
560
|
+
throw takeObject(r1);
|
|
561
|
+
}
|
|
562
|
+
return r0 !== 0;
|
|
563
|
+
} finally {
|
|
564
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Verify if a valid signature exists for a given xpub at the specified input index
|
|
569
|
+
*
|
|
570
|
+
* This method derives the public key from the xpub using the derivation path found in the
|
|
571
|
+
* PSBT input, then verifies the signature. It supports:
|
|
572
|
+
* - ECDSA signatures (for legacy/SegWit inputs)
|
|
573
|
+
* - Schnorr signatures (for Taproot script path inputs)
|
|
574
|
+
* - MuSig2 partial signatures (for Taproot keypath MuSig2 inputs)
|
|
575
|
+
*
|
|
576
|
+
* # Arguments
|
|
577
|
+
* - `input_index`: The index of the input to check
|
|
578
|
+
* - `xpub`: The extended public key as a WasmBIP32 instance
|
|
579
|
+
*
|
|
580
|
+
* # Returns
|
|
581
|
+
* - `Ok(true)` if a valid signature exists for the derived public key
|
|
582
|
+
* - `Ok(false)` if no signature exists for the derived public key
|
|
583
|
+
* - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
|
|
584
|
+
* @param {number} input_index
|
|
585
|
+
* @param {WasmBIP32} xpub
|
|
586
|
+
* @returns {boolean}
|
|
587
|
+
*/
|
|
588
|
+
verify_signature_with_xpub(input_index, xpub) {
|
|
589
|
+
try {
|
|
590
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
591
|
+
_assertClass(xpub, WasmBIP32);
|
|
592
|
+
wasm.bitgopsbt_verify_signature_with_xpub(retptr, this.__wbg_ptr, input_index, xpub.__wbg_ptr);
|
|
593
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
594
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
595
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
596
|
+
if (r2) {
|
|
597
|
+
throw takeObject(r1);
|
|
598
|
+
}
|
|
599
|
+
return r0 !== 0;
|
|
600
|
+
} finally {
|
|
601
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Parse outputs with wallet keys to identify which outputs belong to a wallet
|
|
606
|
+
*
|
|
607
|
+
* Note: This method does NOT validate wallet inputs. It only parses outputs.
|
|
608
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
609
|
+
* @returns {any}
|
|
610
|
+
*/
|
|
611
|
+
parse_outputs_with_wallet_keys(wallet_keys) {
|
|
612
|
+
try {
|
|
613
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
614
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
615
|
+
wasm.bitgopsbt_parse_outputs_with_wallet_keys(retptr, this.__wbg_ptr, wallet_keys.__wbg_ptr);
|
|
616
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
617
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
618
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
619
|
+
if (r2) {
|
|
620
|
+
throw takeObject(r1);
|
|
621
|
+
}
|
|
622
|
+
return takeObject(r0);
|
|
623
|
+
} finally {
|
|
624
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Parse transaction with wallet keys to identify wallet inputs/outputs
|
|
629
|
+
* @param {WasmRootWalletKeys} wallet_keys
|
|
630
|
+
* @param {WasmReplayProtection} replay_protection
|
|
631
|
+
* @returns {any}
|
|
632
|
+
*/
|
|
633
|
+
parse_transaction_with_wallet_keys(wallet_keys, replay_protection) {
|
|
634
|
+
try {
|
|
635
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
636
|
+
_assertClass(wallet_keys, WasmRootWalletKeys);
|
|
637
|
+
_assertClass(replay_protection, WasmReplayProtection);
|
|
638
|
+
wasm.bitgopsbt_parse_transaction_with_wallet_keys(retptr, this.__wbg_ptr, wallet_keys.__wbg_ptr, replay_protection.__wbg_ptr);
|
|
639
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
640
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
641
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
642
|
+
if (r2) {
|
|
643
|
+
throw takeObject(r1);
|
|
644
|
+
}
|
|
645
|
+
return takeObject(r0);
|
|
646
|
+
} finally {
|
|
647
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Verify if a replay protection input has a valid signature
|
|
652
|
+
*
|
|
653
|
+
* This method checks if a given input is a replay protection input and cryptographically verifies
|
|
654
|
+
* the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
|
|
655
|
+
* so this method verifies signatures without deriving from xpub.
|
|
656
|
+
*
|
|
657
|
+
* # Arguments
|
|
658
|
+
* - `input_index`: The index of the input to check
|
|
659
|
+
* - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
|
|
660
|
+
* Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
|
|
661
|
+
*
|
|
662
|
+
* # Returns
|
|
663
|
+
* - `Ok(true)` if the input is a replay protection input and has a valid signature
|
|
664
|
+
* - `Ok(false)` if the input is a replay protection input but has no valid signature
|
|
665
|
+
* - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
|
|
666
|
+
* @param {number} input_index
|
|
667
|
+
* @param {WasmReplayProtection} replay_protection
|
|
668
|
+
* @returns {boolean}
|
|
669
|
+
*/
|
|
670
|
+
verify_replay_protection_signature(input_index, replay_protection) {
|
|
671
|
+
try {
|
|
672
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
673
|
+
_assertClass(replay_protection, WasmReplayProtection);
|
|
674
|
+
wasm.bitgopsbt_verify_replay_protection_signature(retptr, this.__wbg_ptr, input_index, replay_protection.__wbg_ptr);
|
|
675
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
676
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
677
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
678
|
+
if (r2) {
|
|
679
|
+
throw takeObject(r1);
|
|
680
|
+
}
|
|
681
|
+
return r0 !== 0;
|
|
682
|
+
} finally {
|
|
683
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Get the network of the PSBT
|
|
688
|
+
* @returns {string}
|
|
689
|
+
*/
|
|
690
|
+
network() {
|
|
691
|
+
let deferred1_0;
|
|
692
|
+
let deferred1_1;
|
|
693
|
+
try {
|
|
694
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
695
|
+
wasm.bitgopsbt_network(retptr, this.__wbg_ptr);
|
|
696
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
697
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
698
|
+
deferred1_0 = r0;
|
|
699
|
+
deferred1_1 = r1;
|
|
700
|
+
return getStringFromWasm0(r0, r1);
|
|
701
|
+
} finally {
|
|
702
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
703
|
+
wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Serialize the PSBT to bytes
|
|
708
|
+
*
|
|
709
|
+
* # Returns
|
|
710
|
+
* The serialized PSBT as a byte array
|
|
711
|
+
* @returns {Uint8Array}
|
|
712
|
+
*/
|
|
713
|
+
serialize() {
|
|
714
|
+
try {
|
|
715
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
716
|
+
wasm.bitgopsbt_serialize(retptr, this.__wbg_ptr);
|
|
717
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
718
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
719
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
720
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
721
|
+
if (r3) {
|
|
722
|
+
throw takeObject(r2);
|
|
723
|
+
}
|
|
724
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
725
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
726
|
+
return v1;
|
|
727
|
+
} finally {
|
|
728
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (Symbol.dispose) BitGoPsbt.prototype[Symbol.dispose] = BitGoPsbt.prototype.free;
|
|
733
|
+
|
|
734
|
+
const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
735
|
+
? { register: () => {}, unregister: () => {} }
|
|
736
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
|
|
737
|
+
|
|
738
|
+
export class FixedScriptWalletNamespace {
|
|
739
|
+
|
|
740
|
+
__destroy_into_raw() {
|
|
741
|
+
const ptr = this.__wbg_ptr;
|
|
742
|
+
this.__wbg_ptr = 0;
|
|
743
|
+
FixedScriptWalletNamespaceFinalization.unregister(this);
|
|
744
|
+
return ptr;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
free() {
|
|
748
|
+
const ptr = this.__destroy_into_raw();
|
|
749
|
+
wasm.__wbg_fixedscriptwalletnamespace_free(ptr, 0);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* @param {WasmRootWalletKeys} keys
|
|
753
|
+
* @param {number} chain
|
|
754
|
+
* @param {number} index
|
|
755
|
+
* @param {any} network
|
|
756
|
+
* @returns {Uint8Array}
|
|
757
|
+
*/
|
|
758
|
+
static output_script(keys, chain, index, network) {
|
|
759
|
+
try {
|
|
760
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
761
|
+
_assertClass(keys, WasmRootWalletKeys);
|
|
762
|
+
wasm.fixedscriptwalletnamespace_output_script(retptr, keys.__wbg_ptr, chain, index, addHeapObject(network));
|
|
763
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
764
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
765
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
766
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
767
|
+
if (r3) {
|
|
768
|
+
throw takeObject(r2);
|
|
769
|
+
}
|
|
770
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
771
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
772
|
+
return v1;
|
|
773
|
+
} finally {
|
|
774
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* @param {WasmRootWalletKeys} keys
|
|
779
|
+
* @param {number} chain
|
|
780
|
+
* @param {number} index
|
|
781
|
+
* @param {any} network
|
|
782
|
+
* @param {string | null} [address_format]
|
|
783
|
+
* @returns {string}
|
|
784
|
+
*/
|
|
785
|
+
static address(keys, chain, index, network, address_format) {
|
|
786
|
+
let deferred3_0;
|
|
787
|
+
let deferred3_1;
|
|
788
|
+
try {
|
|
789
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
790
|
+
_assertClass(keys, WasmRootWalletKeys);
|
|
791
|
+
var ptr0 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
792
|
+
var len0 = WASM_VECTOR_LEN;
|
|
793
|
+
wasm.fixedscriptwalletnamespace_address(retptr, keys.__wbg_ptr, chain, index, addHeapObject(network), ptr0, len0);
|
|
794
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
795
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
796
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
797
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
798
|
+
var ptr2 = r0;
|
|
799
|
+
var len2 = r1;
|
|
800
|
+
if (r3) {
|
|
801
|
+
ptr2 = 0; len2 = 0;
|
|
802
|
+
throw takeObject(r2);
|
|
803
|
+
}
|
|
804
|
+
deferred3_0 = ptr2;
|
|
805
|
+
deferred3_1 = len2;
|
|
806
|
+
return getStringFromWasm0(ptr2, len2);
|
|
807
|
+
} finally {
|
|
808
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
809
|
+
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
|
|
814
|
+
|
|
815
|
+
const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
816
|
+
? { register: () => {}, unregister: () => {} }
|
|
817
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
|
|
818
|
+
|
|
819
|
+
export class UtxolibCompatNamespace {
|
|
820
|
+
|
|
821
|
+
__destroy_into_raw() {
|
|
822
|
+
const ptr = this.__wbg_ptr;
|
|
823
|
+
this.__wbg_ptr = 0;
|
|
824
|
+
UtxolibCompatNamespaceFinalization.unregister(this);
|
|
825
|
+
return ptr;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
free() {
|
|
829
|
+
const ptr = this.__destroy_into_raw();
|
|
830
|
+
wasm.__wbg_utxolibcompatnamespace_free(ptr, 0);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Convert address string to output script
|
|
834
|
+
*
|
|
835
|
+
* # Arguments
|
|
836
|
+
* * `address` - The address string
|
|
837
|
+
* * `network` - The UtxolibNetwork object from JavaScript
|
|
838
|
+
* * `format` - Optional address format (currently unused for decoding as all formats are accepted)
|
|
839
|
+
* @param {string} address
|
|
840
|
+
* @param {any} network
|
|
841
|
+
* @param {string | null} [format]
|
|
842
|
+
* @returns {Uint8Array}
|
|
843
|
+
*/
|
|
844
|
+
static to_output_script(address, network, format) {
|
|
845
|
+
try {
|
|
846
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
847
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
848
|
+
const len0 = WASM_VECTOR_LEN;
|
|
849
|
+
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
850
|
+
var len1 = WASM_VECTOR_LEN;
|
|
851
|
+
wasm.utxolibcompatnamespace_to_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
|
|
852
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
853
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
854
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
855
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
856
|
+
if (r3) {
|
|
857
|
+
throw takeObject(r2);
|
|
858
|
+
}
|
|
859
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
860
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
861
|
+
return v3;
|
|
862
|
+
} finally {
|
|
863
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Convert output script to address string
|
|
868
|
+
*
|
|
869
|
+
* # Arguments
|
|
870
|
+
* * `script` - The output script as a byte array
|
|
871
|
+
* * `network` - The UtxolibNetwork object from JavaScript
|
|
872
|
+
* * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
|
|
873
|
+
* @param {Uint8Array} script
|
|
874
|
+
* @param {any} network
|
|
875
|
+
* @param {string | null} [format]
|
|
876
|
+
* @returns {string}
|
|
877
|
+
*/
|
|
878
|
+
static from_output_script(script, network, format) {
|
|
879
|
+
let deferred4_0;
|
|
880
|
+
let deferred4_1;
|
|
881
|
+
try {
|
|
882
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
883
|
+
const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
|
|
884
|
+
const len0 = WASM_VECTOR_LEN;
|
|
885
|
+
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
886
|
+
var len1 = WASM_VECTOR_LEN;
|
|
887
|
+
wasm.utxolibcompatnamespace_from_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
|
|
888
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
889
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
890
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
891
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
892
|
+
var ptr3 = r0;
|
|
893
|
+
var len3 = r1;
|
|
894
|
+
if (r3) {
|
|
895
|
+
ptr3 = 0; len3 = 0;
|
|
896
|
+
throw takeObject(r2);
|
|
897
|
+
}
|
|
898
|
+
deferred4_0 = ptr3;
|
|
899
|
+
deferred4_1 = len3;
|
|
900
|
+
return getStringFromWasm0(ptr3, len3);
|
|
901
|
+
} finally {
|
|
902
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
903
|
+
wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
if (Symbol.dispose) UtxolibCompatNamespace.prototype[Symbol.dispose] = UtxolibCompatNamespace.prototype.free;
|
|
908
|
+
|
|
909
|
+
const WasmBIP32Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
910
|
+
? { register: () => {}, unregister: () => {} }
|
|
911
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmbip32_free(ptr >>> 0, 1));
|
|
912
|
+
/**
|
|
913
|
+
* WASM wrapper for BIP32 extended keys (Xpub/Xpriv)
|
|
914
|
+
* Implements the BIP32Interface TypeScript interface
|
|
915
|
+
*/
|
|
916
|
+
export class WasmBIP32 {
|
|
917
|
+
|
|
918
|
+
static __wrap(ptr) {
|
|
919
|
+
ptr = ptr >>> 0;
|
|
920
|
+
const obj = Object.create(WasmBIP32.prototype);
|
|
921
|
+
obj.__wbg_ptr = ptr;
|
|
922
|
+
WasmBIP32Finalization.register(obj, obj.__wbg_ptr, obj);
|
|
923
|
+
return obj;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
__destroy_into_raw() {
|
|
927
|
+
const ptr = this.__wbg_ptr;
|
|
928
|
+
this.__wbg_ptr = 0;
|
|
929
|
+
WasmBIP32Finalization.unregister(this);
|
|
930
|
+
return ptr;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
free() {
|
|
934
|
+
const ptr = this.__destroy_into_raw();
|
|
935
|
+
wasm.__wbg_wasmbip32_free(ptr, 0);
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Get the chain code as a Uint8Array
|
|
939
|
+
* @returns {Uint8Array}
|
|
940
|
+
*/
|
|
941
|
+
get chain_code() {
|
|
942
|
+
const ret = wasm.wasmbip32_chain_code(this.__wbg_ptr);
|
|
943
|
+
return takeObject(ret);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Get the identifier as a Uint8Array
|
|
947
|
+
* @returns {Uint8Array}
|
|
948
|
+
*/
|
|
949
|
+
get identifier() {
|
|
950
|
+
const ret = wasm.wasmbip32_identifier(this.__wbg_ptr);
|
|
951
|
+
return takeObject(ret);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Get the public key as a Uint8Array
|
|
955
|
+
* @returns {Uint8Array}
|
|
956
|
+
*/
|
|
957
|
+
get public_key() {
|
|
958
|
+
const ret = wasm.wasmbip32_public_key(this.__wbg_ptr);
|
|
959
|
+
return takeObject(ret);
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Derive a key using a derivation path (e.g., "0/1/2" or "m/0/1/2")
|
|
963
|
+
* @param {string} path
|
|
964
|
+
* @returns {WasmBIP32}
|
|
965
|
+
*/
|
|
966
|
+
derive_path(path) {
|
|
967
|
+
try {
|
|
968
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
969
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
970
|
+
const len0 = WASM_VECTOR_LEN;
|
|
971
|
+
wasm.wasmbip32_derive_path(retptr, this.__wbg_ptr, ptr0, len0);
|
|
972
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
973
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
974
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
975
|
+
if (r2) {
|
|
976
|
+
throw takeObject(r1);
|
|
977
|
+
}
|
|
978
|
+
return WasmBIP32.__wrap(r0);
|
|
979
|
+
} finally {
|
|
980
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Get the fingerprint as a Uint8Array
|
|
985
|
+
* @returns {Uint8Array}
|
|
986
|
+
*/
|
|
987
|
+
get fingerprint() {
|
|
988
|
+
const ret = wasm.wasmbip32_fingerprint(this.__wbg_ptr);
|
|
989
|
+
return takeObject(ret);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Create a BIP32 key from a base58 string (xpub/xprv/tpub/tprv)
|
|
993
|
+
* @param {string} base58_str
|
|
994
|
+
* @returns {WasmBIP32}
|
|
995
|
+
*/
|
|
996
|
+
static from_base58(base58_str) {
|
|
997
|
+
try {
|
|
998
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
999
|
+
const ptr0 = passStringToWasm0(base58_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1000
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1001
|
+
wasm.wasmbip32_from_base58(retptr, ptr0, len0);
|
|
1002
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1003
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1004
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1005
|
+
if (r2) {
|
|
1006
|
+
throw takeObject(r1);
|
|
1007
|
+
}
|
|
1008
|
+
return WasmBIP32.__wrap(r0);
|
|
1009
|
+
} finally {
|
|
1010
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Check if this is a neutered (public) key
|
|
1015
|
+
* @returns {boolean}
|
|
1016
|
+
*/
|
|
1017
|
+
is_neutered() {
|
|
1018
|
+
const ret = wasm.wasmbip32_is_neutered(this.__wbg_ptr);
|
|
1019
|
+
return ret !== 0;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Get the private key as a Uint8Array (if available)
|
|
1023
|
+
* @returns {Uint8Array | undefined}
|
|
1024
|
+
*/
|
|
1025
|
+
get private_key() {
|
|
1026
|
+
const ret = wasm.wasmbip32_private_key(this.__wbg_ptr);
|
|
1027
|
+
return takeObject(ret);
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Derive a hardened child key (only works for private keys)
|
|
1031
|
+
* @param {number} index
|
|
1032
|
+
* @returns {WasmBIP32}
|
|
1033
|
+
*/
|
|
1034
|
+
derive_hardened(index) {
|
|
1035
|
+
try {
|
|
1036
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1037
|
+
wasm.wasmbip32_derive_hardened(retptr, this.__wbg_ptr, index);
|
|
1038
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1039
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1040
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1041
|
+
if (r2) {
|
|
1042
|
+
throw takeObject(r1);
|
|
1043
|
+
}
|
|
1044
|
+
return WasmBIP32.__wrap(r0);
|
|
1045
|
+
} finally {
|
|
1046
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Get the parent fingerprint
|
|
1051
|
+
* @returns {number}
|
|
1052
|
+
*/
|
|
1053
|
+
get parent_fingerprint() {
|
|
1054
|
+
const ret = wasm.wasmbip32_parent_fingerprint(this.__wbg_ptr);
|
|
1055
|
+
return ret >>> 0;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Create a BIP32 key from a BIP32Interface JavaScript object properties
|
|
1059
|
+
* Expects an object with: network.bip32.public, depth, parentFingerprint,
|
|
1060
|
+
* index, chainCode, and publicKey properties
|
|
1061
|
+
* @param {any} bip32_key
|
|
1062
|
+
* @returns {WasmBIP32}
|
|
1063
|
+
*/
|
|
1064
|
+
static from_bip32_interface(bip32_key) {
|
|
1065
|
+
try {
|
|
1066
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1067
|
+
wasm.wasmbip32_from_bip32_interface(retptr, addBorrowedObject(bip32_key));
|
|
1068
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1069
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1070
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1071
|
+
if (r2) {
|
|
1072
|
+
throw takeObject(r1);
|
|
1073
|
+
}
|
|
1074
|
+
return WasmBIP32.__wrap(r0);
|
|
1075
|
+
} finally {
|
|
1076
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1077
|
+
heap[stack_pointer++] = undefined;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Create a BIP32 key from BIP32 properties
|
|
1082
|
+
* Extracts properties from a JavaScript object and constructs an xpub
|
|
1083
|
+
* @param {any} bip32_key
|
|
1084
|
+
* @returns {WasmBIP32}
|
|
1085
|
+
*/
|
|
1086
|
+
static from_bip32_properties(bip32_key) {
|
|
1087
|
+
try {
|
|
1088
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1089
|
+
wasm.wasmbip32_from_bip32_interface(retptr, addBorrowedObject(bip32_key));
|
|
1090
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1091
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1092
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1093
|
+
if (r2) {
|
|
1094
|
+
throw takeObject(r1);
|
|
1095
|
+
}
|
|
1096
|
+
return WasmBIP32.__wrap(r0);
|
|
1097
|
+
} finally {
|
|
1098
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1099
|
+
heap[stack_pointer++] = undefined;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Get the depth
|
|
1104
|
+
* @returns {number}
|
|
1105
|
+
*/
|
|
1106
|
+
get depth() {
|
|
1107
|
+
const ret = wasm.wasmbip32_depth(this.__wbg_ptr);
|
|
1108
|
+
return ret;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Get the child index
|
|
1112
|
+
* @returns {number}
|
|
1113
|
+
*/
|
|
1114
|
+
get index() {
|
|
1115
|
+
const ret = wasm.wasmbip32_index(this.__wbg_ptr);
|
|
1116
|
+
return ret >>> 0;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Derive a normal (non-hardened) child key
|
|
1120
|
+
* @param {number} index
|
|
1121
|
+
* @returns {WasmBIP32}
|
|
1122
|
+
*/
|
|
1123
|
+
derive(index) {
|
|
1124
|
+
try {
|
|
1125
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1126
|
+
wasm.wasmbip32_derive(retptr, this.__wbg_ptr, index);
|
|
1127
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1128
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1129
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1130
|
+
if (r2) {
|
|
1131
|
+
throw takeObject(r1);
|
|
1132
|
+
}
|
|
1133
|
+
return WasmBIP32.__wrap(r0);
|
|
1134
|
+
} finally {
|
|
1135
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Get the WIF encoding of the private key
|
|
1140
|
+
* @returns {string}
|
|
1141
|
+
*/
|
|
1142
|
+
to_wif() {
|
|
1143
|
+
let deferred2_0;
|
|
1144
|
+
let deferred2_1;
|
|
1145
|
+
try {
|
|
1146
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1147
|
+
wasm.wasmbip32_to_wif(retptr, this.__wbg_ptr);
|
|
1148
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1149
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1150
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1151
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1152
|
+
var ptr1 = r0;
|
|
1153
|
+
var len1 = r1;
|
|
1154
|
+
if (r3) {
|
|
1155
|
+
ptr1 = 0; len1 = 0;
|
|
1156
|
+
throw takeObject(r2);
|
|
1157
|
+
}
|
|
1158
|
+
deferred2_0 = ptr1;
|
|
1159
|
+
deferred2_1 = len1;
|
|
1160
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1161
|
+
} finally {
|
|
1162
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1163
|
+
wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Get the neutered (public) version of this key
|
|
1168
|
+
* @returns {WasmBIP32}
|
|
1169
|
+
*/
|
|
1170
|
+
neutered() {
|
|
1171
|
+
const ret = wasm.wasmbip32_neutered(this.__wbg_ptr);
|
|
1172
|
+
return WasmBIP32.__wrap(ret);
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Create a BIP32 master key from a seed
|
|
1176
|
+
* @param {Uint8Array} seed
|
|
1177
|
+
* @param {string | null} [network]
|
|
1178
|
+
* @returns {WasmBIP32}
|
|
1179
|
+
*/
|
|
1180
|
+
static from_seed(seed, network) {
|
|
1181
|
+
try {
|
|
1182
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1183
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_export_1);
|
|
1184
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1185
|
+
var ptr1 = isLikeNone(network) ? 0 : passStringToWasm0(network, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1186
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1187
|
+
wasm.wasmbip32_from_seed(retptr, ptr0, len0, ptr1, len1);
|
|
1188
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1189
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1190
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1191
|
+
if (r2) {
|
|
1192
|
+
throw takeObject(r1);
|
|
1193
|
+
}
|
|
1194
|
+
return WasmBIP32.__wrap(r0);
|
|
1195
|
+
} finally {
|
|
1196
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Create a BIP32 key from an xprv string (base58-encoded)
|
|
1201
|
+
* @param {string} xprv_str
|
|
1202
|
+
* @returns {WasmBIP32}
|
|
1203
|
+
*/
|
|
1204
|
+
static from_xprv(xprv_str) {
|
|
1205
|
+
try {
|
|
1206
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1207
|
+
const ptr0 = passStringToWasm0(xprv_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1208
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1209
|
+
wasm.wasmbip32_from_xprv(retptr, ptr0, len0);
|
|
1210
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1211
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1212
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1213
|
+
if (r2) {
|
|
1214
|
+
throw takeObject(r1);
|
|
1215
|
+
}
|
|
1216
|
+
return WasmBIP32.__wrap(r0);
|
|
1217
|
+
} finally {
|
|
1218
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Create a BIP32 key from an xpub string (base58-encoded)
|
|
1223
|
+
* @param {string} xpub_str
|
|
1224
|
+
* @returns {WasmBIP32}
|
|
1225
|
+
*/
|
|
1226
|
+
static from_xpub(xpub_str) {
|
|
1227
|
+
try {
|
|
1228
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1229
|
+
const ptr0 = passStringToWasm0(xpub_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1230
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1231
|
+
wasm.wasmbip32_from_xpub(retptr, ptr0, len0);
|
|
1232
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1233
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1234
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1235
|
+
if (r2) {
|
|
1236
|
+
throw takeObject(r1);
|
|
1237
|
+
}
|
|
1238
|
+
return WasmBIP32.__wrap(r0);
|
|
1239
|
+
} finally {
|
|
1240
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Serialize to base58 string
|
|
1245
|
+
* @returns {string}
|
|
1246
|
+
*/
|
|
1247
|
+
to_base58() {
|
|
1248
|
+
let deferred1_0;
|
|
1249
|
+
let deferred1_1;
|
|
1250
|
+
try {
|
|
1251
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1252
|
+
wasm.wasmbip32_to_base58(retptr, this.__wbg_ptr);
|
|
1253
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1254
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1255
|
+
deferred1_0 = r0;
|
|
1256
|
+
deferred1_1 = r1;
|
|
1257
|
+
return getStringFromWasm0(r0, r1);
|
|
1258
|
+
} finally {
|
|
1259
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1260
|
+
wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
if (Symbol.dispose) WasmBIP32.prototype[Symbol.dispose] = WasmBIP32.prototype.free;
|
|
1265
|
+
|
|
1266
|
+
const WasmECPairFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1267
|
+
? { register: () => {}, unregister: () => {} }
|
|
1268
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmecpair_free(ptr >>> 0, 1));
|
|
1269
|
+
/**
|
|
1270
|
+
* WASM wrapper for elliptic curve key pairs (always uses compressed keys)
|
|
1271
|
+
*/
|
|
1272
|
+
export class WasmECPair {
|
|
1273
|
+
|
|
1274
|
+
static __wrap(ptr) {
|
|
1275
|
+
ptr = ptr >>> 0;
|
|
1276
|
+
const obj = Object.create(WasmECPair.prototype);
|
|
1277
|
+
obj.__wbg_ptr = ptr;
|
|
1278
|
+
WasmECPairFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1279
|
+
return obj;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
__destroy_into_raw() {
|
|
1283
|
+
const ptr = this.__wbg_ptr;
|
|
1284
|
+
this.__wbg_ptr = 0;
|
|
1285
|
+
WasmECPairFinalization.unregister(this);
|
|
1286
|
+
return ptr;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
free() {
|
|
1290
|
+
const ptr = this.__destroy_into_raw();
|
|
1291
|
+
wasm.__wbg_wasmecpair_free(ptr, 0);
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Get the compressed public key as a Uint8Array (always 33 bytes)
|
|
1295
|
+
* @returns {Uint8Array}
|
|
1296
|
+
*/
|
|
1297
|
+
get public_key() {
|
|
1298
|
+
const ret = wasm.wasmecpair_public_key(this.__wbg_ptr);
|
|
1299
|
+
return takeObject(ret);
|
|
1300
|
+
}
|
|
1301
|
+
/**
|
|
1302
|
+
* Get the private key as a Uint8Array (if available)
|
|
1303
|
+
* @returns {Uint8Array | undefined}
|
|
1304
|
+
*/
|
|
1305
|
+
get private_key() {
|
|
1306
|
+
const ret = wasm.wasmecpair_private_key(this.__wbg_ptr);
|
|
1307
|
+
return takeObject(ret);
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Convert to mainnet WIF string
|
|
1311
|
+
* @returns {string}
|
|
1312
|
+
*/
|
|
1313
|
+
to_wif_mainnet() {
|
|
1314
|
+
let deferred2_0;
|
|
1315
|
+
let deferred2_1;
|
|
1316
|
+
try {
|
|
1317
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1318
|
+
wasm.wasmecpair_to_wif_mainnet(retptr, this.__wbg_ptr);
|
|
1319
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1320
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1321
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1322
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1323
|
+
var ptr1 = r0;
|
|
1324
|
+
var len1 = r1;
|
|
1325
|
+
if (r3) {
|
|
1326
|
+
ptr1 = 0; len1 = 0;
|
|
1327
|
+
throw takeObject(r2);
|
|
1328
|
+
}
|
|
1329
|
+
deferred2_0 = ptr1;
|
|
1330
|
+
deferred2_1 = len1;
|
|
1331
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1332
|
+
} finally {
|
|
1333
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1334
|
+
wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Convert to testnet WIF string
|
|
1339
|
+
* @returns {string}
|
|
1340
|
+
*/
|
|
1341
|
+
to_wif_testnet() {
|
|
1342
|
+
let deferred2_0;
|
|
1343
|
+
let deferred2_1;
|
|
1344
|
+
try {
|
|
1345
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1346
|
+
wasm.wasmecpair_to_wif_testnet(retptr, this.__wbg_ptr);
|
|
1347
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1348
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1349
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1350
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1351
|
+
var ptr1 = r0;
|
|
1352
|
+
var len1 = r1;
|
|
1353
|
+
if (r3) {
|
|
1354
|
+
ptr1 = 0; len1 = 0;
|
|
1355
|
+
throw takeObject(r2);
|
|
1356
|
+
}
|
|
1357
|
+
deferred2_0 = ptr1;
|
|
1358
|
+
deferred2_1 = len1;
|
|
1359
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1360
|
+
} finally {
|
|
1361
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1362
|
+
wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Create an ECPair from a public key (always uses compressed keys)
|
|
1367
|
+
* @param {Uint8Array} public_key
|
|
1368
|
+
* @returns {WasmECPair}
|
|
1369
|
+
*/
|
|
1370
|
+
static from_public_key(public_key) {
|
|
388
1371
|
try {
|
|
389
1372
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
390
|
-
|
|
1373
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_export_1);
|
|
1374
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1375
|
+
wasm.wasmecpair_from_public_key(retptr, ptr0, len0);
|
|
391
1376
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
392
1377
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
393
|
-
|
|
394
|
-
|
|
1378
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1379
|
+
if (r2) {
|
|
1380
|
+
throw takeObject(r1);
|
|
395
1381
|
}
|
|
1382
|
+
return WasmECPair.__wrap(r0);
|
|
396
1383
|
} finally {
|
|
397
1384
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
398
1385
|
}
|
|
399
1386
|
}
|
|
400
1387
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* @param {any} wallet_keys
|
|
405
|
-
* @returns {any}
|
|
1388
|
+
* Create an ECPair from a private key (always uses compressed keys)
|
|
1389
|
+
* @param {Uint8Array} private_key
|
|
1390
|
+
* @returns {WasmECPair}
|
|
406
1391
|
*/
|
|
407
|
-
|
|
1392
|
+
static from_private_key(private_key) {
|
|
408
1393
|
try {
|
|
409
1394
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
410
|
-
|
|
1395
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_export_1);
|
|
1396
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1397
|
+
wasm.wasmecpair_from_private_key(retptr, ptr0, len0);
|
|
411
1398
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
412
1399
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
413
1400
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
414
1401
|
if (r2) {
|
|
415
1402
|
throw takeObject(r1);
|
|
416
1403
|
}
|
|
417
|
-
return
|
|
1404
|
+
return WasmECPair.__wrap(r0);
|
|
418
1405
|
} finally {
|
|
419
1406
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
420
1407
|
}
|
|
421
1408
|
}
|
|
422
1409
|
/**
|
|
423
|
-
*
|
|
424
|
-
* @param {
|
|
425
|
-
* @
|
|
426
|
-
* @returns {any}
|
|
1410
|
+
* Create an ECPair from a mainnet WIF string
|
|
1411
|
+
* @param {string} wif_string
|
|
1412
|
+
* @returns {WasmECPair}
|
|
427
1413
|
*/
|
|
428
|
-
|
|
1414
|
+
static from_wif_mainnet(wif_string) {
|
|
429
1415
|
try {
|
|
430
1416
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
431
|
-
|
|
1417
|
+
const ptr0 = passStringToWasm0(wif_string, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1418
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1419
|
+
wasm.wasmecpair_from_wif_mainnet(retptr, ptr0, len0);
|
|
432
1420
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
433
1421
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
434
1422
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
435
1423
|
if (r2) {
|
|
436
1424
|
throw takeObject(r1);
|
|
437
1425
|
}
|
|
438
|
-
return
|
|
1426
|
+
return WasmECPair.__wrap(r0);
|
|
439
1427
|
} finally {
|
|
440
1428
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
441
1429
|
}
|
|
442
1430
|
}
|
|
443
1431
|
/**
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
* the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
|
|
448
|
-
* so this method verifies signatures without deriving from xpub.
|
|
449
|
-
*
|
|
450
|
-
* # Arguments
|
|
451
|
-
* - `input_index`: The index of the input to check
|
|
452
|
-
* - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
|
|
453
|
-
* Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
|
|
454
|
-
*
|
|
455
|
-
* # Returns
|
|
456
|
-
* - `Ok(true)` if the input is a replay protection input and has a valid signature
|
|
457
|
-
* - `Ok(false)` if the input is a replay protection input but has no valid signature
|
|
458
|
-
* - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
|
|
459
|
-
* @param {number} input_index
|
|
460
|
-
* @param {any} replay_protection
|
|
461
|
-
* @returns {boolean}
|
|
1432
|
+
* Create an ECPair from a testnet WIF string
|
|
1433
|
+
* @param {string} wif_string
|
|
1434
|
+
* @returns {WasmECPair}
|
|
462
1435
|
*/
|
|
463
|
-
|
|
1436
|
+
static from_wif_testnet(wif_string) {
|
|
464
1437
|
try {
|
|
465
1438
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
466
|
-
|
|
1439
|
+
const ptr0 = passStringToWasm0(wif_string, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1440
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1441
|
+
wasm.wasmecpair_from_wif_testnet(retptr, ptr0, len0);
|
|
467
1442
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
468
1443
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
469
1444
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
470
1445
|
if (r2) {
|
|
471
1446
|
throw takeObject(r1);
|
|
472
1447
|
}
|
|
473
|
-
return r0
|
|
1448
|
+
return WasmECPair.__wrap(r0);
|
|
474
1449
|
} finally {
|
|
475
1450
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
476
1451
|
}
|
|
477
1452
|
}
|
|
478
1453
|
/**
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
* # Returns
|
|
482
|
-
* The serialized PSBT as a byte array
|
|
483
|
-
* @returns {Uint8Array}
|
|
1454
|
+
* Convert to WIF string (mainnet)
|
|
1455
|
+
* @returns {string}
|
|
484
1456
|
*/
|
|
485
|
-
|
|
1457
|
+
to_wif() {
|
|
1458
|
+
let deferred2_0;
|
|
1459
|
+
let deferred2_1;
|
|
486
1460
|
try {
|
|
487
1461
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
488
|
-
wasm.
|
|
1462
|
+
wasm.wasmecpair_to_wif(retptr, this.__wbg_ptr);
|
|
489
1463
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
490
1464
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
491
1465
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
492
1466
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1467
|
+
var ptr1 = r0;
|
|
1468
|
+
var len1 = r1;
|
|
493
1469
|
if (r3) {
|
|
1470
|
+
ptr1 = 0; len1 = 0;
|
|
494
1471
|
throw takeObject(r2);
|
|
495
1472
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return
|
|
1473
|
+
deferred2_0 = ptr1;
|
|
1474
|
+
deferred2_1 = len1;
|
|
1475
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1476
|
+
} finally {
|
|
1477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1478
|
+
wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Create an ECPair from a WIF string (auto-detects network)
|
|
1483
|
+
* @param {string} wif_string
|
|
1484
|
+
* @returns {WasmECPair}
|
|
1485
|
+
*/
|
|
1486
|
+
static from_wif(wif_string) {
|
|
1487
|
+
try {
|
|
1488
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1489
|
+
const ptr0 = passStringToWasm0(wif_string, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1490
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1491
|
+
wasm.wasmecpair_from_wif(retptr, ptr0, len0);
|
|
1492
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1493
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1494
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1495
|
+
if (r2) {
|
|
1496
|
+
throw takeObject(r1);
|
|
1497
|
+
}
|
|
1498
|
+
return WasmECPair.__wrap(r0);
|
|
499
1499
|
} finally {
|
|
500
1500
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
501
1501
|
}
|
|
502
1502
|
}
|
|
503
1503
|
}
|
|
504
|
-
if (Symbol.dispose)
|
|
1504
|
+
if (Symbol.dispose) WasmECPair.prototype[Symbol.dispose] = WasmECPair.prototype.free;
|
|
505
1505
|
|
|
506
|
-
const
|
|
1506
|
+
const WasmReplayProtectionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
507
1507
|
? { register: () => {}, unregister: () => {} }
|
|
508
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
1508
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmreplayprotection_free(ptr >>> 0, 1));
|
|
1509
|
+
/**
|
|
1510
|
+
* WASM wrapper for ReplayProtection
|
|
1511
|
+
*/
|
|
1512
|
+
export class WasmReplayProtection {
|
|
509
1513
|
|
|
510
|
-
|
|
1514
|
+
static __wrap(ptr) {
|
|
1515
|
+
ptr = ptr >>> 0;
|
|
1516
|
+
const obj = Object.create(WasmReplayProtection.prototype);
|
|
1517
|
+
obj.__wbg_ptr = ptr;
|
|
1518
|
+
WasmReplayProtectionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1519
|
+
return obj;
|
|
1520
|
+
}
|
|
511
1521
|
|
|
512
1522
|
__destroy_into_raw() {
|
|
513
1523
|
const ptr = this.__wbg_ptr;
|
|
514
1524
|
this.__wbg_ptr = 0;
|
|
515
|
-
|
|
1525
|
+
WasmReplayProtectionFinalization.unregister(this);
|
|
516
1526
|
return ptr;
|
|
517
1527
|
}
|
|
518
1528
|
|
|
519
1529
|
free() {
|
|
520
1530
|
const ptr = this.__destroy_into_raw();
|
|
521
|
-
wasm.
|
|
1531
|
+
wasm.__wbg_wasmreplayprotection_free(ptr, 0);
|
|
522
1532
|
}
|
|
523
1533
|
/**
|
|
524
|
-
*
|
|
525
|
-
* @param {
|
|
526
|
-
* @param {
|
|
527
|
-
* @
|
|
528
|
-
* @returns {Uint8Array}
|
|
1534
|
+
* Create from addresses (requires network for decoding)
|
|
1535
|
+
* @param {any[]} addresses
|
|
1536
|
+
* @param {string} network
|
|
1537
|
+
* @returns {WasmReplayProtection}
|
|
529
1538
|
*/
|
|
530
|
-
static
|
|
1539
|
+
static from_addresses(addresses, network) {
|
|
531
1540
|
try {
|
|
532
1541
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
533
|
-
|
|
1542
|
+
const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_export_1);
|
|
1543
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1544
|
+
const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1545
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1546
|
+
wasm.wasmreplayprotection_from_addresses(retptr, ptr0, len0, ptr1, len1);
|
|
534
1547
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
535
1548
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
536
1549
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
throw takeObject(r2);
|
|
1550
|
+
if (r2) {
|
|
1551
|
+
throw takeObject(r1);
|
|
540
1552
|
}
|
|
541
|
-
|
|
542
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
543
|
-
return v1;
|
|
1553
|
+
return WasmReplayProtection.__wrap(r0);
|
|
544
1554
|
} finally {
|
|
545
1555
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
546
1556
|
}
|
|
547
1557
|
}
|
|
548
1558
|
/**
|
|
549
|
-
*
|
|
550
|
-
* @param {
|
|
551
|
-
* @
|
|
552
|
-
* @param {any} network
|
|
553
|
-
* @param {string | null} [address_format]
|
|
554
|
-
* @returns {string}
|
|
1559
|
+
* Create from public keys (derives P2SH-P2PK output scripts)
|
|
1560
|
+
* @param {Uint8Array[]} public_keys
|
|
1561
|
+
* @returns {WasmReplayProtection}
|
|
555
1562
|
*/
|
|
556
|
-
static
|
|
557
|
-
let deferred3_0;
|
|
558
|
-
let deferred3_1;
|
|
1563
|
+
static from_public_keys(public_keys) {
|
|
559
1564
|
try {
|
|
560
1565
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
wasm.
|
|
1566
|
+
const ptr0 = passArrayJsValueToWasm0(public_keys, wasm.__wbindgen_export_1);
|
|
1567
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1568
|
+
wasm.wasmreplayprotection_from_public_keys(retptr, ptr0, len0);
|
|
564
1569
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
565
1570
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
566
1571
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
var len2 = r1;
|
|
570
|
-
if (r3) {
|
|
571
|
-
ptr2 = 0; len2 = 0;
|
|
572
|
-
throw takeObject(r2);
|
|
1572
|
+
if (r2) {
|
|
1573
|
+
throw takeObject(r1);
|
|
573
1574
|
}
|
|
574
|
-
|
|
575
|
-
deferred3_1 = len2;
|
|
576
|
-
return getStringFromWasm0(ptr2, len2);
|
|
1575
|
+
return WasmReplayProtection.__wrap(r0);
|
|
577
1576
|
} finally {
|
|
578
1577
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
579
|
-
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
580
1578
|
}
|
|
581
1579
|
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Create from output scripts directly
|
|
1582
|
+
* @param {Uint8Array[]} output_scripts
|
|
1583
|
+
* @returns {WasmReplayProtection}
|
|
1584
|
+
*/
|
|
1585
|
+
static from_output_scripts(output_scripts) {
|
|
1586
|
+
const ptr0 = passArrayJsValueToWasm0(output_scripts, wasm.__wbindgen_export_1);
|
|
1587
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1588
|
+
const ret = wasm.wasmreplayprotection_from_output_scripts(ptr0, len0);
|
|
1589
|
+
return WasmReplayProtection.__wrap(ret);
|
|
1590
|
+
}
|
|
582
1591
|
}
|
|
583
|
-
if (Symbol.dispose)
|
|
1592
|
+
if (Symbol.dispose) WasmReplayProtection.prototype[Symbol.dispose] = WasmReplayProtection.prototype.free;
|
|
584
1593
|
|
|
585
|
-
const
|
|
1594
|
+
const WasmRootWalletKeysFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
586
1595
|
? { register: () => {}, unregister: () => {} }
|
|
587
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
1596
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmrootwalletkeys_free(ptr >>> 0, 1));
|
|
1597
|
+
/**
|
|
1598
|
+
* WASM wrapper for RootWalletKeys
|
|
1599
|
+
* Represents a set of three extended public keys with their derivation prefixes
|
|
1600
|
+
*/
|
|
1601
|
+
export class WasmRootWalletKeys {
|
|
588
1602
|
|
|
589
|
-
|
|
1603
|
+
static __wrap(ptr) {
|
|
1604
|
+
ptr = ptr >>> 0;
|
|
1605
|
+
const obj = Object.create(WasmRootWalletKeys.prototype);
|
|
1606
|
+
obj.__wbg_ptr = ptr;
|
|
1607
|
+
WasmRootWalletKeysFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1608
|
+
return obj;
|
|
1609
|
+
}
|
|
590
1610
|
|
|
591
1611
|
__destroy_into_raw() {
|
|
592
1612
|
const ptr = this.__wbg_ptr;
|
|
593
1613
|
this.__wbg_ptr = 0;
|
|
594
|
-
|
|
1614
|
+
WasmRootWalletKeysFinalization.unregister(this);
|
|
595
1615
|
return ptr;
|
|
596
1616
|
}
|
|
597
1617
|
|
|
598
1618
|
free() {
|
|
599
1619
|
const ptr = this.__destroy_into_raw();
|
|
600
|
-
wasm.
|
|
1620
|
+
wasm.__wbg_wasmrootwalletkeys_free(ptr, 0);
|
|
601
1621
|
}
|
|
602
1622
|
/**
|
|
603
|
-
*
|
|
1623
|
+
* Get the backup key (second xpub)
|
|
1624
|
+
* @returns {WasmBIP32}
|
|
1625
|
+
*/
|
|
1626
|
+
backup_key() {
|
|
1627
|
+
const ret = wasm.wasmrootwalletkeys_backup_key(this.__wbg_ptr);
|
|
1628
|
+
return WasmBIP32.__wrap(ret);
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Create a RootWalletKeys from three BIP32 keys with custom derivation prefixes
|
|
604
1632
|
*
|
|
605
1633
|
* # Arguments
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
* @
|
|
1634
|
+
* - `user`: User key (first xpub)
|
|
1635
|
+
* - `backup`: Backup key (second xpub)
|
|
1636
|
+
* - `bitgo`: BitGo key (third xpub)
|
|
1637
|
+
* - `user_derivation`: Derivation path for user key (e.g., "m/0/0")
|
|
1638
|
+
* - `backup_derivation`: Derivation path for backup key (e.g., "m/0/0")
|
|
1639
|
+
* - `bitgo_derivation`: Derivation path for bitgo key (e.g., "m/0/0")
|
|
1640
|
+
* @param {WasmBIP32} user
|
|
1641
|
+
* @param {WasmBIP32} backup
|
|
1642
|
+
* @param {WasmBIP32} bitgo
|
|
1643
|
+
* @param {string} user_derivation
|
|
1644
|
+
* @param {string} backup_derivation
|
|
1645
|
+
* @param {string} bitgo_derivation
|
|
1646
|
+
* @returns {WasmRootWalletKeys}
|
|
613
1647
|
*/
|
|
614
|
-
static
|
|
1648
|
+
static with_derivation_prefixes(user, backup, bitgo, user_derivation, backup_derivation, bitgo_derivation) {
|
|
615
1649
|
try {
|
|
616
1650
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
617
|
-
|
|
1651
|
+
_assertClass(user, WasmBIP32);
|
|
1652
|
+
_assertClass(backup, WasmBIP32);
|
|
1653
|
+
_assertClass(bitgo, WasmBIP32);
|
|
1654
|
+
const ptr0 = passStringToWasm0(user_derivation, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
618
1655
|
const len0 = WASM_VECTOR_LEN;
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
1656
|
+
const ptr1 = passStringToWasm0(backup_derivation, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1657
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1658
|
+
const ptr2 = passStringToWasm0(bitgo_derivation, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1659
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1660
|
+
wasm.wasmrootwalletkeys_with_derivation_prefixes(retptr, user.__wbg_ptr, backup.__wbg_ptr, bitgo.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
622
1661
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
623
1662
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
624
1663
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
throw takeObject(r2);
|
|
1664
|
+
if (r2) {
|
|
1665
|
+
throw takeObject(r1);
|
|
628
1666
|
}
|
|
629
|
-
|
|
630
|
-
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
631
|
-
return v3;
|
|
1667
|
+
return WasmRootWalletKeys.__wrap(r0);
|
|
632
1668
|
} finally {
|
|
633
1669
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
634
1670
|
}
|
|
635
1671
|
}
|
|
636
1672
|
/**
|
|
637
|
-
*
|
|
1673
|
+
* Create a RootWalletKeys from three BIP32 keys
|
|
1674
|
+
* Uses default derivation prefix of m/0/0 for all three keys
|
|
638
1675
|
*
|
|
639
1676
|
* # Arguments
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
* @param {
|
|
644
|
-
* @param {
|
|
645
|
-
* @param {
|
|
646
|
-
* @returns {string}
|
|
1677
|
+
* - `user`: User key (first xpub)
|
|
1678
|
+
* - `backup`: Backup key (second xpub)
|
|
1679
|
+
* - `bitgo`: BitGo key (third xpub)
|
|
1680
|
+
* @param {WasmBIP32} user
|
|
1681
|
+
* @param {WasmBIP32} backup
|
|
1682
|
+
* @param {WasmBIP32} bitgo
|
|
647
1683
|
*/
|
|
648
|
-
|
|
649
|
-
let deferred4_0;
|
|
650
|
-
let deferred4_1;
|
|
1684
|
+
constructor(user, backup, bitgo) {
|
|
651
1685
|
try {
|
|
652
1686
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
wasm.utxolibcompatnamespace_from_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
|
|
1687
|
+
_assertClass(user, WasmBIP32);
|
|
1688
|
+
_assertClass(backup, WasmBIP32);
|
|
1689
|
+
_assertClass(bitgo, WasmBIP32);
|
|
1690
|
+
wasm.wasmrootwalletkeys_new(retptr, user.__wbg_ptr, backup.__wbg_ptr, bitgo.__wbg_ptr);
|
|
658
1691
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
659
1692
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
660
1693
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
var len3 = r1;
|
|
664
|
-
if (r3) {
|
|
665
|
-
ptr3 = 0; len3 = 0;
|
|
666
|
-
throw takeObject(r2);
|
|
1694
|
+
if (r2) {
|
|
1695
|
+
throw takeObject(r1);
|
|
667
1696
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
return
|
|
1697
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
1698
|
+
WasmRootWalletKeysFinalization.register(this, this.__wbg_ptr, this);
|
|
1699
|
+
return this;
|
|
671
1700
|
} finally {
|
|
672
1701
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
673
|
-
wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
|
|
674
1702
|
}
|
|
675
1703
|
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Get the user key (first xpub)
|
|
1706
|
+
* @returns {WasmBIP32}
|
|
1707
|
+
*/
|
|
1708
|
+
user_key() {
|
|
1709
|
+
const ret = wasm.wasmrootwalletkeys_user_key(this.__wbg_ptr);
|
|
1710
|
+
return WasmBIP32.__wrap(ret);
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Get the bitgo key (third xpub)
|
|
1714
|
+
* @returns {WasmBIP32}
|
|
1715
|
+
*/
|
|
1716
|
+
bitgo_key() {
|
|
1717
|
+
const ret = wasm.wasmrootwalletkeys_bitgo_key(this.__wbg_ptr);
|
|
1718
|
+
return WasmBIP32.__wrap(ret);
|
|
1719
|
+
}
|
|
676
1720
|
}
|
|
677
|
-
if (Symbol.dispose)
|
|
1721
|
+
if (Symbol.dispose) WasmRootWalletKeys.prototype[Symbol.dispose] = WasmRootWalletKeys.prototype.free;
|
|
678
1722
|
|
|
679
1723
|
const WrapDescriptorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
680
1724
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -1292,45 +2336,33 @@ export function __wbg_call_13410aac570ffff7() { return handleError(function (arg
|
|
|
1292
2336
|
return addHeapObject(ret);
|
|
1293
2337
|
}, arguments) };
|
|
1294
2338
|
|
|
1295
|
-
export function
|
|
1296
|
-
const ret =
|
|
2339
|
+
export function __wbg_call_a5400b25a865cfd8() { return handleError(function (arg0, arg1, arg2) {
|
|
2340
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
1297
2341
|
return addHeapObject(ret);
|
|
1298
|
-
};
|
|
2342
|
+
}, arguments) };
|
|
1299
2343
|
|
|
1300
|
-
export function
|
|
1301
|
-
const ret = getObject(arg0)
|
|
2344
|
+
export function __wbg_crypto_574e78ad8b13b65f(arg0) {
|
|
2345
|
+
const ret = getObject(arg0).crypto;
|
|
1302
2346
|
return addHeapObject(ret);
|
|
1303
2347
|
};
|
|
1304
2348
|
|
|
2349
|
+
export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
|
|
2350
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
2351
|
+
}, arguments) };
|
|
2352
|
+
|
|
1305
2353
|
export function __wbg_get_458e874b43b18b25() { return handleError(function (arg0, arg1) {
|
|
1306
2354
|
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
1307
2355
|
return addHeapObject(ret);
|
|
1308
2356
|
}, arguments) };
|
|
1309
2357
|
|
|
1310
|
-
export function
|
|
1311
|
-
let result;
|
|
1312
|
-
try {
|
|
1313
|
-
result = getObject(arg0) instanceof Uint8Array;
|
|
1314
|
-
} catch (_) {
|
|
1315
|
-
result = false;
|
|
1316
|
-
}
|
|
1317
|
-
const ret = result;
|
|
1318
|
-
return ret;
|
|
1319
|
-
};
|
|
1320
|
-
|
|
1321
|
-
export function __wbg_isArray_030cce220591fb41(arg0) {
|
|
1322
|
-
const ret = Array.isArray(getObject(arg0));
|
|
1323
|
-
return ret;
|
|
1324
|
-
};
|
|
1325
|
-
|
|
1326
|
-
export function __wbg_length_186546c51cd61acd(arg0) {
|
|
2358
|
+
export function __wbg_length_6bb7e81f9d7713e4(arg0) {
|
|
1327
2359
|
const ret = getObject(arg0).length;
|
|
1328
2360
|
return ret;
|
|
1329
2361
|
};
|
|
1330
2362
|
|
|
1331
|
-
export function
|
|
1332
|
-
const ret = getObject(arg0).
|
|
1333
|
-
return ret;
|
|
2363
|
+
export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
|
|
2364
|
+
const ret = getObject(arg0).msCrypto;
|
|
2365
|
+
return addHeapObject(ret);
|
|
1334
2366
|
};
|
|
1335
2367
|
|
|
1336
2368
|
export function __wbg_new_19c25a3f2fa63a02() {
|
|
@@ -1358,6 +2390,26 @@ export function __wbg_newfromslice_074c56947bd43469(arg0, arg1) {
|
|
|
1358
2390
|
return addHeapObject(ret);
|
|
1359
2391
|
};
|
|
1360
2392
|
|
|
2393
|
+
export function __wbg_newnoargs_254190557c45b4ec(arg0, arg1) {
|
|
2394
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
2395
|
+
return addHeapObject(ret);
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2398
|
+
export function __wbg_newwithlength_a167dcc7aaa3ba77(arg0) {
|
|
2399
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
2400
|
+
return addHeapObject(ret);
|
|
2401
|
+
};
|
|
2402
|
+
|
|
2403
|
+
export function __wbg_node_905d3e251edff8a2(arg0) {
|
|
2404
|
+
const ret = getObject(arg0).node;
|
|
2405
|
+
return addHeapObject(ret);
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2408
|
+
export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
|
|
2409
|
+
const ret = getObject(arg0).process;
|
|
2410
|
+
return addHeapObject(ret);
|
|
2411
|
+
};
|
|
2412
|
+
|
|
1361
2413
|
export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
|
|
1362
2414
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
1363
2415
|
};
|
|
@@ -1367,11 +2419,50 @@ export function __wbg_push_330b2eb93e4e1212(arg0, arg1) {
|
|
|
1367
2419
|
return ret;
|
|
1368
2420
|
};
|
|
1369
2421
|
|
|
2422
|
+
export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
|
|
2423
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
2424
|
+
}, arguments) };
|
|
2425
|
+
|
|
2426
|
+
export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
|
|
2427
|
+
const ret = module.require;
|
|
2428
|
+
return addHeapObject(ret);
|
|
2429
|
+
}, arguments) };
|
|
2430
|
+
|
|
1370
2431
|
export function __wbg_set_453345bcda80b89a() { return handleError(function (arg0, arg1, arg2) {
|
|
1371
2432
|
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
1372
2433
|
return ret;
|
|
1373
2434
|
}, arguments) };
|
|
1374
2435
|
|
|
2436
|
+
export function __wbg_static_accessor_GLOBAL_8921f820c2ce3f12() {
|
|
2437
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
2438
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2441
|
+
export function __wbg_static_accessor_GLOBAL_THIS_f0a4409105898184() {
|
|
2442
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
2443
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
2444
|
+
};
|
|
2445
|
+
|
|
2446
|
+
export function __wbg_static_accessor_SELF_995b214ae681ff99() {
|
|
2447
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
2448
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
2449
|
+
};
|
|
2450
|
+
|
|
2451
|
+
export function __wbg_static_accessor_WINDOW_cde3890479c675ea() {
|
|
2452
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
2453
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
2454
|
+
};
|
|
2455
|
+
|
|
2456
|
+
export function __wbg_subarray_70fd07feefe14294(arg0, arg1, arg2) {
|
|
2457
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
2458
|
+
return addHeapObject(ret);
|
|
2459
|
+
};
|
|
2460
|
+
|
|
2461
|
+
export function __wbg_versions_c01dfd4722a88165(arg0) {
|
|
2462
|
+
const ret = getObject(arg0).versions;
|
|
2463
|
+
return addHeapObject(ret);
|
|
2464
|
+
};
|
|
2465
|
+
|
|
1375
2466
|
export function __wbg_wbindgenisfunction_8cee7dce3725ae74(arg0) {
|
|
1376
2467
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
1377
2468
|
return ret;
|
|
@@ -1388,6 +2479,11 @@ export function __wbg_wbindgenisobject_307a53c6bd97fbf8(arg0) {
|
|
|
1388
2479
|
return ret;
|
|
1389
2480
|
};
|
|
1390
2481
|
|
|
2482
|
+
export function __wbg_wbindgenisstring_d4fa939789f003b0(arg0) {
|
|
2483
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
2484
|
+
return ret;
|
|
2485
|
+
};
|
|
2486
|
+
|
|
1391
2487
|
export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
|
|
1392
2488
|
const ret = getObject(arg0) === undefined;
|
|
1393
2489
|
return ret;
|
|
@@ -1425,6 +2521,12 @@ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
|
|
|
1425
2521
|
return addHeapObject(ret);
|
|
1426
2522
|
};
|
|
1427
2523
|
|
|
2524
|
+
export function __wbindgen_cast_cb9088102bce6b30(arg0, arg1) {
|
|
2525
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
2526
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
2527
|
+
return addHeapObject(ret);
|
|
2528
|
+
};
|
|
2529
|
+
|
|
1428
2530
|
export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
|
|
1429
2531
|
// Cast intrinsic for `F64 -> Externref`.
|
|
1430
2532
|
const ret = arg0;
|