@bitgo/wasm-utxo 4.40.0 → 5.0.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/fixedScriptWallet/Dimensions.d.ts +5 -16
  4. package/dist/cjs/js/fixedScriptWallet/Dimensions.js +2 -2
  5. package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
  6. package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.js +30 -0
  7. package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodWitness.d.ts +31 -0
  8. package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodWitness.js +45 -0
  9. package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
  10. package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
  11. package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -0
  12. package/dist/cjs/js/fixedScriptWallet/index.js +4 -1
  13. package/dist/cjs/js/index.d.ts +2 -0
  14. package/dist/cjs/js/index.js +4 -1
  15. package/dist/cjs/js/wasm/wasm_utxo.d.ts +87 -5
  16. package/dist/cjs/js/wasm/wasm_utxo.js +232 -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 +72 -62
  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/fixedScriptWallet/Dimensions.d.ts +5 -16
  24. package/dist/esm/js/fixedScriptWallet/Dimensions.js +2 -2
  25. package/dist/esm/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
  26. package/dist/esm/js/fixedScriptWallet/ZcashDimensions.js +26 -0
  27. package/dist/esm/js/fixedScriptWallet/ZcashIronwoodWitness.d.ts +31 -0
  28. package/dist/esm/js/fixedScriptWallet/ZcashIronwoodWitness.js +41 -0
  29. package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
  30. package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
  31. package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -0
  32. package/dist/esm/js/fixedScriptWallet/index.js +2 -0
  33. package/dist/esm/js/index.d.ts +2 -0
  34. package/dist/esm/js/index.js +2 -0
  35. package/dist/esm/js/wasm/wasm_utxo.d.ts +87 -5
  36. package/dist/esm/js/wasm/wasm_utxo.js +1 -1
  37. package/dist/esm/js/wasm/wasm_utxo_bg.js +226 -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 +72 -62
  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
@@ -5,12 +5,8 @@ import type { CoinName } from "./coinName.js";
5
5
  */
6
6
  export type AddressFormat = "default" | "cashaddr";
7
7
  /**
8
- * @param canBeShieldedOutput - When set and `address` is a ZIP-316 unified address carrying an
9
- * Orchard/Ironwood receiver, returns that raw 43-byte receiver instead of a transparent
10
- * scriptPubKey (there is no scriptPubKey for a shielded output). `address` is only even
11
- * attempted as a unified address when this is set. If `address` looks like a unified address for
12
- * this coin's network but is malformed, or has no Orchard/Ironwood receiver (e.g. Sapling-only),
13
- * this throws rather than falling back to the transparent path.
8
+ * Convert `address` to its scriptPubKey bytes for `coin`, decoding it as an ordinary transparent
9
+ * address.
14
10
  */
15
- export declare function toOutputScriptWithCoin(address: string, coin: CoinName, canBeShieldedOutput?: boolean): Uint8Array;
11
+ export declare function toOutputScriptWithCoin(address: string, coin: CoinName): Uint8Array;
16
12
  export declare function fromOutputScriptWithCoin(script: Uint8Array, coin: CoinName, format?: AddressFormat): string;
@@ -4,15 +4,11 @@ exports.toOutputScriptWithCoin = toOutputScriptWithCoin;
4
4
  exports.fromOutputScriptWithCoin = fromOutputScriptWithCoin;
5
5
  const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
6
6
  /**
7
- * @param canBeShieldedOutput - When set and `address` is a ZIP-316 unified address carrying an
8
- * Orchard/Ironwood receiver, returns that raw 43-byte receiver instead of a transparent
9
- * scriptPubKey (there is no scriptPubKey for a shielded output). `address` is only even
10
- * attempted as a unified address when this is set. If `address` looks like a unified address for
11
- * this coin's network but is malformed, or has no Orchard/Ironwood receiver (e.g. Sapling-only),
12
- * this throws rather than falling back to the transparent path.
7
+ * Convert `address` to its scriptPubKey bytes for `coin`, decoding it as an ordinary transparent
8
+ * address.
13
9
  */
