@bitgo/wasm-utxo 4.25.0 → 4.26.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.
@@ -0,0 +1,57 @@
1
+ import { ZcashUnifiedAddress as WasmZcashUnifiedAddress } from "../wasm/wasm_utxo.js";
2
+ import type { ZcashNetworkName } from "./ZcashBitGoPsbt.js";
3
+ /**
4
+ * A parsed ZIP-316 Unified Address.
5
+ *
6
+ * Decode once with {@link ZcashUnifiedAddress.parse}, then read each component
7
+ * through its accessor (returns `undefined` when the receiver is absent). Membership
8
+ * of another address is answered by {@link contains}.
9
+ *
10
+ * Ironwood reuses the Orchard receiver, so {@link orchardReceiver} is the shielded
11
+ * receiver used to construct an Ironwood output note.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
16
+ * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
17
+ * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
18
+ * ua.contains(transparentAddress); // is it one of this UA's receivers?
19
+ * ```
20
+ */
21
+ export declare class ZcashUnifiedAddress {
22
+ private _wasm;
23
+ private constructor();
24
+ /**
25
+ * Parse a Unified Address.
26
+ *
27
+ * @param address - The Bech32m unified address string
28
+ * @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
29
+ * @throws If the address is malformed or on the wrong network
30
+ */
31
+ static parse(address: string, network: ZcashNetworkName): ZcashUnifiedAddress;
32
+ /**
33
+ * The Orchard (a.k.a. Ironwood) receiver — 43 raw bytes (11-byte diversifier +
34
+ * 32-byte pk_d) — or `undefined` if the UA has no Orchard receiver.
35
+ */
36
+ get orchardReceiver(): Uint8Array | undefined;
37
+ /**
38
+ * The Sapling receiver — 43 raw bytes (diversifier + pk_d) — or `undefined`.
39
+ */
40
+ get saplingReceiver(): Uint8Array | undefined;
41
+ /**
42
+ * The transparent receiver as scriptPubKey bytes (P2PKH or P2SH), ready to use as
43
+ * a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
44
+ */
45
+ get transparentScript(): Uint8Array | undefined;
46
+ /**
47
+ * Whether `candidate` is a receiver of this unified address.
48
+ *
49
+ * @param candidate - Another Unified Address (matches if all of its receivers are
50
+ * contained here) or a transparent Zcash address (matches this UA's transparent
51
+ * receiver). Must be on the same network as this UA.
52
+ * @throws If `candidate` is malformed or on the wrong network
53
+ */
54
+ contains(candidate: string): boolean;
55
+ /** @internal */
56
+ get wasm(): WasmZcashUnifiedAddress;
57
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZcashUnifiedAddress = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ /**
6
+ * A parsed ZIP-316 Unified Address.
7
+ *
8
+ * Decode once with {@link ZcashUnifiedAddress.parse}, then read each component
9
+ * through its accessor (returns `undefined` when the receiver is absent). Membership
10
+ * of another address is answered by {@link contains}.
11
+ *
12
+ * Ironwood reuses the Orchard receiver, so {@link orchardReceiver} is the shielded
13
+ * receiver used to construct an Ironwood output note.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
18
+ * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
19
+ * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
20
+ * ua.contains(transparentAddress); // is it one of this UA's receivers?
21
+ * ```
22
+ */
23
+ class ZcashUnifiedAddress {
24
+ _wasm;
25
+ constructor(_wasm) {
26
+ this._wasm = _wasm;
27
+ }
28
+ /**
29
+ * Parse a Unified Address.
30
+ *
31
+ * @param address - The Bech32m unified address string
32
+ * @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
33
+ * @throws If the address is malformed or on the wrong network
34
+ */
35
+ static parse(address, network) {
36
+ return new ZcashUnifiedAddress(wasm_utxo_js_1.ZcashUnifiedAddress.parse(address, network));
37
+ }
38
+ /**
39
+ * The Orchard (a.k.a. Ironwood) receiver — 43 raw bytes (11-byte diversifier +
40
+ * 32-byte pk_d) — or `undefined` if the UA has no Orchard receiver.
41
+ */
42
+ get orchardReceiver() {
43
+ return this._wasm.orchardReceiver;
44
+ }
45
+ /**
46
+ * The Sapling receiver — 43 raw bytes (diversifier + pk_d) — or `undefined`.
47
+ */
48
+ get saplingReceiver() {
49
+ return this._wasm.saplingReceiver;
50
+ }
51
+ /**
52
+ * The transparent receiver as scriptPubKey bytes (P2PKH or P2SH), ready to use as
53
+ * a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
54
+ */
55
+ get transparentScript() {
56
+ return this._wasm.transparentScript;
57
+ }
58
+ /**
59
+ * Whether `candidate` is a receiver of this unified address.
60
+ *
61
+ * @param candidate - Another Unified Address (matches if all of its receivers are
62
+ * contained here) or a transparent Zcash address (matches this UA's transparent
63
+ * receiver). Must be on the same network as this UA.
64
+ * @throws If `candidate` is malformed or on the wrong network
65
+ */
66
+ contains(candidate) {
67
+ return this._wasm.contains(candidate);
68
+ }
69
+ /** @internal */
70
+ get wasm() {
71
+ return this._wasm;
72
+ }
73
+ }
74
+ exports.ZcashUnifiedAddress = ZcashUnifiedAddress;
@@ -9,6 +9,7 @@ export { requiresPrevTxForP2sh } from "./prevTx.js";
9
9
  export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, type HydrationUnspent, } from "./BitGoPsbt.js";
10
10
  export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
11
11
  export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
12
+ export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
12
13
  import type { ScriptType } from "./scriptType.js";
