@bitgo/wasm-utxo 4.41.0 → 5.1.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.
Files changed (42) hide show
  1. package/dist/cjs/js/address.d.ts +3 -7
  2. package/dist/cjs/js/address.js +4 -8
  3. package/dist/cjs/js/descriptorWallet/psbt/findDescriptors.js +16 -12
  4. package/dist/cjs/js/fixedScriptWallet/Dimensions.d.ts +5 -16
  5. package/dist/cjs/js/fixedScriptWallet/Dimensions.js +2 -2
  6. package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
  7. package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.js +30 -0
  8. package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
  9. package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
  10. package/dist/cjs/js/index.d.ts +18 -0
  11. package/dist/cjs/js/index.js +4 -1
  12. package/dist/cjs/js/psbt.d.ts +2 -1
  13. package/dist/cjs/js/psbtBase.d.ts +3 -1
  14. package/dist/cjs/js/psbtBase.js +3 -0
  15. package/dist/cjs/js/wasm/wasm_utxo.d.ts +55 -5
  16. package/dist/cjs/js/wasm/wasm_utxo.js +174 -7
  17. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  18. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +93 -85
  19. package/dist/cjs/js/zcashAddress.d.ts +44 -0
  20. package/dist/cjs/js/zcashAddress.js +58 -0
  21. package/dist/esm/js/address.d.ts +3 -7
  22. package/dist/esm/js/address.js +4 -8
  23. package/dist/esm/js/descriptorWallet/psbt/findDescriptors.js +16 -12
  24. package/dist/esm/js/fixedScriptWallet/Dimensions.d.ts +5 -16
  25. package/dist/esm/js/fixedScriptWallet/Dimensions.js +2 -2
  26. package/dist/esm/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
  27. package/dist/esm/js/fixedScriptWallet/ZcashDimensions.js +26 -0
  28. package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
  29. package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
  30. package/dist/esm/js/index.d.ts +18 -0
  31. package/dist/esm/js/index.js +2 -0
  32. package/dist/esm/js/psbt.d.ts +2 -1
  33. package/dist/esm/js/psbtBase.d.ts +3 -1
  34. package/dist/esm/js/psbtBase.js +3 -0
  35. package/dist/esm/js/wasm/wasm_utxo.d.ts +55 -5
  36. package/dist/esm/js/wasm/wasm_utxo.js +1 -1
  37. package/dist/esm/js/wasm/wasm_utxo_bg.js +170 -7
  38. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  39. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +93 -85
  40. package/dist/esm/js/zcashAddress.d.ts +44 -0
  41. package/dist/esm/js/zcashAddress.js +52 -0
  42. package/package.json +1 -1