14
- function toOutputScriptWithCoin(address, coin, canBeShieldedOutput) {
15
- return wasm_utxo_js_1.AddressNamespace.to_output_script_with_coin(address, coin, canBeShieldedOutput);
10
+ function toOutputScriptWithCoin(address, coin) {
11
+ return wasm_utxo_js_1.AddressNamespace.to_output_script_with_coin(address, coin);
16
12
  }
17
13
  function fromOutputScriptWithCoin(script, coin, format) {
18
14
  return wasm_utxo_js_1.AddressNamespace.from_output_script_with_coin(script, coin, format);
@@ -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
  */
@@ -45,12 +45,12 @@ class Dimensions {
45
45
  }
46
46
  return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
47
47
  }
48
- static fromOutput(params, network, options) {
48
+ static fromOutput(params, network) {
49
49
  if (typeof params === "string") {
50
50
  if (network === undefined) {
51
51
  throw new Error("network is required when passing an address string");
52
52
  }
53
- const script = (0, address_js_1.toOutputScriptWithCoin)(params, network, options?.isShielded);
53
+ const script = (0, address_js_1.toOutputScriptWithCoin)(params, network);
54
54
  return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(script.length));
55
55
  }
56
56
  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,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZcashDimensions = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ const zcashAddress_js_1 = require("../zcashAddress.js");
6
+ const Dimensions_js_1 = require("./Dimensions.js");
7
+ /**
8
+ * Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
9
+ * shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
10
+ * does for every other coin.
11
+ */
12
+ class ZcashDimensions extends Dimensions_js_1.Dimensions {
13
+ static fromOutput(params, network, options) {
14
+ if (typeof params === "string") {
15
+ if (network === undefined) {
16
+ throw new Error("network is required when passing an address string");
17
+ }
18
+ const receiver = options?.isShielded
19
+ ? (0, zcashAddress_js_1.toShieldedReceiverWithCoin)(params, network)
20
+ : (0, zcashAddress_js_1.toTransparentReceiverWithCoin)(params, network);
21
+ return new ZcashDimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(receiver.length));
22
+ }
23
+ if (typeof params === "object" && "scriptType" in params) {
24
+ return Dimensions_js_1.Dimensions.fromOutput(params);
25
+ }
26
+ // Both Uint8Array and { length: number } have .length
27
+ return Dimensions_js_1.Dimensions.fromOutput(params);
28
+ }
29
+ }
30
+ exports.ZcashDimensions = ZcashDimensions;
@@ -0,0 +1,31 @@
1
+ import { IronwoodWitness as WasmIronwoodWitness } from "../wasm/wasm_utxo.js";
2
+ /**
3
+ * A validated Merkle witness for an Ironwood/Orchard note commitment.
4
+ *
5
+ * Build with {@link ZcashIronwoodWitness.build}: `cmx` is the note commitment being
6
+ * witnessed, `authPath` must be exactly 32 sibling hashes (32 bytes each, leaf-to-root
7
+ * order), and `anchor` is the expected note-commitment-tree root. Throws if any input
8
+ * isn't a canonical field element, or if the witness doesn't recompute to `anchor`.
9
+ *
10
+ * wasm-utxo has no chain state, so the raw sibling-hash path must be supplied by the
11
+ * caller (typically BitGo's backend, querying a Zcash-aware service).
12
+ */
13
+ export declare class ZcashIronwoodWitness {
14
+ private _wasm;
15
+ private constructor();
16
+ /**
17
+ * Build and validate a Merkle witness for an Ironwood/Orchard note commitment.
18
+ * @throws If any input isn't a canonical field element, or the witness doesn't
19
+ * recompute to `anchor`
20
+ */
21
+ static build(cmx: Uint8Array, position: number, authPath: Uint8Array[], anchor: Uint8Array): ZcashIronwoodWitness;
22
+ /** The leaf's position in the note commitment tree. */
23
+ get position(): number;
24
+ /**
25
+ * The 32 sibling hashes (leaf-to-root order), flattened into a single 1024-byte array
26
+ * (32 hashes × 32 bytes each).
27
+ */
28
+ get authPath(): Uint8Array;
29
+ /** @internal */
30
+ get wasm(): WasmIronwoodWitness;
31
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZcashIronwoodWitness = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ /**
6
+ * A validated Merkle witness for an Ironwood/Orchard note commitment.
7
+ *
8
+ * Build with {@link ZcashIronwoodWitness.build}: `cmx` is the note commitment being
9
+ * witnessed, `authPath` must be exactly 32 sibling hashes (32 bytes each, leaf-to-root
10
+ * order), and `anchor` is the expected note-commitment-tree root. Throws if any input
11
+ * isn't a canonical field element, or if the witness doesn't recompute to `anchor`.
12
+ *
13
+ * wasm-utxo has no chain state, so the raw sibling-hash path must be supplied by the
14
+ * caller (typically BitGo's backend, querying a Zcash-aware service).
15
+ */
16
+ class ZcashIronwoodWitness {
17
+ _wasm;
18
+ constructor(_wasm) {
19
+ this._wasm = _wasm;
20
+ }
21
+ /**
22
+ * Build and validate a Merkle witness for an Ironwood/Orchard note commitment.
23
+ * @throws If any input isn't a canonical field element, or the witness doesn't
24
+ * recompute to `anchor`
25
+ */
26
+ static build(cmx, position, authPath, anchor) {
27
+ return new ZcashIronwoodWitness((0, wasm_utxo_js_1.ironwood_build_witness)(cmx, position, authPath, anchor));
28
+ }
29
+ /** The leaf's position in the note commitment tree. */
30
+ get position() {
31
+ return this._wasm.position;
32
+ }
33
+ /**
34
+ * The 32 sibling hashes (leaf-to-root order), flattened into a single 1024-byte array
35
+ * (32 hashes × 32 bytes each).
36
+ */
37
+ get authPath() {
38
+ return this._wasm.auth_path;
39
+ }
40
+ /** @internal */
41
+ get wasm() {
42
+ return this._wasm;
43
+ }
44
+ }
45
+ exports.ZcashIronwoodWitness = ZcashIronwoodWitness;
@@ -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
  *
@@ -17,6 +17,8 @@ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
17
17
  * const ua = ZcashUnifiedAddress.parse(uaString, "zec");
18
18
  * const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
19
19
  * const script = ua.transparentScript; // scriptPubKey bytes, or undefined
20
+ * ua.hasOrchardReceiver; // true iff orchardReceiver is present
21
+ * ua.hasTransparentReceiver; // true iff transparentScript is present
20
22
  * ua.contains(transparentAddress); // is it one of this UA's receivers?
21
23
  * ```
22
24
  */
@@ -55,6 +57,24 @@ class ZcashUnifiedAddress {
55
57
  get transparentScript() {
56
58
  return this._wasm.transparentScript;
57
59
  }
60
+ /**
61
+ * Whether this Unified Address carries an Orchard/Ironwood receiver.
62
+ *
63
+ * Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
64
+ * matters, since it avoids copying the receiver bytes.
65
+ */
66
+ get hasOrchardReceiver() {
67
+ return this._wasm.hasOrchardReceiver;
68
+ }
69
+ /**
70
+ * Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
71
+ *
72
+ * Equivalent to `transparentScript !== undefined`; prefer this when only presence
73
+ * matters, since it avoids copying the script bytes.
74
+ */
75
+ get hasTransparentReceiver() {
76
+ return this._wasm.hasTransparentReceiver;
77
+ }
58
78
  /**
59
79
  * Whether `candidate` is a receiver of this unified address.
60
80
  *
@@ -12,6 +12,7 @@ export { ZcashBitGoPsbt, type ZcashNetworkName, type ZcashParsedOutput, type Cre
12
12
  export { ZcashIronwoodBitGoPsbt, zip302NoMemo, type CreateEmptyIronwoodOptions, type CreateEmptyIronwoodWithConsensusBranchIdOptions, } from "./ZcashIronwoodBitGoPsbt.js";
13
13
  export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
14
14
  export { ZcashV6Transaction } from "./ZcashV6Transaction.js";
15
+ export { ZcashIronwoodWitness } from "./ZcashIronwoodWitness.js";
15
16
  import type { ScriptType } from "./scriptType.js";
16
17
  /**
17
18
  * 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.ZcashV6Transaction = exports.ZcashUnifiedAddress = exports.zip302NoMemo = exports.ZcashIronwoodBitGoPsbt = exports.IRONWOOD_VERSION_GROUP_ID = 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.ZcashIronwoodWitness = exports.ZcashV6Transaction = exports.ZcashUnifiedAddress = exports.zip302NoMemo = exports.ZcashIronwoodBitGoPsbt = exports.IRONWOOD_VERSION_GROUP_ID = 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;
@@ -44,6 +44,9 @@ Object.defineProperty(exports, "ZcashUnifiedAddress", { enumerable: true, get: f
44
44
  // Zcash v6 (Ironwood / NU6.3) transaction
45
45
  var ZcashV6Transaction_js_1 = require("./ZcashV6Transaction.js");
46
46
  Object.defineProperty(exports, "ZcashV6Transaction", { enumerable: true, get: function () { return ZcashV6Transaction_js_1.ZcashV6Transaction; } });
47
+ // Zcash v6 (Ironwood / NU6.3) Merkle witness
48
+ var ZcashIronwoodWitness_js_1 = require("./ZcashIronwoodWitness.js");
49
+ Object.defineProperty(exports, "ZcashIronwoodWitness", { enumerable: true, get: function () { return ZcashIronwoodWitness_js_1.ZcashIronwoodWitness; } });
47
50
  /**
48
51
  * Check if a network supports a given fixed-script wallet script type
49
52
  *
@@ -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;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.requiresPrevTxForP2sh = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.descriptorWallet = exports.fixedScriptWallet = exports.utxolibCompat = exports.message = exports.inscriptions = exports.bip322 = exports.ast = exports.address = void 0;
36
+ exports.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.requiresPrevTxForP2sh = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.ZcashDimensions = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.descriptorWallet = exports.fixedScriptWallet = exports.utxolibCompat = exports.message = exports.inscriptions = exports.bip322 = exports.ast = exports.zcashAddress = exports.address = void 0;
37
37
  exports.getWasmUtxoVersion = getWasmUtxoVersion;
38
38
  exports.isWasmUtxoError = isWasmUtxoError;
39
39
  const wasm = __importStar(require("./wasm/wasm_utxo.js"));
@@ -44,6 +44,7 @@ void wasm;
44
44
  // Most exports are namespaced to avoid polluting the top-level namespace
45
45
  // and to make imports more explicit (e.g., `import { address } from '@bitgo/wasm-utxo'`)
46
46
  exports.address = __importStar(require("./address.js"));
47
+ exports.zcashAddress = __importStar(require("./zcashAddress.js"));
47
48
  exports.ast = __importStar(require("./ast/index.js"));
48
49
  exports.bip322 = __importStar(require("./bip322/index.js"));
49
50
  exports.inscriptions = __importStar(require("./inscriptions.js"));
@@ -60,6 +61,8 @@ var bip32_js_1 = require("./bip32.js");
60
61
  Object.defineProperty(exports, "BIP32", { enumerable: true, get: function () { return bip32_js_1.BIP32; } });
61
62
  var Dimensions_js_1 = require("./fixedScriptWallet/Dimensions.js");
62
63
  Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
64
+ var ZcashDimensions_js_1 = require("./fixedScriptWallet/ZcashDimensions.js");
65
+ Object.defineProperty(exports, "ZcashDimensions", { enumerable: true, get: function () { return ZcashDimensions_js_1.ZcashDimensions; } });
63
66
  function getWasmUtxoVersion() {
64
67
  return wasm_utxo_js_1.WasmUtxoNamespace.get_wasm_utxo_version();
65
68
  }
@@ -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
  /**
@@ -984,6 +981,27 @@ export class InscriptionsNamespace {
984
981
  static sign_reveal_transaction(private_key: Uint8Array, tap_leaf_script: any, commit_tx: WasmTransaction, commit_output_script: Uint8Array, recipient_output_script: Uint8Array, output_value_sats: bigint): Uint8Array;
985
982
  }
986
983
 
984
+ /**
985
+ * A validated Merkle witness for an Ironwood/Orchard note commitment, from
986
+ * [`ironwood_build_witness`].
987
+ *
988
+ * Not yet installed anywhere — see [`ironwood_build_witness`]'s docs.
989
+ */
990
+ export class IronwoodWitness {
991
+ private constructor();
992
+ free(): void;
993
+ [Symbol.dispose](): void;
994
+ /**
995
+ * The 32 sibling hashes (leaf-to-root order), flattened into a single 1024-byte array
996
+ * (32 hashes × 32 bytes each).
997
+ */
998
+ readonly auth_path: Uint8Array;
999
+ /**
1000
+ * The leaf's position in the note commitment tree.
1001
+ */
1002
+ readonly position: number;
1003
+ }
1004
+
987
1005
  export class MessageNamespace {
988
1006
  private constructor();
989
1007
  free(): void;
@@ -1777,6 +1795,20 @@ export class ZcashUnifiedAddress {
1777
1795
  * below are infallible. Throws if the address is malformed or on the wrong network.
1778
1796
  */
1779
1797
  static parse(address: string, network: string): ZcashUnifiedAddress;
1798
+ /**
1799
+ * Whether this Unified Address carries an Orchard/Ironwood receiver.
1800
+ *
1801
+ * Equivalent to `orchardReceiver !== undefined`, without cloning the receiver bytes
1802
+ * when the caller only needs presence.
1803
+ */
1804
+ readonly hasOrchardReceiver: boolean;
1805
+ /**
1806
+ * Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
1807
+ *
1808
+ * Equivalent to `transparentScript !== undefined`, without cloning the script bytes
1809
+ * when the caller only needs presence.
1810
+ */
1811
+ readonly hasTransparentReceiver: boolean;
1780
1812
  /**
1781
1813
  * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
1782
1814
  */
@@ -1861,6 +1893,19 @@ export class ZcashV6Transaction {
1861
1893
  readonly ironwoodValueBalance: bigint;
1862
1894
  }
1863
1895
 
1896
+ /**
1897
+ * Build and validate a Merkle witness for an Ironwood/Orchard note commitment.
1898
+ *
1899
+ * `cmx` is the note commitment being witnessed; `auth_path` must be exactly 32 sibling hashes (32
1900
+ * bytes each), leaf-to-root order; `anchor` is the expected note-commitment-tree root. Throws if
1901
+ * any input isn't a canonical field element, or if the witness doesn't recompute to `anchor`.
1902
+ *
1903
+ * This crate has no chain state, so the raw sibling-hash path must be supplied by the caller
1904
+ * (typically BitGo's backend, querying a Zcash-aware service). The returned witness is not yet
1905
+ * installed anywhere — hook it into a spend once real-spend construction exists.
1906
+ */
1907
+ export function ironwood_build_witness(cmx: Uint8Array, position: number, auth_path: Uint8Array[], anchor: Uint8Array): IronwoodWitness;
1908
+
1864
1909
  /**
1865
1910
  * Check if the inspect feature is enabled.
1866
1911
  *
@@ -1932,6 +1977,43 @@ export function parsePsbtToJson(psbt_bytes: Uint8Array, coin_name: string): stri
1932
1977
  */
1933
1978
  export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
1934
1979
 
1980
+ /**
1981
+ * Whether `address` is a ZIP-316 unified address for `coin`'s network carrying an
1982
+ * Orchard/Ironwood receiver. `false` (never throws) for a malformed/wrong-network unified
1983
+ * address, an ordinary address, or a UA with no Orchard/Ironwood receiver.
1984
+ */
1985
+ export function zcashHasOrchardReceiver(address: string, coin: string): boolean;
1986
+
1987
+ /**
1988
+ * Whether `address` has a usable transparent receiver for `coin`'s network: either it's a
1989
+ * unified address carrying a transparent receiver, or it's itself a valid transparent address
1990
+ * for `coin`. `false` (never throws) otherwise.
1991
+ */
1992
+ export function zcashHasTransparentReceiver(address: string, coin: string): boolean;
1993
+
1994
+ export function zcashToShieldedReceiverWithCoin(address: string, coin: string): Uint8Array;
1995
+
1996
+ /**
1997
+ * Resolve the Orchard/Ironwood receiver of a ZIP-316 unified address for `coin`'s network, as
1998
+ * its raw 43 bytes (diversifier + `pk_d`) — there is no scriptPubKey for a shielded output, so
1999
+ * this can't return script bytes uniformly and returns raw receiver bytes instead.
2000
+ *
2001
+ * A UA that has no Orchard/Ironwood receiver (e.g. Sapling-only) throws rather than falling back
2002
+ * to the transparent receiver. If `address` merely looks like a unified address for this coin's
2003
+ * network (right Bech32m HRP) but is malformed, this also throws. `address` must be a unified
2004
+ * address — an ordinary transparent address is rejected, since it can never carry a shielded
2005
+ * receiver; use {@link toOutputScriptWithCoin} in `js/address.ts` for the transparent case.
2006
+ * Resolve the transparent receiver of an `address` for `coin`'s network, as its scriptPubKey
2007
+ * bytes. When `address` is a ZIP-316 unified address, resolves its transparent receiver rather
2008
+ * than rejecting the UA string outright — a UA with no transparent receiver (e.g. Orchard-only)
2009
+ * throws rather than falling back to a shielded one. An ordinary (non-UA) address falls through
2010
+ * to the same transparent codec path as any other coin.
2011
+ *
2012
+ * This is the zcash-aware counterpart of `toOutputScriptWithCoin` in `js/address.ts`, which
2013
+ * dispatches here for zcash/tzec so that non-zcash coins never pay for a unified-address check.
2014
+ */
2015
+ export function zcashToTransparentReceiverWithCoin(address: string, coin: string): Uint8Array;
2016
+
1935
2017
  /**
1936
2018
  * Return the Zcash consensus branch ID active at `height` on `network`.
1937
2019
  *