@bitgo/wasm-utxo 5.3.0 → 5.5.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.
@@ -1,4 +1,20 @@
1
1
  import { IronwoodWitness as WasmIronwoodWitness } from "../wasm/wasm_utxo.js";
2
+ /**
3
+ * A node of a pruned Orchard note-commitment (sub)tree, for {@link ZcashIronwoodWitness.buildFromShard}'s
4
+ * `shard`/`cap` inputs. Mirrors a real pruned tree store's shape (e.g. a `shardtree::ShardTree`):
5
+ * most leaves are never individually retained, only enough annotated hashes to reproduce a witness.
6
+ */
7
+ export type ShardTreeNode = {
8
+ type: "Nil";
9
+ } | {
10
+ type: "Leaf";
11
+ hash: Uint8Array;
12
+ } | {
13
+ type: "Parent";
14
+ hash?: Uint8Array;
15
+ left: ShardTreeNode;
16
+ right: ShardTreeNode;
17
+ };
2
18
  /**
3
19
  * A validated Merkle witness for an Ironwood/Orchard note commitment.
4
20
  *
@@ -19,6 +35,19 @@ export declare class ZcashIronwoodWitness {
19
35
  * recompute to `anchor`
20
36
  */
21
37
  static build(cmx: Uint8Array, position: number, authPath: Uint8Array[], anchor: Uint8Array): ZcashIronwoodWitness;
38
+ /**
39
+ * Build and validate a Merkle witness from a pruned shard + cap, instead of a
40
+ * caller-precomputed 32-entry path.
41
+ *
42
+ * `shardHeight` chooses which level the shard's root sits at (it spans up to `2^shardHeight`
43
+ * leaves); `shard` is the pruned subtree containing `position`, rooted at that level; `cap` is
44
+ * the pruned tree above every shard, down to (and including) shard-root nodes. `leafCount` is
45
+ * the total number of leaves committed to the tree as of `anchor` — positions beyond it are
46
+ * treated as canonically empty.
47
+ * @throws Under the same conditions as {@link build}, plus if `shard`/`cap` don't have enough
48
+ * detail to witness `position` as of `leafCount`
49
+ */
50
+ static buildFromShard(position: number, shardHeight: number, leafCount: bigint, cmx: Uint8Array, shard: ShardTreeNode, cap: ShardTreeNode, anchor: Uint8Array): ZcashIronwoodWitness;
22
51
  /** The leaf's position in the note commitment tree. */
23
52
  get position(): number;
24
53
  /**
@@ -26,6 +26,21 @@ class ZcashIronwoodWitness {
26
26
  static build(cmx, position, authPath, anchor) {
27
27
  return new ZcashIronwoodWitness((0, wasm_utxo_js_1.ironwood_build_witness)(cmx, position, authPath, anchor));
28
28
  }
29
+ /**
30
+ * Build and validate a Merkle witness from a pruned shard + cap, instead of a
31
+ * caller-precomputed 32-entry path.
32
+ *
33
+ * `shardHeight` chooses which level the shard's root sits at (it spans up to `2^shardHeight`
34
+ * leaves); `shard` is the pruned subtree containing `position`, rooted at that level; `cap` is
35
+ * the pruned tree above every shard, down to (and including) shard-root nodes. `leafCount` is
36
+ * the total number of leaves committed to the tree as of `anchor` — positions beyond it are
37
+ * treated as canonically empty.
38
+ * @throws Under the same conditions as {@link build}, plus if `shard`/`cap` don't have enough
39
+ * detail to witness `position` as of `leafCount`
40
+ */
41
+ static buildFromShard(position, shardHeight, leafCount, cmx, shard, cap, anchor) {
42
+ return new ZcashIronwoodWitness((0, wasm_utxo_js_1.ironwood_build_witness_from_shard)(position, shardHeight, leafCount, cmx, shard, cap, anchor));
43
+ }
29
44
  /** The leaf's position in the note commitment tree. */
