@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.
- package/dist/cjs/js/address.d.ts +3 -7
- package/dist/cjs/js/address.js +4 -8
- package/dist/cjs/js/fixedScriptWallet/Dimensions.d.ts +5 -16
- package/dist/cjs/js/fixedScriptWallet/Dimensions.js +2 -2
- package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashDimensions.js +30 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodWitness.d.ts +31 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodWitness.js +45 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -0
- package/dist/cjs/js/fixedScriptWallet/index.js +4 -1
- package/dist/cjs/js/index.d.ts +2 -0
- package/dist/cjs/js/index.js +4 -1
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +87 -5
- package/dist/cjs/js/wasm/wasm_utxo.js +232 -7
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +72 -62
- package/dist/cjs/js/zcashAddress.d.ts +44 -0
- package/dist/cjs/js/zcashAddress.js +58 -0
- package/dist/esm/js/address.d.ts +3 -7
- package/dist/esm/js/address.js +4 -8
- package/dist/esm/js/fixedScriptWallet/Dimensions.d.ts +5 -16
- package/dist/esm/js/fixedScriptWallet/Dimensions.js +2 -2
- package/dist/esm/js/fixedScriptWallet/ZcashDimensions.d.ts +45 -0
- package/dist/esm/js/fixedScriptWallet/ZcashDimensions.js +26 -0
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodWitness.d.ts +31 -0
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodWitness.js +41 -0
- package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.d.ts +16 -0
- package/dist/esm/js/fixedScriptWallet/ZcashUnifiedAddress.js +20 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -0
- package/dist/esm/js/fixedScriptWallet/index.js +2 -0
- package/dist/esm/js/index.d.ts +2 -0
- package/dist/esm/js/index.js +2 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +87 -5
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +226 -7
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +72 -62
- package/dist/esm/js/zcashAddress.d.ts +44 -0
- package/dist/esm/js/zcashAddress.js +52 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
|
59
|
+
static fromOutput(address: string, network: CoinName): Dimensions;
|
|
71
60
|
/**
|
|
72
61
|
* Create dimensions for a single output from script length only
|
|
73
62
|
*/
|
|
@@ -42,12 +42,12 @@ export class Dimensions {
|
|
|
42
42
|
}
|
|
43
43
|
return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
|
|
44
44
|
}
|
|
45
|
-
static fromOutput(params, network
|
|
45
|
+
static fromOutput(params, network) {
|
|
46
46
|
if (typeof params === "string") {
|
|
47
47
|
if (network === undefined) {
|
|
48
48
|
throw new Error("network is required when passing an address string");
|
|
49
49
|
}
|
|
50
|
-
const script = toOutputScriptWithCoin(params, network
|
|
50
|
+
const script = toOutputScriptWithCoin(params, network);
|
|
51
51
|
return new Dimensions(WasmDimensions.from_output_script_length(script.length));
|
|
52
52
|
}
|
|
53
53
|
if (typeof params === "object" && "scriptType" in params) {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CoinName } from "../coinName.js";
|
|
2
|
+
import type { OutputScriptType } from "./scriptType.js";
|
|
3
|
+
import { Dimensions } from "./Dimensions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link ZcashDimensions.fromOutput}.
|
|
6
|
+
*/
|
|
7
|
+
export type ZcashFromOutputOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Set when `address` may be a ZIP-316 Unified Address whose Orchard receiver should be sized
|
|
10
|
+
* as a shielded output. Forwarded to `zcashAddress.toShieldedReceiverWithCoin`; when unset,
|
|
11
|
+
* `zcashAddress.toTransparentReceiverWithCoin` is used instead.
|
|
12
|
+
*/
|
|
13
|
+
isShielded?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
|
|
17
|
+
* shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
|
|
18
|
+
* does for every other coin.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ZcashDimensions extends Dimensions {
|
|
21
|
+
/**
|
|
22
|
+
* Create dimensions for a single output from script bytes
|
|
23
|
+
*/
|
|
24
|
+
static fromOutput(script: Uint8Array): Dimensions;
|
|
25
|
+
/**
|
|
26
|
+
* Create dimensions for a single output from a Zcash address for `network`.
|
|
27
|
+
*
|
|
28
|
+
* Pass `{ isShielded: true }` when `address` may be a ZIP-316 Unified Address whose Orchard
|
|
29
|
+
* receiver should be sized as a shielded output; otherwise its transparent receiver is
|
|
30
|
+
* resolved (a UA with no transparent receiver throws rather than falling back to Orchard).
|
|
31
|
+
*/
|
|
32
|
+
static fromOutput(address: string, network: CoinName, options?: ZcashFromOutputOptions): Dimensions;
|
|
33
|
+
/**
|
|
34
|
+
* Create dimensions for a single output from script length only
|
|
35
|
+
*/
|
|
36
|
+
static fromOutput(params: {
|
|
37
|
+
length: number;
|
|
38
|
+
}): Dimensions;
|
|
39
|
+
/**
|
|
40
|
+
* Create dimensions for a single output from script type
|
|
41
|
+
*/
|
|
42
|
+
static fromOutput(params: {
|
|
43
|
+
scriptType: OutputScriptType;
|
|
44
|
+
}): Dimensions;
|
|
45
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WasmDimensions } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { toShieldedReceiverWithCoin, toTransparentReceiverWithCoin } from "../zcashAddress.js";
|
|
3
|
+
import { Dimensions } from "./Dimensions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Zcash-specific dimensions: resolves ZIP-316 Unified Addresses (transparent or Orchard/Ironwood
|
|
6
|
+
* shielded receiver) instead of the plain transparent-only decoding {@link Dimensions.fromOutput}
|
|
7
|
+
* does for every other coin.
|
|
8
|
+
*/
|
|
9
|
+
export class ZcashDimensions extends Dimensions {
|
|
10
|
+
static fromOutput(params, network, options) {
|
|
11
|
+
if (typeof params === "string") {
|
|
12
|
+
if (network === undefined) {
|
|
13
|
+
throw new Error("network is required when passing an address string");
|
|
14
|
+
}
|
|
15
|
+
const receiver = options?.isShielded
|
|
16
|
+
? toShieldedReceiverWithCoin(params, network)
|
|
17
|
+
: toTransparentReceiverWithCoin(params, network);
|
|
18
|
+
return new ZcashDimensions(WasmDimensions.from_output_script_length(receiver.length));
|
|
19
|
+
}
|
|
20
|
+
if (typeof params === "object" && "scriptType" in params) {
|
|
21
|
+
return Dimensions.fromOutput(params);
|
|
22
|
+
}
|
|
23
|
+
// Both Uint8Array and { length: number } have .length
|
|
24
|
+
return Dimensions.fromOutput(params);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -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,41 @@
|
|
|
1
|
+
import { ironwood_build_witness, } 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 class ZcashIronwoodWitness {
|
|
14
|
+
_wasm;
|
|
15
|
+
constructor(_wasm) {
|
|
16
|
+
this._wasm = _wasm;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build and validate a Merkle witness for an Ironwood/Orchard note commitment.
|
|
20
|
+
* @throws If any input isn't a canonical field element, or the witness doesn't
|
|
21
|
+
* recompute to `anchor`
|
|
22
|
+
*/
|
|
23
|
+
static build(cmx, position, authPath, anchor) {
|
|
24
|
+
return new ZcashIronwoodWitness(ironwood_build_witness(cmx, position, authPath, anchor));
|
|
25
|
+
}
|
|
26
|
+
/** The leaf's position in the note commitment tree. */
|
|
27
|
+
get position() {
|
|
28
|
+
return this._wasm.position;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The 32 sibling hashes (leaf-to-root order), flattened into a single 1024-byte array
|
|
32
|
+
* (32 hashes × 32 bytes each).
|
|
33
|
+
*/
|
|
34
|
+
get authPath() {
|
|
35
|
+
return this._wasm.auth_path;
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
get wasm() {
|
|
39
|
+
return this._wasm;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -15,6 +15,8 @@ import type { ZcashNetworkName } from "./ZcashBitGoPsbt.js";
|
|
|
15
15
|
* const ua = ZcashUnifiedAddress.parse(uaString, "zec");
|
|
16
16
|
* const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
|
|
17
17
|
* const script = ua.transparentScript; // scriptPubKey bytes, or undefined
|
|
18
|
+
* ua.hasOrchardReceiver; // true iff orchardReceiver is present
|
|
19
|
+
* ua.hasTransparentReceiver; // true iff transparentScript is present
|
|
18
20
|
* ua.contains(transparentAddress); // is it one of this UA's receivers?
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
@@ -43,6 +45,20 @@ export declare class ZcashUnifiedAddress {
|
|
|
43
45
|
* a `TxOut.scriptPubKey`, or `undefined` if the UA has no transparent receiver.
|
|
44
46
|
*/
|
|
45
47
|
get transparentScript(): Uint8Array | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Whether this Unified Address carries an Orchard/Ironwood receiver.
|
|
50
|
+
*
|
|
51
|
+
* Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
|
|
52
|
+
* matters, since it avoids copying the receiver bytes.
|
|
53
|
+
*/
|
|
54
|
+
get hasOrchardReceiver(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
|
|
57
|
+
*
|
|
58
|
+
* Equivalent to `transparentScript !== undefined`; prefer this when only presence
|
|
59
|
+
* matters, since it avoids copying the script bytes.
|
|
60
|
+
*/
|
|
61
|
+
get hasTransparentReceiver(): boolean;
|
|
46
62
|
/**
|
|
47
63
|
* Whether `candidate` is a receiver of this unified address.
|
|
48
64
|
*
|
|
@@ -14,6 +14,8 @@ import { ZcashUnifiedAddress as WasmZcashUnifiedAddress } from "../wasm/wasm_utx
|
|
|
14
14
|
* const ua = ZcashUnifiedAddress.parse(uaString, "zec");
|
|
15
15
|
* const ironwood = ua.orchardReceiver; // 43 bytes, or undefined
|
|
16
16
|
* const script = ua.transparentScript; // scriptPubKey bytes, or undefined
|
|
17
|
+
* ua.hasOrchardReceiver; // true iff orchardReceiver is present
|
|
18
|
+
* ua.hasTransparentReceiver; // true iff transparentScript is present
|
|
17
19
|
* ua.contains(transparentAddress); // is it one of this UA's receivers?
|
|
18
20
|
* ```
|
|
19
21
|
*/
|
|
@@ -52,6 +54,24 @@ export class ZcashUnifiedAddress {
|
|
|
52
54
|
get transparentScript() {
|
|
53
55
|
return this._wasm.transparentScript;
|
|
54
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether this Unified Address carries an Orchard/Ironwood receiver.
|
|
59
|
+
*
|
|
60
|
+
* Equivalent to `orchardReceiver !== undefined`; prefer this when only presence
|
|
61
|
+
* matters, since it avoids copying the receiver bytes.
|
|
62
|
+
*/
|
|
63
|
+
get hasOrchardReceiver() {
|
|
64
|
+
return this._wasm.hasOrchardReceiver;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Whether this Unified Address carries a transparent (P2PKH/P2SH) receiver.
|
|
68
|
+
*
|
|
69
|
+
* Equivalent to `transparentScript !== undefined`; prefer this when only presence
|
|
70
|
+
* matters, since it avoids copying the script bytes.
|
|
71
|
+
*/
|
|
72
|
+
get hasTransparentReceiver() {
|
|
73
|
+
return this._wasm.hasTransparentReceiver;
|
|
74
|
+
}
|
|
55
75
|
/**
|
|
56
76
|
* Whether `candidate` is a receiver of this unified address.
|
|
57
77
|
*
|
|
@@ -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
|
|
@@ -18,6 +18,8 @@ export { ZcashIronwoodBitGoPsbt, zip302NoMemo, } from "./ZcashIronwoodBitGoPsbt.
|
|
|
18
18
|
export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
|
|
19
19
|
// Zcash v6 (Ironwood / NU6.3) transaction
|
|
20
20
|
export { ZcashV6Transaction } from "./ZcashV6Transaction.js";
|
|
21
|
+
// Zcash v6 (Ironwood / NU6.3) Merkle witness
|
|
22
|
+
export { ZcashIronwoodWitness } from "./ZcashIronwoodWitness.js";
|
|
21
23
|
/**
|
|
22
24
|
* Check if a network supports a given fixed-script wallet script type
|
|
23
25
|
*
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/esm/js/index.js
CHANGED
|
@@ -6,6 +6,7 @@ void wasm;
|
|
|
6
6
|
// Most exports are namespaced to avoid polluting the top-level namespace
|
|
7
7
|
// and to make imports more explicit (e.g., `import { address } from '@bitgo/wasm-utxo'`)
|
|
8
8
|
export * as address from "./address.js";
|
|
9
|
+
export * as zcashAddress from "./zcashAddress.js";
|
|
9
10
|
export * as ast from "./ast/index.js";
|
|
10
11
|
export * as bip322 from "./bip322/index.js";
|
|
11
12
|
export * as inscriptions from "./inscriptions.js";
|
|
@@ -19,6 +20,7 @@ export * as ecpair from "./ecpair.js";
|
|
|
19
20
|
export { ECPair } from "./ecpair.js";
|
|
20
21
|
export { BIP32 } from "./bip32.js";
|
|
21
22
|
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
23
|
+
export { ZcashDimensions } from "./fixedScriptWallet/ZcashDimensions.js";
|
|
22
24
|
export function getWasmUtxoVersion() {
|
|
23
25
|
return WasmUtxoNamespace.get_wasm_utxo_version();
|
|
24
26
|
}
|
|
@@ -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
|
-
*
|
|
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
|
|
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
|
*
|
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./wasm_utxo_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmUtxoNamespace, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, ZcashUnifiedAddress, ZcashV6Transaction, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson, zcash_branch_id_for_height, zcash_ironwood_version_group_id
|
|
8
|
+
AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, IronwoodWitness, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmUtxoNamespace, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, ZcashUnifiedAddress, ZcashV6Transaction, ironwood_build_witness, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson, zcashHasOrchardReceiver, zcashHasTransparentReceiver, zcashToShieldedReceiverWithCoin, zcashToTransparentReceiverWithCoin, zcash_branch_id_for_height, zcash_ironwood_version_group_id
|
|
9
9
|
} from "./wasm_utxo_bg.js";
|