@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
@@ -46,23 +46,19 @@ export class AddressNamespace {
46
46
  }
47
47
  }
48
48
  /**
49
- * `can_be_shielded_output`: when set and `address` is a ZIP-316 unified address carrying an
50
- * Orchard/Ironwood receiver, returns that raw 43-byte receiver instead of a transparent
51
- * scriptPubKey. See [`to_output_script_or_shielded_receiver_with_coin`] for the exact
52
- * fallback/error rules.
49
+ * Convert `address` to its scriptPubKey bytes for `coin`.
53
50
  * @param {string} address
54
51
  * @param {string} coin
55
- * @param {boolean | null} [can_be_shielded_output]
56
52
  * @returns {Uint8Array}
57
53
  */
58
- static to_output_script_with_coin(address, coin, can_be_shielded_output) {
54
+ static to_output_script_with_coin(address, coin) {
59
55
  try {
60
56
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
61
57
  const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
62
58
  const len0 = WASM_VECTOR_LEN;
63
59
  const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
64
60
  const len1 = WASM_VECTOR_LEN;
65
- wasm.addressnamespace_to_output_script_with_coin(retptr, ptr0, len0, ptr1, len1, isLikeNone(can_be_shielded_output) ? 0xFFFFFF : can_be_shielded_output ? 1 : 0);
61
+ wasm.addressnamespace_to_output_script_with_coin(retptr, ptr0, len0, ptr1, len1);
66
62
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
67
63
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
68
64
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -3183,6 +3179,59 @@ export class InscriptionsNamespace {
3183
3179
  }
3184
3180
  if (Symbol.dispose) InscriptionsNamespace.prototype[Symbol.dispose] = InscriptionsNamespace.prototype.free;
3185
3181
 
3182
+ /**
3183
+ * A validated Merkle witness for an Ironwood/Orchard note commitment, from
3184
+ * [`ironwood_build_witness`].
3185
+ *
3186
+ * Not yet installed anywhere — see [`ironwood_build_witness`]'s docs.
3187
+ */
3188
+ export class IronwoodWitness {
3189
+ static __wrap(ptr) {
3190
+ ptr = ptr >>> 0;
3191
+ const obj = Object.create(IronwoodWitness.prototype);
3192
+ obj.__wbg_ptr = ptr;
3193
+ IronwoodWitnessFinalization.register(obj, obj.__wbg_ptr, obj);
3194
+ return obj;
3195
+ }
3196
+ __destroy_into_raw() {
3197
+ const ptr = this.__wbg_ptr;
3198
+ this.__wbg_ptr = 0;
3199
+ IronwoodWitnessFinalization.unregister(this);
3200
+ return ptr;
3201
+ }
3202
+ free() {
3203
+ const ptr = this.__destroy_into_raw();
3204
+ wasm.__wbg_ironwoodwitness_free(ptr, 0);
3205
+ }
3206
+ /**
3207
+ * The 32 sibling hashes (leaf-to-root order), flattened into a single 1024-byte array
3208
+ * (32 hashes × 32 bytes each).
3209
+ * @returns {Uint8Array}
3210
+ */
3211
+ get auth_path() {
3212
+ try {
3213
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3214
+ wasm.ironwoodwitness_auth_path(retptr, this.__wbg_ptr);
3215
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3216
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3217
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3218
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3219
+ return v1;
3220
+ } finally {
3221
+ wasm.__wbindgen_add_to_stack_pointer(16);
3222
+ }
3223
+ }
3224
+ /**
3225
+ * The leaf's position in the note commitment tree.
3226
+ * @returns {number}
3227
+ */
3228
+ get position() {
3229
+ const ret = wasm.ironwoodwitness_position(this.__wbg_ptr);
3230
+ return ret >>> 0;
3231
+ }
3232
+ }
3233
+ if (Symbol.dispose) IronwoodWitness.prototype[Symbol.dispose] = IronwoodWitness.prototype.free;
3234
+
3186
3235
  export class MessageNamespace {
3187
3236
  __destroy_into_raw() {
3188
3237
  const ptr = this.__wbg_ptr;
@@ -6743,6 +6792,28 @@ export class ZcashUnifiedAddress {
6743
6792
  wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
6744
6793
  }
6745
6794
  }
6795
+ /**
6796
+ * Whether this Unified Address carries an Orchard/Ironwood receiver.
6797
+ *
6798
+ * Equivalent to `orchardReceiver !== undefined`, without cloning the receiver bytes
6799
+ * when the caller only needs presence.
6800
+ * @returns {boolean}
6801
+ */
6802
+ get hasOrchardReceiver() {
6803
+ const ret = wasm.zcashunifiedaddress_hasOrchardReceiver(this.__wbg_ptr);
6804
+ return ret !== 0;
6805
+ }
6806
+ /**
6807
+ * Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
6808
+ *
6809
+ * Equivalent to `transparentScript !== undefined`, without cloning the script bytes
6810
+ * when the caller only needs presence.
6811
+ * @returns {boolean}
6812
+ */
6813
+ get hasTransparentReceiver() {
6814
+ const ret = wasm.zcashunifiedaddress_hasTransparentReceiver(this.__wbg_ptr);
6815
+ return ret !== 0;
6816
+ }
6746
6817
  /**
6747
6818
  * The Orchard/Ironwood receiver's raw 43 bytes (diversifier + pk_d), or `undefined`.
6748
6819
  * @returns {Uint8Array | undefined}
@@ -7045,6 +7116,44 @@ export class ZcashV6Transaction {
7045
7116
  }
7046
7117
  if (Symbol.dispose) ZcashV6Transaction.prototype[Symbol.dispose] = ZcashV6Transaction.prototype.free;
7047
7118
 
7119
+ /**
7120
+ * Build and validate a Merkle witness for an Ironwood/Orchard note commitment.
7121
+ *
7122
+ * `cmx` is the note commitment being witnessed; `auth_path` must be exactly 32 sibling hashes (32
7123
+ * bytes each), leaf-to-root order; `anchor` is the expected note-commitment-tree root. Throws if
7124
+ * any input isn't a canonical field element, or if the witness doesn't recompute to `anchor`.
7125
+ *
7126
+ * This crate has no chain state, so the raw sibling-hash path must be supplied by the caller
7127
+ * (typically BitGo's backend, querying a Zcash-aware service). The returned witness is not yet
7128
+ * installed anywhere — hook it into a spend once real-spend construction exists.
7129
+ * @param {Uint8Array} cmx
7130
+ * @param {number} position
7131
+ * @param {Uint8Array[]} auth_path
7132
+ * @param {Uint8Array} anchor
7133
+ * @returns {IronwoodWitness}
7134
+ */
7135
+ export function ironwood_build_witness(cmx, position, auth_path, anchor) {
7136
+ try {
7137
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
7138
+ const ptr0 = passArray8ToWasm0(cmx, wasm.__wbindgen_export);
7139
+ const len0 = WASM_VECTOR_LEN;
7140
+ const ptr1 = passArrayJsValueToWasm0(auth_path, wasm.__wbindgen_export);
7141
+ const len1 = WASM_VECTOR_LEN;
7142
+ const ptr2 = passArray8ToWasm0(anchor, wasm.__wbindgen_export);
7143
+ const len2 = WASM_VECTOR_LEN;
7144
+ wasm.ironwood_build_witness(retptr, ptr0, len0, position, ptr1, len1, ptr2, len2);
7145
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
7146
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
7147
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
7148
+ if (r2) {
7149
+ throw takeObject(r1);
7150
+ }
7151
+ return IronwoodWitness.__wrap(r0);
7152
+ } finally {
7153
+ wasm.__wbindgen_add_to_stack_pointer(16);
7154
+ }
7155
+ }
7156
+
7048
7157
  /**
7049
7158
  * Check if the inspect feature is enabled.
7050
7159
  *
@@ -7210,6 +7319,113 @@ export function parseTxToJson(tx_bytes, coin_name) {
7210
7319
  }
7211
7320
  }
7212
7321
 
7322
+ /**
7323
+ * Whether `address` is a ZIP-316 unified address for `coin`'s network carrying an
7324
+ * Orchard/Ironwood receiver. `false` (never throws) for a malformed/wrong-network unified
7325
+ * address, an ordinary address, or a UA with no Orchard/Ironwood receiver.
7326
+ * @param {string} address
7327
+ * @param {string} coin
7328
+ * @returns {boolean}
7329
+ */
7330
+ export function zcashHasOrchardReceiver(address, coin) {
7331
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7332
+ const len0 = WASM_VECTOR_LEN;
7333
+ const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7334
+ const len1 = WASM_VECTOR_LEN;
7335
+ const ret = wasm.zcashHasOrchardReceiver(ptr0, len0, ptr1, len1);
7336
+ return ret !== 0;
7337
+ }
7338
+
7339
+ /**
7340
+ * Whether `address` has a usable transparent receiver for `coin`'s network: either it's a
7341
+ * unified address carrying a transparent receiver, or it's itself a valid transparent address
7342
+ * for `coin`. `false` (never throws) otherwise.
7343
+ * @param {string} address
7344
+ * @param {string} coin
7345
+ * @returns {boolean}
7346
+ */
7347
+ export function zcashHasTransparentReceiver(address, coin) {
7348
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7349
+ const len0 = WASM_VECTOR_LEN;
7350
+ const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7351
+ const len1 = WASM_VECTOR_LEN;
7352
+ const ret = wasm.zcashHasTransparentReceiver(ptr0, len0, ptr1, len1);
7353
+ return ret !== 0;
7354
+ }
7355
+
7356
+ /**
7357
+ * @param {string} address
7358
+ * @param {string} coin
7359
+ * @returns {Uint8Array}
7360
+ */
7361
+ export function zcashToShieldedReceiverWithCoin(address, coin) {
7362
+ try {
7363
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
7364
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7365
+ const len0 = WASM_VECTOR_LEN;
7366
+ const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7367
+ const len1 = WASM_VECTOR_LEN;
7368
+ wasm.zcashToShieldedReceiverWithCoin(retptr, ptr0, len0, ptr1, len1);
7369
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
7370
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
7371
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
7372
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
7373
+ if (r3) {
7374
+ throw takeObject(r2);
7375
+ }
7376
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
7377
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
7378
+ return v3;
7379
+ } finally {
7380
+ wasm.__wbindgen_add_to_stack_pointer(16);
7381
+ }
7382
+ }
7383
+
7384
+ /**
7385
+ * Resolve the Orchard/Ironwood receiver of a ZIP-316 unified address for `coin`'s network, as
7386
+ * its raw 43 bytes (diversifier + `pk_d`) — there is no scriptPubKey for a shielded output, so
7387
+ * this can't return script bytes uniformly and returns raw receiver bytes instead.
7388
+ *
7389
+ * A UA that has no Orchard/Ironwood receiver (e.g. Sapling-only) throws rather than falling back
7390
+ * to the transparent receiver. If `address` merely looks like a unified address for this coin's
7391
+ * network (right Bech32m HRP) but is malformed, this also throws. `address` must be a unified
7392
+ * address — an ordinary transparent address is rejected, since it can never carry a shielded
7393
+ * receiver; use {@link toOutputScriptWithCoin} in `js/address.ts` for the transparent case.
7394
+ * Resolve the transparent receiver of an `address` for `coin`'s network, as its scriptPubKey
7395
+ * bytes. When `address` is a ZIP-316 unified address, resolves its transparent receiver rather
7396
+ * than rejecting the UA string outright — a UA with no transparent receiver (e.g. Orchard-only)
7397
+ * throws rather than falling back to a shielded one. An ordinary (non-UA) address falls through
7398
+ * to the same transparent codec path as any other coin.
7399
+ *
7400
+ * This is the zcash-aware counterpart of `toOutputScriptWithCoin` in `js/address.ts`, which
7401
+ * dispatches here for zcash/tzec so that non-zcash coins never pay for a unified-address check.
7402
+ * @param {string} address
7403
+ * @param {string} coin
7404
+ * @returns {Uint8Array}
7405
+ */
7406
+ export function zcashToTransparentReceiverWithCoin(address, coin) {
7407
+ try {
7408
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
7409
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7410
+ const len0 = WASM_VECTOR_LEN;
7411
+ const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7412
+ const len1 = WASM_VECTOR_LEN;
7413
+ wasm.zcashToTransparentReceiverWithCoin(retptr, ptr0, len0, ptr1, len1);
7414
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
7415
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
7416
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
7417
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
7418
+ if (r3) {
7419
+ throw takeObject(r2);
7420
+ }
7421
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
7422
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
7423
+ return v3;
7424
+ } finally {
7425
+ wasm.__wbindgen_add_to_stack_pointer(16);
7426
+ }
7427
+ }
7428
+
7213
7429
  /**
7214
7430
  * Return the Zcash consensus branch ID active at `height` on `network`.
7215
7431
  *
@@ -7504,6 +7720,9 @@ const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry ===
7504
7720
  const InscriptionsNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
7505
7721
  ? { register: () => {}, unregister: () => {} }
7506
7722
  : new FinalizationRegistry(ptr => wasm.__wbg_inscriptionsnamespace_free(ptr >>> 0, 1));
7723
+ const IronwoodWitnessFinalization = (typeof FinalizationRegistry === 'undefined')
7724
+ ? { register: () => {}, unregister: () => {} }
7725
+ : new FinalizationRegistry(ptr => wasm.__wbg_ironwoodwitness_free(ptr >>> 0, 1));
7507
7726
  const MessageNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
7508
7727
  ? { register: () => {}, unregister: () => {} }
7509
7728
  : new FinalizationRegistry(ptr => wasm.__wbg_messagenamespace_free(ptr >>> 0, 1));
Binary file
@@ -1,11 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const __wbg_addressnamespace_free: (a: number, b: number) => void;
5
4
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
6
5
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
7
- export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
8
- export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
9
6
  export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
10
7
  export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
11
8
  export const wasmdimensions_empty: () => number;
@@ -23,7 +20,20 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
23
20
  export const wasmdimensions_has_segwit: (a: number) => number;
24
21
  export const wasmdimensions_plus: (a: number, b: number) => number;
25
22
  export const wasmdimensions_times: (a: number, b: number) => number;
26
- export const __wbg_messagenamespace_free: (a: number, b: number) => void;
23
+ export const __wbg_bip322namespace_free: (a: number, b: number) => void;
24
+ export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
25
+ 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;
26
+ export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
27
+ 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;
28
+ export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
29
+ export const bip322namespace_verify_bip322_tx_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) => void;
30
+ export const bip322namespace_verify_bip322_tx_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
31
+ export const wasmrootwalletkeys_backup_key: (a: number) => number;
32
+ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
33
+ export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
34
+ export const wasmrootwalletkeys_user_key: (a: number) => number;
35
+ 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;
36
+ export const __wbg_ironwoodwitness_free: (a: number, b: number) => void;
27
37
  export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
28
38
  export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
29
39
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
@@ -31,8 +41,9 @@ export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
31
41
  export const __wbg_wrappsbt_free: (a: number, b: number) => void;
32
42
  export const __wbg_zcashunifiedaddress_free: (a: number, b: number) => void;
33
43
  export const __wbg_zcashv6transaction_free: (a: number, b: number) => void;
34
- export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
35
- export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
44
+ export const ironwood_build_witness: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
45
+ export const ironwoodwitness_auth_path: (a: number, b: number) => void;
46
+ export const ironwoodwitness_position: (a: number) => number;
36
47
  export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
37
48
  export const wasmdashtransaction_get_inputs: (a: number, b: number) => void;
38
49
  export const wasmdashtransaction_get_outputs: (a: number, b: number) => void;
@@ -109,10 +120,16 @@ export const wrappsbt_update_input_with_descriptor: (a: number, b: number, c: nu
109
120
  export const wrappsbt_update_output_with_descriptor: (a: number, b: number, c: number, d: number) => void;
110
121
  export const wrappsbt_validate_signature_at_input: (a: number, b: number, c: number, d: number, e: number) => void;
111
122
  export const wrappsbt_verify_signature_with_key: (a: number, b: number, c: number, d: number) => void;
123
+ export const zcashHasOrchardReceiver: (a: number, b: number, c: number, d: number) => number;
124
+ export const zcashHasTransparentReceiver: (a: number, b: number, c: number, d: number) => number;
125
+ export const zcashToShieldedReceiverWithCoin: (a: number, b: number, c: number, d: number, e: number) => void;
126
+ export const zcashToTransparentReceiverWithCoin: (a: number, b: number, c: number, d: number, e: number) => void;
112
127
  export const zcash_branch_id_for_height: (a: number, b: number, c: number, d: number) => void;
113
128
  export const zcash_ironwood_version_group_id: () => number;
114
129
  export const zcashunifiedaddress_contains: (a: number, b: number, c: number, d: number) => void;
115
130
  export const zcashunifiedaddress_encodeOrchardReceiver: (a: number, b: number, c: number, d: number, e: number) => void;
131
+ export const zcashunifiedaddress_hasOrchardReceiver: (a: number) => number;
132
+ export const zcashunifiedaddress_hasTransparentReceiver: (a: number) => number;
116
133
  export const zcashunifiedaddress_orchardReceiver: (a: number, b: number) => void;
117
134
  export const zcashunifiedaddress_parse: (a: number, b: number, c: number, d: number, e: number) => void;
118
135
  export const zcashunifiedaddress_saplingReceiver: (a: number, b: number) => void;
@@ -138,44 +155,33 @@ export const wasmzcashtransaction_lock_time: (a: number) => number;
138
155
  export const wasmzcashtransaction_version: (a: number) => number;
139
156
  export const wrappsbt_lock_time: (a: number) => number;
140
157
  export const wrappsbt_version: (a: number) => number;
141
- export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
142
- export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
143
- export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
144
- export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
145
- 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;
146
- export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
147
- export const wrapdescriptor_descType: (a: number, b: number) => void;
148
- export const wrapdescriptor_encode: (a: number, b: number) => void;
149
- export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
150
- export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
151
- export const wrapdescriptor_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
152
- export const wrapdescriptor_hasWildcard: (a: number) => number;
153
- export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
154
- export const wrapdescriptor_node: (a: number, b: number) => void;
155
- export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
156
- export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
157
- export const wrapdescriptor_toString: (a: number, b: number) => void;
158
- export const wrapminiscript_encode: (a: number, b: number) => void;
159
- export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
160
- export const wrapminiscript_fromBitcoinScriptExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
161
- export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
162
- export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
163
- export const wrapminiscript_node: (a: number, b: number) => void;
164
- export const wrapminiscript_toAsmString: (a: number, b: number) => void;
165
- export const wrapminiscript_toString: (a: number, b: number) => void;
166
- export const __wbg_bip322namespace_free: (a: number, b: number) => void;
167
- 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;
168
- export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
169
- 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;
170
- export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
171
- export const bip322namespace_verify_bip322_tx_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) => void;
172
- export const bip322namespace_verify_bip322_tx_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
158
+ export const __wbg_addressnamespace_free: (a: number, b: number) => void;
159
+ export const __wbg_messagenamespace_free: (a: number, b: number) => void;
160
+ export const __wbg_wasmecpair_free: (a: number, b: number) => void;
161
+ export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
162
+ export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
163
+ export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
164
+ export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
165
+ export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
166
+ export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
167
+ export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
168
+ export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
169
+ export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
170
+ export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
171
+ export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
172
+ export const wasmecpair_private_key: (a: number) => number;
173
+ export const wasmecpair_public_key: (a: number) => number;
174
+ export const wasmecpair_to_wif: (a: number, b: number) => void;
175
+ export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
176
+ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
177
+ export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
178
+ export const isInspectEnabled: () => number;
179
+ export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
180
+ export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
173
181
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
174
182
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
183
+ export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
175
184
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
176
- export const __wbg_wasmecpair_free: (a: number, b: number) => void;
177
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
178
- export const __wbg_wasmutxonamespace_free: (a: number, b: number) => void;
179
185
  export const bitgopsbt_add_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number, k: number) => void;
180
186
  export const bitgopsbt_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number, j: number, k: number, l: number) => void;
181
187
  export const bitgopsbt_add_ironwood_output: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
@@ -272,8 +278,8 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
272
278
  export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
273
279
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
274
280
  export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
275
- export const isInspectEnabled: () => number;
276
- export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
281
+ export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
282
+ 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;
277
283
  export const wasmbip32_chain_code: (a: number) => number;
278
284
  export const wasmbip32_depth: (a: number) => number;
279
285
  export const wasmbip32_derive: (a: number, b: number, c: number) => void;
@@ -296,28 +302,32 @@ export const wasmbip32_private_key: (a: number) => number;
296
302
  export const wasmbip32_public_key: (a: number) => number;
297
303
  export const wasmbip32_to_base58: (a: number, b: number) => void;
298
304
  export const wasmbip32_to_wif: (a: number, b: number) => void;
299
- export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
300
- export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
301
- export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
302
- export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
303
- export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
304
- export const wasmecpair_private_key: (a: number) => number;
305
- export const wasmecpair_public_key: (a: number) => number;
306
- export const wasmecpair_to_wif: (a: number, b: number) => void;
307
- export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
308
- export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
309
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
310
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
311
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
312
- export const wasmrootwalletkeys_user_key: (a: number) => number;
313
- 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;
314
- export const wasmutxonamespace_get_wasm_utxo_version: (a: number) => void;
315
305
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
316
- export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
317
- export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
306
+ export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
318
307
  export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
319
308
  export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
320
- export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
309
+ export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
310
+ export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
311
+ export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
312
+ export const wrapdescriptor_descType: (a: number, b: number) => void;
313
+ export const wrapdescriptor_encode: (a: number, b: number) => void;
314
+ export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
315
+ export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
316
+ export const wrapdescriptor_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
317
+ export const wrapdescriptor_hasWildcard: (a: number) => number;
318
+ export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
319
+ export const wrapdescriptor_node: (a: number, b: number) => void;
320
+ export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
321
+ export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
322
+ export const wrapdescriptor_toString: (a: number, b: number) => void;
323
+ export const wrapminiscript_encode: (a: number, b: number) => void;
324
+ export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
325
+ export const wrapminiscript_fromBitcoinScriptExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
326
+ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
327
+ export const wrapminiscript_fromStringExt: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
328
+ export const wrapminiscript_node: (a: number, b: number) => void;
329
+ export const wrapminiscript_toAsmString: (a: number, b: number) => void;
330
+ export const wrapminiscript_toString: (a: number, b: number) => void;
321
331
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
322
332
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
323
333
  export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
@@ -0,0 +1,44 @@
1
+ import type { CoinName } from "./coinName.js";
2
+ /**
3
+ * Convert `address` to its scriptPubKey bytes for `coin`'s network. When `address` is a ZIP-316
4
+ * unified address, resolves its transparent receiver -- same as any other transparent address --
5
+ * rather than rejecting the UA string outright. A UA with no transparent receiver (e.g.
6
+ * Orchard-only) throws rather than falling back to a shielded one.
7
+ *
8
+ * `js/address.ts`'s `toOutputScriptWithCoin` dispatches here for zcash/tzec; call this directly
9
+ * only if you already know `coin` is a Zcash coin.
10
+ */
11
+ export declare function toTransparentReceiverWithCoin(address: string, coin: CoinName): Uint8Array;
12
+ /**
13
+ * Resolve the Orchard/Ironwood receiver of a ZIP-316 unified address for `coin`'s network, as its
14
+ * raw 43 bytes (diversifier + `pk_d`) -- there is no scriptPubKey for a shielded output, so this
15
+ * returns raw receiver bytes rather than a scriptPubKey.
16
+ *
17
+ * `address` must be a unified address; an ordinary transparent address is rejected, since it can
18
+ * never carry a shielded receiver. A UA that has no Orchard/Ironwood receiver (e.g. Sapling-only)
19
+ * throws rather than falling back to the transparent receiver. If `address` merely looks like a
20
+ * unified address for this coin's network (right Bech32m HRP) but is malformed, this also throws.
21
+ * Use {@link toOutputScriptWithCoin} from `js/address.ts` for the transparent case.
22
+ */
23
+ export declare function toShieldedReceiverWithCoin(address: string, coin: CoinName): Uint8Array;
24
+ /**
25
+ * Whether `address` is a ZIP-316 unified address for `coin`'s network carrying an
26
+ * Orchard/Ironwood receiver.
27
+ *
28
+ * A plain membership check, not a decoder: never throws. Returns `false` for a malformed or
29
+ * wrong-network unified address, an ordinary (non-UA) address, or a UA with no Orchard/Ironwood
30
+ * receiver (e.g. Sapling-only). Use {@link toShieldedReceiverWithCoin} when the raw receiver bytes
31
+ * are needed.
32
+ */
33
+ export declare function hasOrchardReceiver(address: string, coin: CoinName): boolean;
34
+ /**
35
+ * Whether `address` has a usable transparent receiver for `coin`'s network: either `address` is
36
+ * a ZIP-316 unified address carrying a transparent receiver, or `address` is itself an ordinary
37
+ * transparent address that decodes for `coin`.
38
+ *
39
+ * A plain membership check, not a decoder: never throws. Returns `false` for a malformed or
40
+ * wrong-network unified address, a UA with no transparent receiver (e.g. Orchard-only), or an
41
+ * address that is neither a unified address nor a valid transparent address for `coin`. Use
42
+ * {@link toOutputScriptWithCoin} from `js/address.ts` when the scriptPubKey bytes are needed.
43
+ */
44
+ export declare function hasTransparentReceiver(address: string, coin: CoinName): boolean;
@@ -0,0 +1,52 @@
1
+ import { zcashHasOrchardReceiver, zcashHasTransparentReceiver, zcashToShieldedReceiverWithCoin, zcashToTransparentReceiverWithCoin, } from "./wasm/wasm_utxo.js";
2
+ /**
3
+ * Convert `address` to its scriptPubKey bytes for `coin`'s network. When `address` is a ZIP-316
4
+ * unified address, resolves its transparent receiver -- same as any other transparent address --
5
+ * rather than rejecting the UA string outright. A UA with no transparent receiver (e.g.
6
+ * Orchard-only) throws rather than falling back to a shielded one.
7
+ *
8
+ * `js/address.ts`'s `toOutputScriptWithCoin` dispatches here for zcash/tzec; call this directly
9
+ * only if you already know `coin` is a Zcash coin.
10
+ */
11
+ export function toTransparentReceiverWithCoin(address, coin) {
12
+ return zcashToTransparentReceiverWithCoin(address, coin);
13
+ }
14
+ /**
15
+ * Resolve the Orchard/Ironwood receiver of a ZIP-316 unified address for `coin`'s network, as its
16
+ * raw 43 bytes (diversifier + `pk_d`) -- there is no scriptPubKey for a shielded output, so this
17
+ * returns raw receiver bytes rather than a scriptPubKey.
18
+ *
19
+ * `address` must be a unified address; an ordinary transparent address is rejected, since it can
20
+ * never carry a shielded receiver. A UA that has no Orchard/Ironwood receiver (e.g. Sapling-only)
21
+ * throws rather than falling back to the transparent receiver. If `address` merely looks like a
22
+ * unified address for this coin's network (right Bech32m HRP) but is malformed, this also throws.
23
+ * Use {@link toOutputScriptWithCoin} from `js/address.ts` for the transparent case.
24
+ */
25
+ export function toShieldedReceiverWithCoin(address, coin) {
26
+ return zcashToShieldedReceiverWithCoin(address, coin);
27
+ }
28
+ /**
29
+ * Whether `address` is a ZIP-316 unified address for `coin`'s network carrying an
30
+ * Orchard/Ironwood receiver.
31
+ *
32
+ * A plain membership check, not a decoder: never throws. Returns `false` for a malformed or
33
+ * wrong-network unified address, an ordinary (non-UA) address, or a UA with no Orchard/Ironwood
34
+ * receiver (e.g. Sapling-only). Use {@link toShieldedReceiverWithCoin} when the raw receiver bytes
35
+ * are needed.
36
+ */
37
+ export function hasOrchardReceiver(address, coin) {
38
+ return zcashHasOrchardReceiver(address, coin);
39
+ }
40
+ /**
41
+ * Whether `address` has a usable transparent receiver for `coin`'s network: either `address` is
42
+ * a ZIP-316 unified address carrying a transparent receiver, or `address` is itself an ordinary
43
+ * transparent address that decodes for `coin`.
44
+ *
45
+ * A plain membership check, not a decoder: never throws. Returns `false` for a malformed or
46
+ * wrong-network unified address, a UA with no transparent receiver (e.g. Orchard-only), or an
47
+ * address that is neither a unified address nor a valid transparent address for `coin`. Use
48
+ * {@link toOutputScriptWithCoin} from `js/address.ts` when the scriptPubKey bytes are needed.
49
+ */
50
+ export function hasTransparentReceiver(address, coin) {
51
+ return zcashHasTransparentReceiver(address, coin);
52
+ }
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.40.0",
4
+ "version": "5.0.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",