13
14
  /**
14
15
  * Check if a network supports a given fixed-script wallet script type
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.requiresPrevTxForP2sh = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
3
+ exports.ZcashUnifiedAddress = exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.requiresPrevTxForP2sh = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
4
4
  exports.supportsScriptType = supportsScriptType;
5
5
  exports.createOpReturnScript = createOpReturnScript;
6
6
  exports.p2shP2pkOutputScript = p2shP2pkOutputScript;
@@ -33,6 +33,9 @@ Object.defineProperty(exports, "BitGoKeySubtype", { enumerable: true, get: funct
33
33
  // Zcash-specific PSBT subclass
34
34
  var ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
35
35
  Object.defineProperty(exports, "ZcashBitGoPsbt", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.ZcashBitGoPsbt; } });
36
+ // Zcash ZIP-316 Unified Address
37
+ var ZcashUnifiedAddress_js_1 = require("./ZcashUnifiedAddress.js");
38
+ Object.defineProperty(exports, "ZcashUnifiedAddress", { enumerable: true, get: function () { return ZcashUnifiedAddress_js_1.ZcashUnifiedAddress; } });
36
39
  /**
37
40
  * Check if a network supports a given fixed-script wallet script type
38
41
  *
@@ -1584,6 +1584,43 @@ export class WrapPsbt {
1584
1584
  version(): number;
1585
1585
  }
1586
1586
 
1587
+ /**
1588
+ * A parsed ZIP-316 Unified Address.
1589
+ *
1590
+ * Decode once with [`ZcashUnifiedAddress::parse`], then read each component through
1591
+ * its accessor (returns `undefined` when absent). Ironwood reuses the Orchard
1592
+ * receiver, so `orchardReceiver` is the shielded receiver for Ironwood output notes.
1593
+ */
1594
+ export class ZcashUnifiedAddress {
1595
+ private constructor();
1596
+ free(): void;
1597
+ [Symbol.dispose](): void;
1598
+ /**
1599
+ * Whether `candidate` (another Unified Address, or a transparent Zcash address
1600
+ * on the same network) is a receiver of this Unified Address.
1601
+ */
1602
+ contains(candidate: string): boolean;
1603
+ /**
1604
+ * Parse a Unified Address for `network` ("zcash"/"zec" or "zcashTest"/"tzec").
1605
+ *
1606
+ * All receiver components are resolved and validated eagerly, so the accessors
1607
+ * below are infallible. Throws if the address is malformed or on the wrong network.
1608
+ */
1609
+ static parse(address: string, network: string): ZcashUnifiedAddress;
1610
+ /**
1611
+ * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
1612
+ */
1613
+ readonly orchardReceiver: Uint8Array | undefined;
1614
+ /**
1615
+ * The Sapling receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
1616
+ */
1617
+ readonly saplingReceiver: Uint8Array | undefined;
1618
+ /**
1619
+ * The transparent receiver as scriptPubKey bytes (P2PKH/P2SH), or `undefined`.
1620
+ */
1621
+ readonly transparentScript: Uint8Array | undefined;
1622
+ }
1623
+
1587
1624
  /**
1588
1625
  * Check if the inspect feature is enabled.
1589
1626
  *
@@ -1661,5 +1698,8 @@ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
1661
1698
  * `network`: "zcash" / "zec" for mainnet, "zcashTest" / "tzec" for testnet.
1662
1699
  * Returns `None` if `height` is before Overwinter activation.
1663
1700
  * Throws if `network` is not a recognised Zcash network name.
1701
+ *
1702
+ * Errors are thrown as the crate-standard [`WasmUtxoError`] (a marked `js_sys::Error`
1703
+ * with `.message` and `.code`), not a bare string.
1664
1704
  */
1665
1705
  export function zcash_branch_id_for_height(network: string, height: number): number | undefined;