30
45
  get position() {
31
46
  return this._wasm.position;
@@ -1,4 +1,5 @@
1
1
  import { ZcashV6Transaction as WasmZcashV6Transaction } from "../wasm/wasm_utxo.js";
2
+ import type { TxInputData } from "../wasm/wasm_utxo.js";
2
3
  /**
3
4
  * A parsed Zcash v6 (Ironwood / NU6.3) transaction — for inspection and txid.
4
5
  *
@@ -49,6 +50,12 @@ export declare class ZcashV6Transaction {
49
50
  * scriptPubKeys for *every* transparent input of this transaction, in input order.
50
51
  */
51
52
  transparentSighash(index: number, inputAmounts: bigint[], inputScriptPubkeys: Uint8Array[]): Uint8Array;
53
+ /**
54
+ * The transparent inputs of this transaction, in input order — e.g. each input's
55
+ * `previousOutput` (display-order txid + vout) for looking up the spent UTXOs of a broadcast
56
+ * shielding transaction. Empty for a fully shielded transaction.
57
+ */
58
+ getInputs(): TxInputData[];
52
59
  /** @internal */
53
60
  get wasm(): WasmZcashV6Transaction;
54
61
  }
@@ -76,6 +76,14 @@ class ZcashV6Transaction {
76
76
  transparentSighash(index, inputAmounts, inputScriptPubkeys) {
77
77
  return this._wasm.transparentSighash(index, BigInt64Array.from(inputAmounts), inputScriptPubkeys);
78
78
  }
79
+ /**
80
+ * The transparent inputs of this transaction, in input order — e.g. each input's
81
+ * `previousOutput` (display-order txid + vout) for looking up the spent UTXOs of a broadcast
82
+ * shielding transaction. Empty for a fully shielded transaction.
83
+ */
84
+ getInputs() {
85
+ return this._wasm.getInputs();
86
+ }
79
87
  /** @internal */
80
88
  get wasm() {
81
89
  return this._wasm;
@@ -14,6 +14,7 @@ export { ZcashIronwoodBitGoPsbt, zip302NoMemo, type CreateEmptyIronwoodOptions,
14
14
  export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
15
15
  export { ZcashV6Transaction } from "./ZcashV6Transaction.js";
16
16
  export { ZcashIronwoodWitness } from "./ZcashIronwoodWitness.js";
17
+ export type { ShardTreeNode } from "./ZcashIronwoodWitness.js";
17
18
  import type { ScriptType } from "./scriptType.js";
18
19
  /**
19
20
  * Check if a network supports a given fixed-script wallet script type
@@ -1865,6 +1865,12 @@ export class ZcashV6Transaction {
1865
1865
  * transaction id is printed everywhere else in the codebase.
1866
1866
  */
1867
1867
  getId(): string;
1868
+ /**
1869
+ * The transparent inputs of this transaction, in input order — each input's
1870
+ * `previousOutput` (display-order txid + vout), sequence, scriptSig, and witness, carried
1871
+ * verbatim from the wire. Empty for a fully shielded transaction.
1872
+ */
1873
+ getInputs(): TxInputData[];
1868
1874
  /**
1869
1875
  * Serialize back to raw v6 wire bytes.
1870
1876
  */
@@ -1924,6 +1930,23 @@ export class ZcashV6Transaction {
1924
1930
  */
1925
1931
  export function ironwood_build_witness(cmx: Uint8Array, position: number, auth_path: Uint8Array[], anchor: Uint8Array): IronwoodWitness;
1926
1932
 
1933
+ /**
1934
+ * Build and validate an Ironwood witness from a pruned shard + cap, instead of a
1935
+ * caller-precomputed 32-entry path (see `ironwood_build_witness`).
1936
+ *
1937
+ * `shardHeight` chooses which level the shard's root sits at (it spans up to `2^shardHeight`
1938
+ * leaves); `shard` is the pruned subtree containing `position`, rooted at that level; `cap` is the
1939
+ * pruned tree above every shard, down to (and including) shard-root nodes. `leafCount` is the
1940
+ * total number of leaves committed to the tree as of `anchor` — positions beyond it are treated
1941
+ * as canonically empty. `shard`/`cap` are plain JS objects (not JSON strings) shaped like:
1942
+ * `{ type: "Nil" } | { type: "Leaf", hash: Uint8Array } | { type: "Parent", hash?: Uint8Array,
1943
+ * left: ShardTreeNode, right: ShardTreeNode }`.
1944
+ *
1945
+ * Throws under the same conditions as `ironwood_build_witness`, plus if `shard`/`cap` don't have
1946
+ * enough detail to witness `position` as of `leafCount`.
1947
+ */
1948
+ export function ironwood_build_witness_from_shard(position: number, shard_height: number, leaf_count: bigint, cmx: Uint8Array, shard: any, cap: any, anchor: Uint8Array): IronwoodWitness;
1949
+
1927
1950
  /**
1928
1951
  * Check if the inspect feature is enabled.
1929
1952
  *
@@ -7106,6 +7106,27 @@ class ZcashV6Transaction {
7106
7106
  wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
7107
7107
  }
7108
7108
  }
7109
+ /**
7110
+ * The transparent inputs of this transaction, in input order — each input's
7111
+ * `previousOutput` (display-order txid + vout), sequence, scriptSig, and witness, carried
7112
+ * verbatim from the wire. Empty for a fully shielded transaction.
7113
+ * @returns {TxInputData[]}
7114
+ */
7115
+ getInputs() {
7116
+ try {
7117
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
7118
+ wasm.zcashv6transaction_getInputs(retptr, this.__wbg_ptr);
7119
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
7120
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
7121
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
7122
+ if (r2) {
7123
+ throw takeObject(r1);
7124
+ }
7125
+ return takeObject(r0);
7126
+ } finally {
7127
+ wasm.__wbindgen_add_to_stack_pointer(16);
7128
+ }
7129
+ }
7109
7130
  /**
7110
7131
  * Number of Ironwood actions (0 when the Ironwood slot is empty).
7111
7132
  * @returns {number}
@@ -7269,6 +7290,50 @@ function ironwood_build_witness(cmx, position, auth_path, anchor) {
7269
7290
  }
7270
7291
  exports.ironwood_build_witness = ironwood_build_witness;
7271
7292
 
7293
+ /**
7294
+ * Build and validate an Ironwood witness from a pruned shard + cap, instead of a
7295
+ * caller-precomputed 32-entry path (see `ironwood_build_witness`).
7296
+ *
7297
+ * `shardHeight` chooses which level the shard's root sits at (it spans up to `2^shardHeight`
7298
+ * leaves); `shard` is the pruned subtree containing `position`, rooted at that level; `cap` is the
7299
+ * pruned tree above every shard, down to (and including) shard-root nodes. `leafCount` is the
7300
+ * total number of leaves committed to the tree as of `anchor` — positions beyond it are treated
7301
+ * as canonically empty. `shard`/`cap` are plain JS objects (not JSON strings) shaped like:
7302
+ * `{ type: "Nil" } | { type: "Leaf", hash: Uint8Array } | { type: "Parent", hash?: Uint8Array,
7303
+ * left: ShardTreeNode, right: ShardTreeNode }`.
7304
+ *
7305
+ * Throws under the same conditions as `ironwood_build_witness`, plus if `shard`/`cap` don't have
7306
+ * enough detail to witness `position` as of `leafCount`.
7307
+ * @param {number} position
7308
+ * @param {number} shard_height
7309
+ * @param {bigint} leaf_count
7310
+ * @param {Uint8Array} cmx
7311
+ * @param {any} shard
7312
+ * @param {any} cap
7313
+ * @param {Uint8Array} anchor
7314
+ * @returns {IronwoodWitness}
7315
+ */
7316
+ function ironwood_build_witness_from_shard(position, shard_height, leaf_count, cmx, shard, cap, anchor) {
7317
+ try {
7318
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
7319
+ const ptr0 = passArray8ToWasm0(cmx, wasm.__wbindgen_export);
7320
+ const len0 = WASM_VECTOR_LEN;
7321
+ const ptr1 = passArray8ToWasm0(anchor, wasm.__wbindgen_export);
7322
+ const len1 = WASM_VECTOR_LEN;
7323
+ wasm.ironwood_build_witness_from_shard(retptr, position, shard_height, leaf_count, ptr0, len0, addHeapObject(shard), addHeapObject(cap), ptr1, len1);
7324
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
7325
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
7326
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
7327
+ if (r2) {
7328
+ throw takeObject(r1);
7329
+ }
7330
+ return IronwoodWitness.__wrap(r0);
7331
+ } finally {
7332
+ wasm.__wbindgen_add_to_stack_pointer(16);
7333
+ }
7334
+ }
7335
+ exports.ironwood_build_witness_from_shard = ironwood_build_witness_from_shard;
7336
+
7272
7337
  /**
7273
7338
  * Check if the inspect feature is enabled.
7274
7339
  *
@@ -7602,6 +7667,13 @@ function __wbg_get_imports() {
7602
7667
  const ret = Error(getStringFromWasm0(arg0, arg1));
7603
7668
  return addHeapObject(ret);
7604
7669
  },
7670
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
7671
+ const ret = String(getObject(arg1));
7672
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7673
+ const len1 = WASM_VECTOR_LEN;
7674
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
7675
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
7676
+ },
7605
7677
  __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
7606
7678
  const v = getObject(arg1);
7607
7679
  const ret = typeof(v) === 'bigint' ? v : undefined;
@@ -7620,6 +7692,10 @@ function __wbg_get_imports() {
7620
7692
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
7621
7693
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
7622
7694
  },
7695
+ __wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
7696
+ const ret = getObject(arg0) in getObject(arg1);
7697
+ return ret;
7698
+ },
7623
7699
  __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
7624
7700
  const ret = typeof(getObject(arg0)) === 'bigint';
7625
7701
  return ret;
@@ -7649,6 +7725,10 @@ function __wbg_get_imports() {
7649
7725
  const ret = getObject(arg0) === getObject(arg1);
7650
7726
  return ret;
7651
7727
  },
7728
+ __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
7729
+ const ret = getObject(arg0) == getObject(arg1);
7730
+ return ret;
7731
+ },
7652
7732
  __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
7653
7733
  const obj = getObject(arg1);
7654
7734
  const ret = typeof(obj) === 'number' ? obj : undefined;
@@ -7678,6 +7758,14 @@ function __wbg_get_imports() {
7678
7758
  const ret = getObject(arg0).crypto;
7679
7759
  return addHeapObject(ret);
7680
7760
  },
7761
+ __wbg_done_57b39ecd9addfe81: function(arg0) {
7762
+ const ret = getObject(arg0).done;
7763
+ return ret;
7764
+ },
7765
+ __wbg_entries_58c7934c745daac7: function(arg0) {
7766
+ const ret = Object.entries(getObject(arg0));
7767
+ return addHeapObject(ret);
7768
+ },
7681
7769
  __wbg_for_c3adefd268cb6f1c: function(arg0, arg1) {
7682
7770
  const ret = Symbol.for(getStringFromWasm0(arg0, arg1));
7683
7771
  return addHeapObject(ret);
@@ -7697,6 +7785,48 @@ function __wbg_get_imports() {
7697
7785
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
7698
7786
  return addHeapObject(ret);
7699
7787
  }, arguments); },
7788
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
7789
+ let result;
7790
+ try {
7791
+ result = getObject(arg0) instanceof ArrayBuffer;
7792
+ } catch (_) {
7793
+ result = false;
7794
+ }
7795
+ const ret = result;
7796
+ return ret;
7797
+ },
7798
+ __wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
7799
+ let result;
7800
+ try {
7801
+ result = getObject(arg0) instanceof Map;
7802
+ } catch (_) {
7803
+ result = false;
7804
+ }
7805
+ const ret = result;
7806
+ return ret;
7807
+ },
7808
+ __wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
7809
+ let result;
7810
+ try {
7811
+ result = getObject(arg0) instanceof Uint8Array;
7812
+ } catch (_) {
7813
+ result = false;
7814
+ }
7815
+ const ret = result;
7816
+ return ret;
7817
+ },
7818
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
7819
+ const ret = Array.isArray(getObject(arg0));
7820
+ return ret;
7821
+ },
7822
+ __wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
7823
+ const ret = Number.isSafeInteger(getObject(arg0));
7824
+ return ret;
7825
+ },
7826
+ __wbg_iterator_6ff6560ca1568e55: function() {
7827
+ const ret = Symbol.iterator;
7828
+ return addHeapObject(ret);
7829
+ },
7700
7830
  __wbg_length_32ed9a279acd054c: function(arg0) {
7701
7831
  const ret = getObject(arg0).length;
7702
7832
  return ret;
@@ -7737,6 +7867,14 @@ function __wbg_get_imports() {
7737
7867
  const ret = new Uint8Array(arg0 >>> 0);
7738
7868
  return addHeapObject(ret);
7739
7869
  },
7870
+ __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
7871
+ const ret = getObject(arg0).next();
7872
+ return addHeapObject(ret);
7873
+ }, arguments); },
7874
+ __wbg_next_418f80d8f5303233: function(arg0) {
7875
+ const ret = getObject(arg0).next;
7876
+ return addHeapObject(ret);
7877
+ },
7740
7878
  __wbg_node_905d3e251edff8a2: function(arg0) {
7741
7879
  const ret = getObject(arg0).node;
7742
7880
  return addHeapObject(ret);
@@ -7783,6 +7921,10 @@ function __wbg_get_imports() {
7783
7921
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
7784
7922
  return addHeapObject(ret);
7785
7923
  },
7924
+ __wbg_value_0546255b415e96c1: function(arg0) {
7925
+ const ret = getObject(arg0).value;
7926
+ return addHeapObject(ret);
7927
+ },
7786
7928
  __wbg_versions_c01dfd4722a88165: function(arg0) {
7787
7929
  const ret = getObject(arg0).versions;
7788
7930
  return addHeapObject(ret);
@@ -7812,17 +7954,22 @@ function __wbg_get_imports() {
7812
7954
  const ret = arg0;
7813
7955
  return addHeapObject(ret);
7814
7956
  },
7815
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
7957
+ __wbindgen_cast_0000000000000002: function(arg0) {
7958
+ // Cast intrinsic for `I64 -> Externref`.
7959
+ const ret = arg0;
7960
+ return addHeapObject(ret);
7961
+ },
7962
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
7816
7963
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
7817
7964
  const ret = getArrayU8FromWasm0(arg0, arg1);
7818
7965
  return addHeapObject(ret);
7819
7966
  },
7820
- __wbindgen_cast_0000000000000003: function(arg0, arg1) {
7967
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
7821
7968
  // Cast intrinsic for `Ref(String) -> Externref`.
7822
7969
  const ret = getStringFromWasm0(arg0, arg1);
7823
7970
  return addHeapObject(ret);
7824
7971
  },
7825
- __wbindgen_cast_0000000000000004: function(arg0) {
7972
+ __wbindgen_cast_0000000000000005: function(arg0) {
7826
7973
  // Cast intrinsic for `U64 -> Externref`.
7827
7974
  const ret = BigInt.asUintN(64, arg0);
7828
7975
  return addHeapObject(ret);
Binary file