@bitgo/wasm-utxo 4.25.0 → 4.27.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;
@@ -0,0 +1,45 @@
1
+ import { ZcashV6Transaction as WasmZcashV6Transaction } from "../wasm/wasm_utxo.js";
2
+ /**
3
+ * A parsed Zcash v6 (Ironwood / NU6.3) transaction — for inspection and txid.
4
+ *
5
+ * The transaction id is an instance method ({@link getId}) returning the canonical
6
+ * display-order hex, consistent with the `getId()` convention on the other
7
+ * transaction/PSBT wrappers. Callers never pass raw bytes to a txid function or have
8
+ * to reverse internal byte order themselves.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const tx = ZcashV6Transaction.fromBytes(rawV6Bytes);
13
+ * tx.getId(); // canonical (display-order) txid hex
14
+ * tx.ironwoodActionCount; // 0 when the Ironwood slot is empty
15
+ * ```
16
+ */
17
+ export declare class ZcashV6Transaction {
18
+ private _wasm;
19
+ private constructor();
20
+ /**
21
+ * Decode a v6 transaction from raw wire bytes.
22
+ * @throws If the bytes are not a valid v6 (Ironwood) transaction
23
+ */
24
+ static fromBytes(bytes: Uint8Array): ZcashV6Transaction;
25
+ /** Serialize back to raw v6 wire bytes. */
26
+ toBytes(): Uint8Array;
27
+ /** The canonical (display-order) ZIP-244 txid as a lowercase hex string. */
28
+ getId(): string;
29
+ /** The ZIP-244 txid in internal (non-reversed) byte order. */
30
+ txidBytes(): Uint8Array;
31
+ /** Consensus branch id carried in the v6 header. */
32
+ get consensusBranchId(): number;
33
+ /** Expiry height. */
34
+ get expiryHeight(): number;
35
+ /** Number of Ironwood actions (0 when the Ironwood slot is empty). */
36
+ get ironwoodActionCount(): number;
37
+ /** Net value crossing the Ironwood pool boundary (0 when there is no bundle). */
38
+ get ironwoodValueBalance(): bigint;
39
+ /** The Ironwood bundle flag byte, or `undefined` when there is no bundle. */
40
+ get ironwoodFlags(): number | undefined;
41
+ /** The Ironwood note-commitment tree anchor (32 bytes), or `undefined`. */
42
+ get ironwoodAnchor(): Uint8Array | undefined;
43
+ /** @internal */
44
+ get wasm(): WasmZcashV6Transaction;
45
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZcashV6Transaction = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ /**
6
+ * A parsed Zcash v6 (Ironwood / NU6.3) transaction — for inspection and txid.
7
+ *
8
+ * The transaction id is an instance method ({@link getId}) returning the canonical
9
+ * display-order hex, consistent with the `getId()` convention on the other
10
+ * transaction/PSBT wrappers. Callers never pass raw bytes to a txid function or have
11
+ * to reverse internal byte order themselves.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const tx = ZcashV6Transaction.fromBytes(rawV6Bytes);
16
+ * tx.getId(); // canonical (display-order) txid hex
17
+ * tx.ironwoodActionCount; // 0 when the Ironwood slot is empty
18
+ * ```
19
+ */
20
+ class ZcashV6Transaction {
21
+ _wasm;
22
+ constructor(_wasm) {
23
+ this._wasm = _wasm;
24
+ }
25
+ /**
26
+ * Decode a v6 transaction from raw wire bytes.
27
+ * @throws If the bytes are not a valid v6 (Ironwood) transaction
28
+ */
29
+ static fromBytes(bytes) {
30
+ return new ZcashV6Transaction(wasm_utxo_js_1.ZcashV6Transaction.fromBytes(bytes));
31
+ }
32
+ /** Serialize back to raw v6 wire bytes. */
33
+ toBytes() {
34
+ return this._wasm.toBytes();
35
+ }
36
+ /** The canonical (display-order) ZIP-244 txid as a lowercase hex string. */
37
+ getId() {
38
+ return this._wasm.getId();
39
+ }
40
+ /** The ZIP-244 txid in internal (non-reversed) byte order. */
41
+ txidBytes() {
42
+ return this._wasm.txidBytes();
43
+ }
44
+ /** Consensus branch id carried in the v6 header. */
45
+ get consensusBranchId() {
46
+ return this._wasm.consensusBranchId;
47
+ }
48
+ /** Expiry height. */
49
+ get expiryHeight() {
50
+ return this._wasm.expiryHeight;
51
+ }
52
+ /** Number of Ironwood actions (0 when the Ironwood slot is empty). */
53
+ get ironwoodActionCount() {
54
+ return this._wasm.ironwoodActionCount;
55
+ }
56
+ /** Net value crossing the Ironwood pool boundary (0 when there is no bundle). */
57
+ get ironwoodValueBalance() {
58
+ return this._wasm.ironwoodValueBalance;
59
+ }
60
+ /** The Ironwood bundle flag byte, or `undefined` when there is no bundle. */
61
+ get ironwoodFlags() {
62
+ return this._wasm.ironwoodFlags;
63
+ }
64
+ /** The Ironwood note-commitment tree anchor (32 bytes), or `undefined`. */
65
+ get ironwoodAnchor() {
66
+ return this._wasm.ironwoodAnchor;
67
+ }
68
+ /** @internal */
69
+ get wasm() {
70
+ return this._wasm;
71
+ }
72
+ }
73
+ exports.ZcashV6Transaction = ZcashV6Transaction;
@@ -9,6 +9,8 @@ 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";
13
+ export { ZcashV6Transaction } from "./ZcashV6Transaction.js";
12
14
  import type { ScriptType } from "./scriptType.js";
13
15
  /**
14
16
  * 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.ZcashV6Transaction = 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,12 @@ 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; } });
39
+ // Zcash v6 (Ironwood / NU6.3) transaction
40
+ var ZcashV6Transaction_js_1 = require("./ZcashV6Transaction.js");
41
+ Object.defineProperty(exports, "ZcashV6Transaction", { enumerable: true, get: function () { return ZcashV6Transaction_js_1.ZcashV6Transaction; } });
36
42
  /**
37
43
  * Check if a network supports a given fixed-script wallet script type
38
44
  *
@@ -1584,6 +1584,101 @@ 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
+
1624
+ /**
1625
+ * A parsed Zcash v6 (Ironwood / NU6.3) transaction — for inspection and txid.
1626
+ *
1627
+ * This wraps the raw v6 wire codec. The transaction id is exposed as an instance
1628
+ * method [`ZcashV6Transaction::get_id`] (canonical display-order hex), matching the
1629
+ * `getId()` convention used by the other transaction/PSBT wrappers, so callers never
1630
+ * pass raw bytes to a txid function or juggle internal vs display byte order.
1631
+ */
1632
+ export class ZcashV6Transaction {
1633
+ private constructor();
1634
+ free(): void;
1635
+ [Symbol.dispose](): void;
1636
+ /**
1637
+ * Decode a v6 transaction from raw wire bytes. Throws if the bytes are not a
1638
+ * valid v6 (Ironwood) transaction.
1639
+ */
1640
+ static fromBytes(bytes: Uint8Array): ZcashV6Transaction;
1641
+ /**
1642
+ * The canonical (display-order) ZIP-244 txid as a lowercase hex string.
1643
+ *
1644
+ * `Txid`'s `Display` emits display-order (byte-reversed) hex, matching how a
1645
+ * transaction id is printed everywhere else in the codebase.
1646
+ */
1647
+ getId(): string;
1648
+ /**
1649
+ * Serialize back to raw v6 wire bytes.
1650
+ */
1651
+ toBytes(): Uint8Array;
1652
+ /**
1653
+ * The ZIP-244 txid in internal (non-reversed) byte order.
1654
+ */
1655
+ txidBytes(): Uint8Array;
1656
+ /**
1657
+ * Consensus branch id carried in the v6 header.
1658
+ */
1659
+ readonly consensusBranchId: number;
1660
+ /**
1661
+ * Expiry height.
1662
+ */
1663
+ readonly expiryHeight: number;
1664
+ /**
1665
+ * Number of Ironwood actions (0 when the Ironwood slot is empty).
1666
+ */
1667
+ readonly ironwoodActionCount: number;
1668
+ /**
1669
+ * The Ironwood note-commitment tree anchor (32 bytes), or `undefined`.
1670
+ */
1671
+ readonly ironwoodAnchor: Uint8Array | undefined;
1672
+ /**
1673
+ * The Ironwood bundle flag byte, or `undefined` when there is no bundle.
1674
+ */
1675
+ readonly ironwoodFlags: number | undefined;
1676
+ /**
1677
+ * Net value crossing the Ironwood pool boundary (0 when there is no bundle).
1678
+ */
1679
+ readonly ironwoodValueBalance: bigint;
1680
+ }
1681
+
1587
1682
  /**
1588
1683
  * Check if the inspect feature is enabled.
1589
1684
  *
@@ -1661,5 +1756,8 @@ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
1661
1756
  * `network`: "zcash" / "zec" for mainnet, "zcashTest" / "tzec" for testnet.
1662
1757
  * Returns `None` if `height` is before Overwinter activation.
1663
1758
  * Throws if `network` is not a recognised Zcash network name.
1759
+ *
1760
+ * Errors are thrown as the crate-standard [`WasmUtxoError`] (a marked `js_sys::Error`
1761
+ * with `.message` and `.code`), not a bare string.
1664
1762
  */
1665
1763
  export function zcash_branch_id_for_height(network: string, height: number): number | undefined;