@@ -44,11 +44,11 @@ function findDescriptorForDerivationIndex(script, index, descriptorMap) {
44
44
  function getDerivationIndexFromPath(path) {
45
45
  const indexStr = path.split("/").pop();
46
46
  if (!indexStr) {
47
- throw new Error(`Invalid derivation path ${path}`);
47
+ return undefined;
48
48
  }
49
- const index = parseInt(indexStr, 10);
50
- if (index.toString() !== indexStr) {
51
- throw new Error(`Invalid derivation path ${path}`);
49
+ const index = Number(indexStr);
50
+ if (!Number.isSafeInteger(index) || index < 0 || index.toString() !== indexStr) {
51
+ return undefined;
52
52
  }
53
53
  return index;
54
54
  }
@@ -59,7 +59,13 @@ function getDerivationIndexFromPath(path) {
59
59
  * @param descriptorMap
60
60
  */
61
61
  function findDescriptorForAnyDerivationPath(script, derivationPaths, descriptorMap) {
62
- const derivationIndexSet = new Set(derivationPaths.map((p) => getDerivationIndexFromPath(p)));
62
+ const derivationIndexSet = new Set();
63
+ for (const path of derivationPaths) {
64
+ const index = getDerivationIndexFromPath(path);
65
+ if (index !== undefined) {
66
+ derivationIndexSet.add(index);
67
+ }
68
+ }
63
69
  for (const index of [...derivationIndexSet]) {
64
70
  const desc = findDescriptorForDerivationIndex(script, index, descriptorMap);
65
71
  if (desc) {
@@ -69,13 +75,11 @@ function findDescriptorForAnyDerivationPath(script, derivationPaths, descriptorM
69
75
  return undefined;
70
76
  }
71
77
  function getDerivationPaths(v) {
72
- if ("bip32Derivation" in v && v.bip32Derivation && v.bip32Derivation.length > 0) {
73
- return v.bip32Derivation.map((v) => v.path);
74
- }
75
- if ("tapBip32Derivation" in v && v.tapBip32Derivation && v.tapBip32Derivation.length > 0) {
76
- return v.tapBip32Derivation.map((v) => v.path).filter((v) => v !== "" && v !== "m");
77
- }
78
- return undefined;
78
+ const paths = [
79
+ ...(v.bip32Derivation ?? []).map((derivation) => derivation.path),
80
+ ...(v.tapBip32Derivation ?? []).map((derivation) => derivation.path),
81
+ ].filter((path) => path !== "" && path !== "m");
82
+ return paths.length > 0 ? paths : undefined;
79
83
  }
80
84
  /**
81
85
  * @param input
@@ -1,3 +1,4 @@
1
+ import { WasmDimensions } from "../wasm/wasm_utxo.js";
1
2
  import type { BitGoPsbt, InputScriptType, SignPath } from "./BitGoPsbt.js";
2
3
  import type { CoinName } from "../coinName.js";
3
4
  import type { OutputScriptType } from "./scriptType.js";
@@ -17,16 +18,6 @@ export type FromInputOptions = {
17
18
  */
18
19
  utxolibCompat?: boolean;
19
20
  };
20
- /**
21
- * Options for output dimension calculation
22
- */
23
- export type FromOutputOptions = {
24
- /**
25
- * Set when `address` may be a ZIP-316 Unified Address whose Orchard receiver should be sized
26
- * as a shielded output. Forwarded to `toOutputScriptWithCoin`'s `canBeShieldedOutput`.
27
- */
28
- isShielded?: boolean;
29
- };
30
21
  /**
31
22
  * Dimensions class for estimating transaction virtual size.
32
23
  *
@@ -37,7 +28,7 @@ export type FromOutputOptions = {
37
28
  */
38
29
  export declare class Dimensions {
39
30
  private _wasm;
40
- private constructor();
31
+ protected constructor(_wasm: WasmDimensions);
41
32
  /**
42
33
  * Create empty dimensions (zero weight)
43
34
  */
@@ -62,12 +53,10 @@ export declare class Dimensions {
62
53
  */
63
54
  static fromOutput(script: Uint8Array): Dimensions;
64
55
  /**
65
- * Create dimensions for a single output from an address.
66
- *
67
- * Pass `{ isShielded: true }` when `address` may be a ZIP-316 Unified Address whose Orchard
68
- * receiver should be sized as a shielded output
56
+ * Create dimensions for a single output from an address, decoded as an ordinary transparent
57
+ * address for `network`.
69
58
  */
70
- static fromOutput(address: string, network: CoinName, options?: FromOutputOptions): Dimensions;
59
+ static fromOutput(address: string, network: CoinName): Dimensions;
71
60
  /**
72
61
  * Create dimensions for a single output from script length only
73
62
  */
@@ -42,12 +42,12 @@ export class Dimensions {
42
42
  }
43
43
  return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
44
44
  }
45
- static fromOutput(params, network, options) {
45
+ static fromOutput(params, network) {
46
46
  if (typeof params === "string") {
47
47
  if (network === undefined) {
48
48
  throw new Error("network is required when passing an address string");
49
49
  }
50
- const script = toOutputScriptWithCoin(params, network, options?.isShielded);
50
+ const script = toOutputScriptWithCoin(params, network);
51
51
  return new Dimensions(WasmDimensions.from_output_script_length(script.length));
52
52
  }
53
53
  if (typeof params === "object" && "scriptType" in params) {
@@ -0,0 +1,45 @@
1
+ import type { CoinName } from "../coinName.js";
2
+ import type { OutputScriptType } from "./scriptType.js";
3
+ import { Dimensions } from "./Dimensions.js";
4
+ /**
5
+ * Options for {@link ZcashDimensions.fromOutput}.
6
+ */
7
+ export type ZcashFromOutputOptions = {
8
+ /**
9
+ * Set when `address` may be a ZIP-316 Unified Address whose Orchard receiver should be sized
10
+ * as a shielded output. Forwarded to `zcashAddress.toShieldedReceiverWithCoin`; when unset,
11
+ * `zcashAddress.toTransparentReceiverWithCoin` is used instead.
12
+ */
13
+ isShielded?: boolean;
14
+ };
15
+ /**
16
+ * Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
17
+ * shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
18
+ * does for every other coin.
19
+ */
20
+ export declare class ZcashDimensions extends Dimensions {
21
+ /**
22
+ * Create dimensions for a single output from script bytes
23
+ */
24
+ static fromOutput(script: Uint8Array): Dimensions;
25
+ /**
26
+ * Create dimensions for a single output from a Zcash address for `network`.
27
+ *
28
+ * Pass `{ isShielded: true }` when `address` may be a ZIP-316 Unified Address whose Orchard
29
+ * receiver should be sized as a shielded output; otherwise its transparent receiver is
30
+ * resolved (a UA with no transparent receiver throws rather than falling back to Orchard).
31
+ */
32
+ static fromOutput(address: string, network: CoinName, options?: ZcashFromOutputOptions): Dimensions;
33
+ /**
34
+ * Create dimensions for a single output from script length only
35
+ */
36
+ static fromOutput(params: {
37
+ length: number;
38
+ }): Dimensions;
39
+ /**
40
+ * Create dimensions for a single output from script type
41
+ */
42
+ static fromOutput(params: {
43
+ scriptType: OutputScriptType;
44
+ }): Dimensions;
45
+ }
@@ -0,0 +1,26 @@
1
+ import { WasmDimensions } from "../wasm/wasm_utxo.js";
2
+ import { toShieldedReceiverWithCoin, toTransparentReceiverWithCoin } from "../zcashAddress.js";
3
+ import { Dimensions } from "./Dimensions.js";
4
+ /**
5
+ * Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
6
+ * shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
7
+ * does for every other coin.
8
+ */
9
+ export class ZcashDimensions extends Dimensions {
10
+ static fromOutput(params, network, options) {
11
+ if (typeof params === "string") {
12
+ if (network === undefined) {
13
+ throw new Error("network is required when passing an address string");
14
+ }
15
+ const receiver = options?.isShielded
16
+ ? toShieldedReceiverWithCoin(params, network)
17
+ : toTransparentReceiverWithCoin(params, network);
18
+ return new ZcashDimensions(WasmDimensions.from_output_script_length(receiver.length));
19
+ }
20
+ if (typeof params === "object" && "scriptType" in params) {
21
+ return Dimensions.fromOutput(params);
22
+ }
23
+ // Both Uint8Array and { length: number } have .length
24
+ return Dimensions.fromOutput(params);
25
+ }
26
+ }
@@ -15,6 +15,8 @@ import type { ZcashNetworkName } from "./ZcashBitGoPsbt.js";
15
15
  * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
16
16
  * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
17
17
  * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
18
+ * ua.hasOrchardReceiver; // true iff orchardReceiver is present
19
+ * ua.hasTransparentReceiver; // true iff transparentScript is present
18
20
  * ua.contains(transparentAddress); // is it one of this UA's receivers?
19
21
  * ```
20
22
  */
@@ -43,6 +45,20 @@ export declare class ZcashUnifiedAddress {
43
45
  * a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
44
46
  */
45
47
  get transparentScript(): Uint8Array | undefined;
48
+ /**
49
+ * Whether this Unified Address carries an Orchard/Ironwood receiver.
50
+ *
51
+ * Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
52
+ * matters, since it avoids copying the receiver bytes.
53
+ */
54
+ get hasOrchardReceiver(): boolean;
55
+ /**
56
+ * Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
57
+ *
58
+ * Equivalent to `transparentScript !== undefined`; prefer this when only presence
59
+ * matters, since it avoids copying the script bytes.
60
+ */
61
+ get hasTransparentReceiver(): boolean;
46
62
  /**
47
63
  * Whether `candidate` is a receiver of this unified address.
48
64
  *
@@ -14,6 +14,8 @@ import { ZcashUnifiedAddress as WasmZcashUnifiedAddress } from "../wasm/wasm_utx
14
14
  * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
15
15
  * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
16
16
  * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
17
+ * ua.hasOrchardReceiver; // true iff orchardReceiver is present
18
+ * ua.hasTransparentReceiver; // true iff transparentScript is present
17
19
  * ua.contains(transparentAddress); // is it one of this UA's receivers?
18
20
  * ```
19
21
  */
@@ -52,6 +54,24 @@ export class ZcashUnifiedAddress {
52
54
  get transparentScript() {
53
55
  return this._wasm.transparentScript;
54
56
  }
57
+ /**
58
+ * Whether this Unified Address carries an Orchard/Ironwood receiver.
59
+ *
60
+ * Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
61
+ * matters, since it avoids copying the receiver bytes.
62
+ */
63
+ get hasOrchardReceiver() {
64
+ return this._wasm.hasOrchardReceiver;
65
+ }
66
+ /**
67
+ * Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
68
+ *
69
+ * Equivalent to `transparentScript !== undefined`; prefer this when only presence
70
+ * matters, since it avoids copying the script bytes.
71
+ */
72
+ get hasTransparentReceiver() {
73
+ return this._wasm.hasTransparentReceiver;
74
+ }
55
75
  /**
56
76
  * Whether `candidate` is a receiver of this unified address.
57
77
  *
@@ -1,4 +1,5 @@
1
1
  export * as address from "./address.js";
2
+ export * as zcashAddress from "./zcashAddress.js";
2
3
  export * as ast from "./ast/index.js";
3
4
  export * as bip322 from "./bip322/index.js";
4
5
  export * as inscriptions from "./inscriptions.js";
@@ -11,6 +12,7 @@ export * as ecpair from "./ecpair.js";
11
12
  export { ECPair } from "./ecpair.js";
12
13
  export { BIP32 } from "./bip32.js";
13
14
  export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
15
+ export { ZcashDimensions } from "./fixedScriptWallet/ZcashDimensions.js";
14
16
  export type WasmUtxoVersionInfo = {
15
17
  version: string;
16
18
  gitHash: string;
@@ -68,6 +70,21 @@ declare module "./wasm/wasm_utxo.js" {
68
70
  bip32Derivation: PsbtBip32Derivation[];
69
71
  tapBip32Derivation: PsbtBip32Derivation[];
70
72
  }
73
+ /** A serialized input-map record with a standard PSBT key type. */
74
+ interface PsbtKnownInputKeyValue {
75
+ type: "known";
76
+ key: string;
77
+ keyData: Uint8Array;
78
+ value: Uint8Array;
79
+ }
80
+ /** A serialized input-map record whose key type is unrecognized. */
81
+ interface PsbtUnknownInputKeyValue {
82
+ type: "unknown";
83
+ keyType: bigint;
84
+ keyData: Uint8Array;
85
+ value: Uint8Array;
86
+ }
87
+ type PsbtInputKeyValue = PsbtKnownInputKeyValue | PsbtUnknownInputKeyValue;
71
88
  /** Raw PSBT output data returned by getOutputs() */
72
89
  interface PsbtOutputData {
73
90
  script: Uint8Array;
@@ -110,3 +127,4 @@ export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
110
127
  export { Psbt } from "./descriptorWallet/Psbt.js";
111
128
  export { DashTransaction, Transaction, ZcashTransaction, type ITransaction, type ITransactionCommon, } from "./transaction.js";
112
129
  export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
130
+ export type { PsbtInputKeyValue } from "./wasm/wasm_utxo.js";
@@ -6,6 +6,7 @@ void wasm;
6
6
  // Most exports are namespaced to avoid polluting the top-level namespace
7
7
  // and to make imports more explicit (e.g., `import { address } from '@bitgo/wasm-utxo'`)
8
8
  export * as address from "./address.js";
9
+ export * as zcashAddress from "./zcashAddress.js";
9
10
  export * as ast from "./ast/index.js";
10
11
  export * as bip322 from "./bip322/index.js";
11
12
  export * as inscriptions from "./inscriptions.js";
@@ -19,6 +20,7 @@ export * as ecpair from "./ecpair.js";
19
20
  export { ECPair } from "./ecpair.js";
20
21
  export { BIP32 } from "./bip32.js";
21
22
  export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
23
+ export { ZcashDimensions } from "./fixedScriptWallet/ZcashDimensions.js";
22
24
  export function getWasmUtxoVersion() {
23
25
  return WasmUtxoNamespace.get_wasm_utxo_version();
24
26
  }
@@ -1,10 +1,11 @@
1
- import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
1
+ import type { PsbtInputData, PsbtInputKeyValue, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
2
2
  import type { BIP32 } from "./bip32.js";
3
3
  import type { ITransactionCommon } from "./transaction.js";
4
4
  import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
5
5
  /** Common interface for PSBT types */
6
6
  export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData> {
7
7
  getGlobalXpubs(): BIP32[];
8
+ getInputKeyValues(index: number): PsbtInputKeyValue[];
8
9
  unsignedTxId(): string;
9
10
  addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
10
11
  addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
@@ -1,4 +1,4 @@
1
- import type { PsbtInputData, PsbtOutputData } from "./wasm/wasm_utxo.js";
1
+ import type { PsbtInputData, PsbtInputKeyValue, PsbtOutputData } from "./wasm/wasm_utxo.js";
2
2
  import { BIP32 } from "./bip32.js";
3
3
  import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
4
4
  interface WasmPsbtBase {
@@ -9,6 +9,7 @@ interface WasmPsbtBase {
9
9
  unsigned_tx_id(): string;
10
10
  serialize(): Uint8Array;
11
11
  get_inputs(): unknown;
12
+ get_input_key_values(index: number): unknown;
12
13
  get_outputs(): unknown;
13
14
  get_global_xpubs(): unknown;
14
15
  remove_input(index: number): void;
@@ -33,6 +34,7 @@ export declare abstract class PsbtBase<W extends WasmPsbtBase> {
33
34
  unsignedTxId(): string;
34
35
  serialize(): Uint8Array;
35
36
  getInputs(): PsbtInputData[];
37
+ getInputKeyValues(index: number): PsbtInputKeyValue[];
36
38
  getOutputs(): PsbtOutputData[];
37
39
  getGlobalXpubs(): BIP32[];
38
40
  removeInput(index: number): void;
@@ -25,6 +25,9 @@ export class PsbtBase {
25
25
  getInputs() {
26
26
  return this._wasm.get_inputs();
27
27
  }
28
+ getInputKeyValues(index) {
29
+ return this._wasm.get_input_key_values(index);
30
+ }
28
31
  getOutputs() {
29
32
  return this._wasm.get_outputs();
30
33
  }
@@ -7,12 +7,9 @@ export class AddressNamespace {
7
7
  [Symbol.dispose](): void;
8
8
  static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
9
9
  /**
10
- * `can_be_shielded_output`: when set and `address` is a ZIP-316 unified address carrying an
11
- * Orchard/Ironwood receiver, returns that raw 43-byte receiver instead of a transparent
12
- * scriptPubKey. See [`to_output_script_or_shielded_receiver_with_coin`] for the exact
13
- * fallback/error rules.
10
+ * Convert `address` to its scriptPubKey bytes for `coin`.
14
11
  */
15
- static to_output_script_with_coin(address: string, coin: string, can_be_shielded_output?: boolean | null): Uint8Array;
12
+ static to_output_script_with_coin(address: string, coin: string): Uint8Array;
16
13
  }
17
14
 
18
15
  /**
@@ -491,6 +488,7 @@ export class BitGoPsbt {
491
488
  */
492
489
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
493
490
  get_global_xpubs(): any;
491
+ get_input_key_values(index: number): any;
494
492
  get_input_kv(index: number, key: any): Uint8Array | undefined;
495
493
  get_inputs(): any;
496
494
  get_kv(key: any): Uint8Array | undefined;
@@ -1661,6 +1659,7 @@ export class WrapPsbt {
1661
1659
  */
1662
1660
  finalize_mut_zcash(consensus_branch_id: number, version_group_id?: number | null, expiry_height?: number | null): void;
1663
1661
  get_global_xpubs(): any;
1662
+ get_input_key_values(index: number): any;
1664
1663
  get_input_kv(index: number, key: any): Uint8Array | undefined;
1665
1664
  get_inputs(): any;
1666
1665
  get_kv(key: any): Uint8Array | undefined;
@@ -1798,6 +1797,20 @@ export class ZcashUnifiedAddress {
1798
1797
  * below are infallible. Throws if the address is malformed or on the wrong network.
1799
1798
  */
1800
1799
  static parse(address: string, network: string): ZcashUnifiedAddress;
1800
+ /**
1801
+ * Whether this Unified Address carries an Orchard/Ironwood receiver.
1802
+ *
1803
+ * Equivalent to `orchardReceiver !== undefined`, without cloning the receiver bytes
1804
+ * when the caller only needs presence.
1805
+ */
1806
+ readonly hasOrchardReceiver: boolean;
1807
+ /**
1808
+ * Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
1809
+ *
1810
+ * Equivalent to `transparentScript !== undefined`, without cloning the script bytes
1811
+ * when the caller only needs presence.
1812
+ */
1813
+ readonly hasTransparentReceiver: boolean;
1801
1814
  /**
1802
1815
  * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
1803
1816
  */
@@ -1966,6 +1979,43 @@ export function parsePsbtToJson(psbt_bytes: Uint8Array, coin_name: string): stri
1966
1979
  */
1967
1980
  export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
1968
1981
 
1982
+ /**
1983
+ * Whether `address` is a ZIP-316 unified address for `coin`'s network carrying an
1984
+ * Orchard/Ironwood receiver. `false` (never throws) for a malformed/wrong-network unified
1985
+ * address, an ordinary address, or a UA with no Orchard/Ironwood receiver.
1986
+ */
1987
+ export function zcashHasOrchardReceiver(address: string, coin: string): boolean;
1988
+
1989
+ /**
1990
+ * Whether `address` has a usable transparent receiver for `coin`'s network: either it's a
1991
+ * unified address carrying a transparent receiver, or it's itself a valid transparent address
1992
+ * for `coin`. `false` (never throws) otherwise.
1993
+ */
1994
+ export function zcashHasTransparentReceiver(address: string, coin: string): boolean;
1995
+
1996
+ export function zcashToShieldedReceiverWithCoin(address: string, coin: string): Uint8Array;
1997
+
1998
+ /**
1999
+ * Resolve the Orchard/Ironwood receiver of a ZIP-316 unified address for `coin`'s network, as
2000
+ * its raw 43 bytes (diversifier + `pk_d`) — there is no scriptPubKey for a shielded output, so
2001
+ * this can't return script bytes uniformly and returns raw receiver bytes instead.
2002
+ *
2003
+ * A UA that has no Orchard/Ironwood receiver (e.g. Sapling-only) throws rather than falling back
2004
+ * to the transparent receiver. If `address` merely looks like a unified address for this coin's
2005
+ * network (right Bech32m HRP) but is malformed, this also throws. `address` must be a unified
2006
+ * address — an ordinary transparent address is rejected, since it can never carry a shielded
2007
+ * receiver; use {@link toOutputScriptWithCoin} in `js/address.ts` for the transparent case.
2008
+ * Resolve the transparent receiver of an `address` for `coin`'s network, as its scriptPubKey
2009
+ * bytes. When `address` is a ZIP-316 unified address, resolves its transparent receiver rather
2010
+ * than rejecting the UA string outright — a UA with no transparent receiver (e.g. Orchard-only)
2011
+ * throws rather than falling back to a shielded one. An ordinary (non-UA) address falls through
2012
+ * to the same transparent codec path as any other coin.
2013
+ *
2014
+ * This is the zcash-aware counterpart of `toOutputScriptWithCoin` in `js/address.ts`, which
2015
+ * dispatches here for zcash/tzec so that non-zcash coins never pay for a unified-address check.
2016
+ */
2017
+ export function zcashToTransparentReceiverWithCoin(address: string, coin: string): Uint8Array;
2018
+
1969
2019
  /**
1970
2020
  * Return the Zcash consensus branch ID active at `height` on `network`.
1971
2021
  *
@@ -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, IronwoodWitness, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmUtxoNamespace, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, ZcashUnifiedAddress, ZcashV6Transaction, ironwood_build_witness, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson, zcash_branch_id_for_height, zcash_ironwood_version_group_id
8
+ AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, IronwoodWitness, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmUtxoNamespace, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, ZcashUnifiedAddress, ZcashV6Transaction, ironwood_build_witness, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson, zcashHasOrchardReceiver, zcashHasTransparentReceiver, zcashToShieldedReceiverWithCoin, zcashToTransparentReceiverWithCoin, zcash_branch_id_for_height, zcash_ironwood_version_group_id
9
9
  } from "./wasm_utxo_bg.js";