@@ -6215,6 +6215,146 @@ class WrapPsbt {
6215
6215
  if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
6216
6216
  exports.WrapPsbt = WrapPsbt;
6217
6217
 
6218
+ /**
6219
+ * A parsed ZIP-316 Unified Address.
6220
+ *
6221
+ * Decode once with [`ZcashUnifiedAddress::parse`], then read each component through
6222
+ * its accessor (returns `undefined` when absent). Ironwood reuses the Orchard
6223
+ * receiver, so `orchardReceiver` is the shielded receiver for Ironwood output notes.
6224
+ */
6225
+ class ZcashUnifiedAddress {
6226
+ static __wrap(ptr) {
6227
+ ptr = ptr >>> 0;
6228
+ const obj = Object.create(ZcashUnifiedAddress.prototype);
6229
+ obj.__wbg_ptr = ptr;
6230
+ ZcashUnifiedAddressFinalization.register(obj, obj.__wbg_ptr, obj);
6231
+ return obj;
6232
+ }
6233
+ __destroy_into_raw() {
6234
+ const ptr = this.__wbg_ptr;
6235
+ this.__wbg_ptr = 0;
6236
+ ZcashUnifiedAddressFinalization.unregister(this);
6237
+ return ptr;
6238
+ }
6239
+ free() {
6240
+ const ptr = this.__destroy_into_raw();
6241
+ wasm.__wbg_zcashunifiedaddress_free(ptr, 0);
6242
+ }
6243
+ /**
6244
+ * Whether `candidate` (another Unified Address, or a transparent Zcash address
6245
+ * on the same network) is a receiver of this Unified Address.
6246
+ * @param {string} candidate
6247
+ * @returns {boolean}
6248
+ */
6249
+ contains(candidate) {
6250
+ try {
6251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6252
+ const ptr0 = passStringToWasm0(candidate, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6253
+ const len0 = WASM_VECTOR_LEN;
6254
+ wasm.zcashunifiedaddress_contains(retptr, this.__wbg_ptr, ptr0, len0);
6255
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6256
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6257
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6258
+ if (r2) {
6259
+ throw takeObject(r1);
6260
+ }
6261
+ return r0 !== 0;
6262
+ } finally {
6263
+ wasm.__wbindgen_add_to_stack_pointer(16);
6264
+ }
6265
+ }
6266
+ /**
6267
+ * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
6268
+ * @returns {Uint8Array | undefined}
6269
+ */
6270
+ get orchardReceiver() {
6271
+ try {
6272
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6273
+ wasm.zcashunifiedaddress_orchardReceiver(retptr, this.__wbg_ptr);
6274
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6275
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6276
+ let v1;
6277
+ if (r0 !== 0) {
6278
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
6279
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6280
+ }
6281
+ return v1;
6282
+ } finally {
6283
+ wasm.__wbindgen_add_to_stack_pointer(16);
6284
+ }
6285
+ }
6286
+ /**
6287
+ * Parse a Unified Address for `network` ("zcash"/"zec" or "zcashTest"/"tzec").
6288
+ *
6289
+ * All receiver components are resolved and validated eagerly, so the accessors
6290
+ * below are infallible. Throws if the address is malformed or on the wrong network.
6291
+ * @param {string} address
6292
+ * @param {string} network
6293
+ * @returns {ZcashUnifiedAddress}
6294
+ */
6295
+ static parse(address, network) {
6296
+ try {
6297
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6298
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6299
+ const len0 = WASM_VECTOR_LEN;
6300
+ const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6301
+ const len1 = WASM_VECTOR_LEN;
6302
+ wasm.zcashunifiedaddress_parse(retptr, ptr0, len0, ptr1, len1);
6303
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6304
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6305
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6306
+ if (r2) {
6307
+ throw takeObject(r1);
6308
+ }
6309
+ return ZcashUnifiedAddress.__wrap(r0);
6310
+ } finally {
6311
+ wasm.__wbindgen_add_to_stack_pointer(16);
6312
+ }
6313
+ }
6314
+ /**
6315
+ * The Sapling receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
6316
+ * @returns {Uint8Array | undefined}
6317
+ */
6318
+ get saplingReceiver() {
6319
+ try {
6320
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6321
+ wasm.zcashunifiedaddress_saplingReceiver(retptr, this.__wbg_ptr);
6322
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6323
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6324
+ let v1;
6325
+ if (r0 !== 0) {
6326
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
6327
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6328
+ }
6329
+ return v1;
6330
+ } finally {
6331
+ wasm.__wbindgen_add_to_stack_pointer(16);
6332
+ }
6333
+ }
6334
+ /**
6335
+ * The transparent receiver as scriptPubKey bytes (P2PKH/P2SH), or `undefined`.
6336
+ * @returns {Uint8Array | undefined}
6337
+ */
6338
+ get transparentScript() {
6339
+ try {
6340
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6341
+ wasm.zcashunifiedaddress_transparentScript(retptr, this.__wbg_ptr);
6342
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6343
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6344
+ let v1;
6345
+ if (r0 !== 0) {
6346
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
6347
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6348
+ }
6349
+ return v1;
6350
+ } finally {
6351
+ wasm.__wbindgen_add_to_stack_pointer(16);
6352
+ }
6353
+ }
6354
+ }
6355
+ if (Symbol.dispose) ZcashUnifiedAddress.prototype[Symbol.dispose] = ZcashUnifiedAddress.prototype.free;
6356
+ exports.ZcashUnifiedAddress = ZcashUnifiedAddress;
6357
+
6218
6358
  /**
6219
6359
  * Check if the inspect feature is enabled.
6220
6360
  *
@@ -6390,6 +6530,9 @@ exports.parseTxToJson = parseTxToJson;
6390
6530
  * `network`: "zcash" / "zec" for mainnet, "zcashTest" / "tzec" for testnet.
6391
6531
  * Returns `None` if `height` is before Overwinter activation.
6392
6532
  * Throws if `network` is not a recognised Zcash network name.
6533
+ *
6534
+ * Errors are thrown as the crate-standard [`WasmUtxoError`] (a marked `js_sys::Error`
6535
+ * with `.message` and `.code`), not a bare string.
6393
6536
  * @param {string} network
6394
6537
  * @param {number} height
6395
6538
  * @returns {number | undefined}
@@ -6712,6 +6855,9 @@ const WrapMiniscriptFinalization = (typeof FinalizationRegistry === 'undefined')
6712
6855
  const WrapPsbtFinalization = (typeof FinalizationRegistry === 'undefined')
6713
6856
  ? { register: () => {}, unregister: () => {} }
6714
6857
  : new FinalizationRegistry(ptr => wasm.__wbg_wrappsbt_free(ptr >>> 0, 1));
6858
+ const ZcashUnifiedAddressFinalization = (typeof FinalizationRegistry === 'undefined')
6859
+ ? { register: () => {}, unregister: () => {} }
6860
+ : new FinalizationRegistry(ptr => wasm.__wbg_zcashunifiedaddress_free(ptr >>> 0, 1));
6715
6861
 
6716
6862
  function addHeapObject(obj) {
6717
6863
  if (heap_next === heap.length) heap.push(heap.length + 1);
Binary file
@@ -7,18 +7,16 @@ export const __wbg_messagenamespace_free: (a: number, b: number) => void;
7
7
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
8
8
  export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
9
9
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
10
+ export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
10
11
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
11
- export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
12
12
  export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
13
13
  export const __wbg_wrappsbt_free: (a: number, b: number) => void;
14
14
  export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
15
15
  export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
16
16
  export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
17
17
  export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => void;
18
- export const isInspectEnabled: () => number;
19
18
  export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
20
19
  export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
21
- export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
22
20
  export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
23
21
  export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
24
22
  export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
@@ -46,6 +44,11 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
46
44
  export const wasmdimensions_has_segwit: (a: number) => number;
47
45
  export const wasmdimensions_plus: (a: number, b: number) => number;
48
46
  export const wasmdimensions_times: (a: number, b: number) => number;
47
+ export const wasmrootwalletkeys_backup_key: (a: number) => number;
48
+ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
49
+ export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
50
+ export const wasmrootwalletkeys_user_key: (a: number) => number;
51
+ export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
49
52
  export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
50
53
  export const wasmtransaction_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
51
54
  export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
@@ -58,7 +61,6 @@ export const wasmtransaction_get_outputs_with_address: (a: number, b: number, c:
58
61
  export const wasmtransaction_get_txid: (a: number, b: number) => void;
59
62
  export const wasmtransaction_get_vsize: (a: number) => number;
60
63
  export const wasmtransaction_to_bytes: (a: number, b: number) => void;
61
- export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
62
64
  export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
63
65
  export const wasmzcashtransaction_get_inputs: (a: number, b: number) => void;
64
66
  export const wasmzcashtransaction_get_outputs: (a: number, b: number) => void;
@@ -112,43 +114,19 @@ export const wasmtransaction_input_count: (a: number) => number;
112
114
  export const wasmtransaction_output_count: (a: number) => number;
113
115
  export const wasmzcashtransaction_input_count: (a: number) => number;
114
116
  export const wasmzcashtransaction_output_count: (a: number) => number;
115
- export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
116
- export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
117
117
  export const wasmtransaction_lock_time: (a: number) => number;
118
118
  export const wasmtransaction_version: (a: number) => number;
119
119
  export const wasmzcashtransaction_lock_time: (a: number) => number;
120
120
  export const wasmzcashtransaction_version: (a: number) => number;
121
121
  export const wrappsbt_lock_time: (a: number) => number;
122
122
  export const wrappsbt_version: (a: number) => number;
123
- export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
124
- export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
125
- export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
126
- export const wrapdescriptor_descType: (a: number, b: number) => void;
127
- export const wrapdescriptor_encode: (a: number, b: number) => void;
128
- export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
129
- export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
130
- export const wrapdescriptor_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
131
- export const wrapdescriptor_hasWildcard: (a: number) => number;
132
- export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
133
- export const wrapdescriptor_node: (a: number, b: number) => void;
134
- export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
135
- export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
136
- export const wrapdescriptor_toString: (a: number, b: number) => void;
137
- export const wrapminiscript_encode: (a: number, b: number) => void;
138
- export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
139
- export const wrapminiscript_fromBitcoinScriptExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
140
- export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
141
- export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
142
- export const wrapminiscript_node: (a: number, b: number) => void;
143
- export const wrapminiscript_toAsmString: (a: number, b: number) => void;
144
- export const wrapminiscript_toString: (a: number, b: number) => void;
145
123
  export const __wbg_bip322namespace_free: (a: number, b: number) => void;
146
124
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
147
125
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
148
126
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
149
127
  export const __wbg_wasmecpair_free: (a: number, b: number) => void;
150
128
  export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
151
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
129
+ export const __wbg_zcashunifiedaddress_free: (a: number, b: number) => void;
152
130
  export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
153
131
  export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
154
132
  export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
@@ -238,6 +216,8 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
238
216
  export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
239
217
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
240
218
  export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
219
+ export const isInspectEnabled: () => number;
220
+ export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
241
221
  export const wasmbip32_chain_code: (a: number) => number;
242
222
  export const wasmbip32_depth: (a: number) => number;
243
223
  export const wasmbip32_derive: (a: number, b: number, c: number) => void;
@@ -273,16 +253,42 @@ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
273
253
  export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
274
254
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
275
255
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
276
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
277
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
278
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
279
- export const wasmrootwalletkeys_user_key: (a: number) => number;
280
- export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
281
256
  export const zcash_branch_id_for_height: (a: number, b: number, c: number, d: number) => void;
257
+ export const zcashunifiedaddress_contains: (a: number, b: number, c: number, d: number) => void;
258
+ export const zcashunifiedaddress_orchardReceiver: (a: number, b: number) => void;
259
+ export const zcashunifiedaddress_parse: (a: number, b: number, c: number, d: number, e: number) => void;
260
+ export const zcashunifiedaddress_saplingReceiver: (a: number, b: number) => void;
261
+ export const zcashunifiedaddress_transparentScript: (a: number, b: number) => void;
282
262
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
263
+ export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
264
+ export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
283
265
  export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
284
266
  export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
285
267
  export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
268
+ export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
269
+ export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
270
+ export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
271
+ export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
272
+ export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
273
+ export const wrapdescriptor_descType: (a: number, b: number) => void;
274
+ export const wrapdescriptor_encode: (a: number, b: number) => void;
275
+ export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
276
+ export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
277
+ export const wrapdescriptor_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
278
+ export const wrapdescriptor_hasWildcard: (a: number) => number;
279
+ export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
280
+ export const wrapdescriptor_node: (a: number, b: number) => void;
281
+ export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
282
+ export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
283
+ export const wrapdescriptor_toString: (a: number, b: number) => void;
284
+ export const wrapminiscript_encode: (a: number, b: number) => void;
285
+ export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
286
+ export const wrapminiscript_fromBitcoinScriptExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
287
+ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
288
+ export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
289
+ export const wrapminiscript_node: (a: number, b: number) => void;
290
+ export const wrapminiscript_toAsmString: (a: number, b: number) => void;
291
+ export const wrapminiscript_toString: (a: number, b: number) => void;
286
292
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
287
293
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
288
294
  export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
@@ -0,0 +1,57 @@
1
+ import { ZcashUnifiedAddress as WasmZcashUnifiedAddress } from "../wasm/wasm_utxo.js";
2
+ import type { ZcashNetworkName } from "./ZcashBitGoPsbt.js";
3
+ /**
4
+ * A parsed ZIP-316 Unified Address.
5
+ *
6
+ * Decode once with {@link ZcashUnifiedAddress.parse}, then read each component
7
+ * through its accessor (returns `undefined` when the receiver is absent). Membership
8
+ * of another address is answered by {@link contains}.
9
+ *
10
+ * Ironwood reuses the Orchard receiver, so {@link orchardReceiver} is the shielded
11
+ * receiver used to construct an Ironwood output note.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
16
+ * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
17
+ * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
18
+ * ua.contains(transparentAddress); // is it one of this UA's receivers?
19
+ * ```
20
+ */
21
+ export declare class ZcashUnifiedAddress {
22
+ private _wasm;
23
+ private constructor();
24
+ /**
25
+ * Parse a Unified Address.
26
+ *
27
+ * @param address - The Bech32m unified address string
28
+ * @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
29
+ * @throws If the address is malformed or on the wrong network
30
+ */
31
+ static parse(address: string, network: ZcashNetworkName): ZcashUnifiedAddress;
32
+ /**
33
+ * The Orchard (a.k.a. Ironwood) receiver — 43 raw bytes (11-byte diversifier +
34
+ * 32-byte pk_d) — or `undefined` if the UA has no Orchard receiver.
35
+ */
36
+ get orchardReceiver(): Uint8Array | undefined;
37
+ /**
38
+ * The Sapling receiver — 43 raw bytes (diversifier + pk_d) — or `undefined`.
39
+ */
40
+ get saplingReceiver(): Uint8Array | undefined;
41
+ /**
42
+ * The transparent receiver as scriptPubKey bytes (P2PKH or P2SH), ready to use as
43
+ * a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
44
+ */
45
+ get transparentScript(): Uint8Array | undefined;
46
+ /**
47
+ * Whether `candidate` is a receiver of this unified address.
48
+ *
49
+ * @param candidate - Another Unified Address (matches if all of its receivers are
50
+ * contained here) or a transparent Zcash address (matches this UA's transparent
51
+ * receiver). Must be on the same network as this UA.
52
+ * @throws If `candidate` is malformed or on the wrong network
53
+ */
54
+ contains(candidate: string): boolean;
55
+ /** @internal */
56
+ get wasm(): WasmZcashUnifiedAddress;
57
+ }
@@ -0,0 +1,70 @@
1
+ import { ZcashUnifiedAddress as WasmZcashUnifiedAddress } from "../wasm/wasm_utxo.js";
2
+ /**
3
+ * A parsed ZIP-316 Unified Address.
4
+ *
5
+ * Decode once with {@link ZcashUnifiedAddress.parse}, then read each component
6
+ * through its accessor (returns `undefined` when the receiver is absent). Membership
7
+ * of another address is answered by {@link contains}.
8
+ *
9
+ * Ironwood reuses the Orchard receiver, so {@link orchardReceiver} is the shielded
10
+ * receiver used to construct an Ironwood output note.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
15
+ * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
16
+ * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
17
+ * ua.contains(transparentAddress); // is it one of this UA's receivers?
18
+ * ```
19
+ */
20
+ export class ZcashUnifiedAddress {
21
+ _wasm;
22
+ constructor(_wasm) {
23
+ this._wasm = _wasm;
24
+ }
25
+ /**
26
+ * Parse a Unified Address.
27
+ *
28
+ * @param address - The Bech32m unified address string
29
+ * @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
30
+ * @throws If the address is malformed or on the wrong network
31
+ */
32
+ static parse(address, network) {
33
+ return new ZcashUnifiedAddress(WasmZcashUnifiedAddress.parse(address, network));
34
+ }
35
+ /**
36
+ * The Orchard (a.k.a. Ironwood) receiver — 43 raw bytes (11-byte diversifier +
37
+ * 32-byte pk_d) — or `undefined` if the UA has no Orchard receiver.
38
+ */
39
+ get orchardReceiver() {
40
+ return this._wasm.orchardReceiver;
41
+ }
42
+ /**
43
+ * The Sapling receiver — 43 raw bytes (diversifier + pk_d) — or `undefined`.
44
+ */
45
+ get saplingReceiver() {
46
+ return this._wasm.saplingReceiver;
47
+ }
48
+ /**
49
+ * The transparent receiver as scriptPubKey bytes (P2PKH or P2SH), ready to use as
50
+ * a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
51
+ */
52
+ get transparentScript() {
53
+ return this._wasm.transparentScript;
54
+ }
55
+ /**
56
+ * Whether `candidate` is a receiver of this unified address.
57
+ *
58
+ * @param candidate - Another Unified Address (matches if all of its receivers are
59
+ * contained here) or a transparent Zcash address (matches this UA's transparent
60
+ * receiver). Must be on the same network as this UA.
61
+ * @throws If `candidate` is malformed or on the wrong network
62
+ */
63
+ contains(candidate) {
64
+ return this._wasm.contains(candidate);
65
+ }
66
+ /** @internal */
67
+ get wasm() {
68
+ return this._wasm;
69
+ }
70
+ }
@@ -9,6 +9,7 @@ export { requiresPrevTxForP2sh } from "./prevTx.js";
9
9
  export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, type HydrationUnspent, } from "./BitGoPsbt.js";
10
10
  export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
11
11
  export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
12
+ export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
12
13
  import type { ScriptType } from "./scriptType.js";
13
14
  /**
14
15
  * Check if a network supports a given fixed-script wallet script type
@@ -12,6 +12,8 @@ export { BitGoPsbt, getWalletKeysFromPsbt, } from "./BitGoPsbt.js";
12
12
  export { BitGoKeySubtype } from "./BitGoKeySubtype.js";
13
13
  // Zcash-specific PSBT subclass
14
14
  export { ZcashBitGoPsbt, } from "./ZcashBitGoPsbt.js";
15
+ // Zcash ZIP-316 Unified Address
16
+ export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
15
17
  /**
16
18
  * Check if a network supports a given fixed-script wallet script type
17
19
  *
@@ -1584,6 +1584,43 @@ export class WrapPsbt {
1584
1584
  version(): number;
1585
1585
  }
1586
1586
 
1587
+ /**
1588
+ * A parsed ZIP-316 Unified Address.
1589
+ *
1590
+ * Decode once with [`ZcashUnifiedAddress::parse`], then read each component through
1591
+ * its accessor (returns `undefined` when absent). Ironwood reuses the Orchard
1592
+ * receiver, so `orchardReceiver` is the shielded receiver for Ironwood output notes.
1593
+ */
1594
+ export class ZcashUnifiedAddress {
1595
+ private constructor();
1596
+ free(): void;
1597
+ [Symbol.dispose](): void;
1598
+ /**
1599
+ * Whether `candidate` (another Unified Address, or a transparent Zcash address
1600
+ * on the same network) is a receiver of this Unified Address.
1601
+ */
1602
+ contains(candidate: string): boolean;
1603
+ /**
1604
+ * Parse a Unified Address for `network` ("zcash"/"zec" or "zcashTest"/"tzec").
1605
+ *
1606
+ * All receiver components are resolved and validated eagerly, so the accessors
1607
+ * below are infallible. Throws if the address is malformed or on the wrong network.
1608
+ */
1609
+ static parse(address: string, network: string): ZcashUnifiedAddress;
1610
+ /**
1611
+ * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
1612
+ */
1613
+ readonly orchardReceiver: Uint8Array | undefined;
1614
+ /**
1615
+ * The Sapling receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
1616
+ */
1617
+ readonly saplingReceiver: Uint8Array | undefined;
1618
+ /**
1619
+ * The transparent receiver as scriptPubKey bytes (P2PKH/P2SH), or `undefined`.
1620
+ */
1621
+ readonly transparentScript: Uint8Array | undefined;
1622
+ }
1623
+
1587
1624
  /**
1588
1625
  * Check if the inspect feature is enabled.
1589
1626
  *
@@ -1661,5 +1698,8 @@ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
1661
1698
  * `network`: "zcash" / "zec" for mainnet, "zcashTest" / "tzec" for testnet.
1662
1699
  * Returns `None` if `height` is before Overwinter activation.
1663
1700
  * Throws if `network` is not a recognised Zcash network name.
1701
+ *
1702
+ * Errors are thrown as the crate-standard [`WasmUtxoError`] (a marked `js_sys::Error`
1703
+ * with `.message` and `.code`), not a bare string.
1664
1704
  */
1665
1705
  export function zcash_branch_id_for_height(network: string, height: number): number | undefined;
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./wasm_utxo_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
 
7
7
  export {
8
- AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmUtxoNamespace, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson, zcash_branch_id_for_height
8
+ AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmUtxoNamespace, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, ZcashUnifiedAddress, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson, zcash_branch_id_for_height
9
9
  } from "./wasm_utxo_bg.js";
@@ -6194,6 +6194,145 @@ export class WrapPsbt {
6194
6194
  }
6195
6195
  if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
6196
6196
 
6197
+ /**
6198
+ * A parsed ZIP-316 Unified Address.
6199
+ *
6200
+ * Decode once with [`ZcashUnifiedAddress::parse`], then read each component through
6201
+ * its accessor (returns `undefined` when absent). Ironwood reuses the Orchard
6202
+ * receiver, so `orchardReceiver` is the shielded receiver for Ironwood output notes.
6203
+ */
6204
+ export class ZcashUnifiedAddress {
6205
+ static __wrap(ptr) {
6206
+ ptr = ptr >>> 0;
6207
+ const obj = Object.create(ZcashUnifiedAddress.prototype);
6208
+ obj.__wbg_ptr = ptr;
6209
+ ZcashUnifiedAddressFinalization.register(obj, obj.__wbg_ptr, obj);
6210
+ return obj;
6211
+ }
6212
+ __destroy_into_raw() {
6213
+ const ptr = this.__wbg_ptr;
6214
+ this.__wbg_ptr = 0;
6215
+ ZcashUnifiedAddressFinalization.unregister(this);
6216
+ return ptr;
6217
+ }
6218
+ free() {
6219
+ const ptr = this.__destroy_into_raw();
6220
+ wasm.__wbg_zcashunifiedaddress_free(ptr, 0);
6221
+ }
6222
+ /**
6223
+ * Whether `candidate` (another Unified Address, or a transparent Zcash address
6224
+ * on the same network) is a receiver of this Unified Address.
6225
+ * @param {string} candidate
6226
+ * @returns {boolean}
6227
+ */
6228
+ contains(candidate) {
6229
+ try {
6230
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6231
+ const ptr0 = passStringToWasm0(candidate, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6232
+ const len0 = WASM_VECTOR_LEN;
6233
+ wasm.zcashunifiedaddress_contains(retptr, this.__wbg_ptr, ptr0, len0);
6234
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6235
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6236
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6237
+ if (r2) {
6238
+ throw takeObject(r1);
6239
+ }
6240
+ return r0 !== 0;
6241
+ } finally {
6242
+ wasm.__wbindgen_add_to_stack_pointer(16);
6243
+ }
6244
+ }
6245
+ /**
6246
+ * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
6247
+ * @returns {Uint8Array | undefined}
6248
+ */
6249
+ get orchardReceiver() {
6250
+ try {
6251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6252
+ wasm.zcashunifiedaddress_orchardReceiver(retptr, this.__wbg_ptr);
6253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6255
+ let v1;
6256
+ if (r0 !== 0) {
6257
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
6258
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6259
+ }
6260
+ return v1;
6261
+ } finally {
6262
+ wasm.__wbindgen_add_to_stack_pointer(16);
6263
+ }
6264
+ }
6265
+ /**
6266
+ * Parse a Unified Address for `network` ("zcash"/"zec" or "zcashTest"/"tzec").
6267
+ *
6268
+ * All receiver components are resolved and validated eagerly, so the accessors
6269
+ * below are infallible. Throws if the address is malformed or on the wrong network.
6270
+ * @param {string} address
6271
+ * @param {string} network
6272
+ * @returns {ZcashUnifiedAddress}
6273
+ */
6274
+ static parse(address, network) {
6275
+ try {
6276
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6277
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6278
+ const len0 = WASM_VECTOR_LEN;
6279
+ const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
6280
+ const len1 = WASM_VECTOR_LEN;
6281
+ wasm.zcashunifiedaddress_parse(retptr, ptr0, len0, ptr1, len1);
6282
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6283
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6284
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6285
+ if (r2) {
6286
+ throw takeObject(r1);
6287
+ }
6288
+ return ZcashUnifiedAddress.__wrap(r0);
6289
+ } finally {
6290
+ wasm.__wbindgen_add_to_stack_pointer(16);
6291
+ }
6292
+ }
6293
+ /**
6294
+ * The Sapling receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
6295
+ * @returns {Uint8Array | undefined}
6296
+ */
6297
+ get saplingReceiver() {
6298
+ try {
6299
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6300
+ wasm.zcashunifiedaddress_saplingReceiver(retptr, this.__wbg_ptr);
6301
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6302
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6303
+ let v1;
6304
+ if (r0 !== 0) {
6305
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
6306
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6307
+ }
6308
+ return v1;
6309
+ } finally {
6310
+ wasm.__wbindgen_add_to_stack_pointer(16);
6311
+ }
6312
+ }
6313
+ /**
6314
+ * The transparent receiver as scriptPubKey bytes (P2PKH/P2SH), or `undefined`.
6315
+ * @returns {Uint8Array | undefined}
6316
+ */
6317
+ get transparentScript() {
6318
+ try {
6319
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6320
+ wasm.zcashunifiedaddress_transparentScript(retptr, this.__wbg_ptr);
6321
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6322
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6323
+ let v1;
6324
+ if (r0 !== 0) {
6325
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
6326
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
6327
+ }
6328
+ return v1;
6329
+ } finally {
6330
+ wasm.__wbindgen_add_to_stack_pointer(16);
6331
+ }
6332
+ }
6333
+ }
6334
+ if (Symbol.dispose) ZcashUnifiedAddress.prototype[Symbol.dispose] = ZcashUnifiedAddress.prototype.free;
6335
+
6197
6336
  /**
6198
6337
  * Check if the inspect feature is enabled.
6199
6338
  *
@@ -6365,6 +6504,9 @@ export function parseTxToJson(tx_bytes, coin_name) {
6365
6504
  * `network`: "zcash" / "zec" for mainnet, "zcashTest" / "tzec" for testnet.
6366
6505
  * Returns `None` if `height` is before Overwinter activation.
6367
6506
  * Throws if `network` is not a recognised Zcash network name.
6507
+ *
6508
+ * Errors are thrown as the crate-standard [`WasmUtxoError`] (a marked `js_sys::Error`
6509
+ * with `.message` and `.code`), not a bare string.
6368
6510
  * @param {string} network
6369
6511
  * @param {number} height
6370
6512
  * @returns {number | undefined}
@@ -6675,6 +6817,9 @@ const WrapMiniscriptFinalization = (typeof FinalizationRegistry === 'undefined')
6675
6817
  const WrapPsbtFinalization = (typeof FinalizationRegistry === 'undefined')
6676
6818
  ? { register: () => {}, unregister: () => {} }
6677
6819
  : new FinalizationRegistry(ptr => wasm.__wbg_wrappsbt_free(ptr >>> 0, 1));
6820
+ const ZcashUnifiedAddressFinalization = (typeof FinalizationRegistry === 'undefined')
6821
+ ? { register: () => {}, unregister: () => {} }
6822
+ : new FinalizationRegistry(ptr => wasm.__wbg_zcashunifiedaddress_free(ptr >>> 0, 1));
6678
6823
 
6679
6824
  function addHeapObject(obj) {
6680
6825
  if (heap_next === heap.length) heap.push(heap.length + 1);
Binary file
@@ -7,18 +7,16 @@ export const __wbg_messagenamespace_free: (a: number, b: number) => void;
7
7
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
8
8
  export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
9
9
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
10
+ export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
10
11
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
11
- export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
12
12
  export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
13
13
  export const __wbg_wrappsbt_free: (a: number, b: number) => void;
14
14
  export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
15
15
  export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
16
16
  export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
17
17
  export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => void;
18
- export const isInspectEnabled: () => number;
19
18
  export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
20
19
  export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
21
- export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
22
20
  export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
23
21
  export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
24
22
  export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
@@ -46,6 +44,11 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
46
44
  export const wasmdimensions_has_segwit: (a: number) => number;
47
45
  export const wasmdimensions_plus: (a: number, b: number) => number;
48
46
  export const wasmdimensions_times: (a: number, b: number) => number;
47
+ export const wasmrootwalletkeys_backup_key: (a: number) => number;
48
+ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
49
+ export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
50
+ export const wasmrootwalletkeys_user_key: (a: number) => number;
51
+ export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
49
52
  export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
50
53
  export const wasmtransaction_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
51
54
  export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
@@ -58,7 +61,6 @@ export const wasmtransaction_get_outputs_with_address: (a: number, b: number, c:
58
61
  export const wasmtransaction_get_txid: (a: number, b: number) => void;
59
62
  export const wasmtransaction_get_vsize: (a: number) => number;
60
63
  export const wasmtransaction_to_bytes: (a: number, b: number) => void;
61
- export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
62
64
  export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
63
65
  export const wasmzcashtransaction_get_inputs: (a: number, b: number) => void;
64
66
  export const wasmzcashtransaction_get_outputs: (a: number, b: number) => void;
@@ -112,43 +114,19 @@ export const wasmtransaction_input_count: (a: number) => number;
112
114
  export const wasmtransaction_output_count: (a: number) => number;
113
115
  export const wasmzcashtransaction_input_count: (a: number) => number;
114
116
  export const wasmzcashtransaction_output_count: (a: number) => number;
115
- export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
116
- export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
117
117
  export const wasmtransaction_lock_time: (a: number) => number;
118
118
  export const wasmtransaction_version: (a: number) => number;
119
119
  export const wasmzcashtransaction_lock_time: (a: number) => number;
120
120
  export const wasmzcashtransaction_version: (a: number) => number;
121
121
  export const wrappsbt_lock_time: (a: number) => number;
122
122
  export const wrappsbt_version: (a: number) => number;
123
- export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
124
- export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
125
- export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
126
- export const wrapdescriptor_descType: (a: number, b: number) => void;
127
- export const wrapdescriptor_encode: (a: number, b: number) => void;
128
- export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
129
- export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
130
- export const wrapdescriptor_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
131
- export const wrapdescriptor_hasWildcard: (a: number) => number;
132
- export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
133
- export const wrapdescriptor_node: (a: number, b: number) => void;
134
- export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
135
- export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
136
- export const wrapdescriptor_toString: (a: number, b: number) => void;
137
- export const wrapminiscript_encode: (a: number, b: number) => void;
138
- export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
139
- export const wrapminiscript_fromBitcoinScriptExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
140
- export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
141
- export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
142
- export const wrapminiscript_node: (a: number, b: number) => void;
143
- export const wrapminiscript_toAsmString: (a: number, b: number) => void;
144
- export const wrapminiscript_toString: (a: number, b: number) => void;
145
123
  export const __wbg_bip322namespace_free: (a: number, b: number) => void;
146
124
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
147
125
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
148
126
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
149
127
  export const __wbg_wasmecpair_free: (a: number, b: number) => void;
150
128
  export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
151
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
129
+ export const __wbg_zcashunifiedaddress_free: (a: number, b: number) => void;
152
130
  export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
153
131
  export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
154
132
  export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
@@ -238,6 +216,8 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
238
216
  export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
239
217
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
240
218
  export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
219
+ export const isInspectEnabled: () => number;
220
+ export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
241
221
  export const wasmbip32_chain_code: (a: number) => number;
242
222
  export const wasmbip32_depth: (a: number) => number;
243
223
  export const wasmbip32_derive: (a: number, b: number, c: number) => void;
@@ -273,16 +253,42 @@ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
273
253
  export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
274
254
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
275
255
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
276
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
277
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
278
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
279
- export const wasmrootwalletkeys_user_key: (a: number) => number;
280
- export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
281
256
  export const zcash_branch_id_for_height: (a: number, b: number, c: number, d: number) => void;
257
+ export const zcashunifiedaddress_contains: (a: number, b: number, c: number, d: number) => void;
258
+ export const zcashunifiedaddress_orchardReceiver: (a: number, b: number) => void;
259
+ export const zcashunifiedaddress_parse: (a: number, b: number, c: number, d: number, e: number) => void;
260
+ export const zcashunifiedaddress_saplingReceiver: (a: number, b: number) => void;
261
+ export const zcashunifiedaddress_transparentScript: (a: number, b: number) => void;
282
262
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
263
+ export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
264
+ export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
283
265
  export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
284
266
  export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
285
267
  export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
268
+ export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
269
+ export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
270
+ export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
271
+ export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
272
+ export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
273
+ export const wrapdescriptor_descType: (a: number, b: number) => void;
274
+ export const wrapdescriptor_encode: (a: number, b: number) => void;
275
+ export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
276
+ export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
277
+ export const wrapdescriptor_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
278
+ export const wrapdescriptor_hasWildcard: (a: number) => number;
279
+ export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
280
+ export const wrapdescriptor_node: (a: number, b: number) => void;
281
+ export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
282
+ export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
283
+ export const wrapdescriptor_toString: (a: number, b: number) => void;
284
+ export const wrapminiscript_encode: (a: number, b: number) => void;
285
+ export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
286
+ export const wrapminiscript_fromBitcoinScriptExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
287
+ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
288
+ export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
289
+ export const wrapminiscript_node: (a: number, b: number) => void;
290
+ export const wrapminiscript_toAsmString: (a: number, b: number) => void;
291
+ export const wrapminiscript_toString: (a: number, b: number) => void;
286
292
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
287
293
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
288
294
  export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitgo/wasm-utxo",
3
3
  "description": "WebAssembly wrapper for rust-bitcoin (beta)",
4
- "version": "4.25.0",
4
+ "version": "4.26.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",