@bitgo/wasm-utxo 4.31.0 → 4.32.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/fixedScriptWallet/ZcashBitGoPsbt.d.ts +11 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.js +17 -2
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +172 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +180 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +2 -1
- package/dist/cjs/js/fixedScriptWallet/index.js +6 -1
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +67 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +226 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +49 -41
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +11 -0
- package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.js +17 -2
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +172 -0
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +175 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +2 -1
- package/dist/esm/js/fixedScriptWallet/index.js +3 -1
- package/dist/esm/js/wasm/wasm_utxo.d.ts +67 -0
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +225 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +49 -41
- package/package.json +1 -1
|
@@ -3,6 +3,15 @@ import { BitGoPsbt, type CreateEmptyOptions, type HydrationUnspent } from "./Bit
|
|
|
3
3
|
import { ZcashTransaction, type ITransaction } from "../transaction.js";
|
|
4
4
|
/** Zcash network names */
|
|
5
5
|
export type ZcashNetworkName = "zcash" | "zcashTest" | "zec" | "tzec";
|
|
6
|
+
/**
|
|
7
|
+
* Zcash v6 (Ironwood) version group id (0xd884b698). Its presence marks a PSBT as v6 — see
|
|
8
|
+
* `ZcashIronwoodBitGoPsbt`.
|
|
9
|
+
*
|
|
10
|
+
* Read from the wasm layer rather than hard-coded, so it cannot drift from
|
|
11
|
+
* `ZCASH_IRONWOOD_VERSION_GROUP_ID` in `src/zcash/transaction.rs`: a divergence would make the
|
|
12
|
+
* v4/v6 discrimination in {@link ZcashBitGoPsbt.fromBytes} silently classify v6 bytes as v4.
|
|
13
|
+
*/
|
|
14
|
+
export declare const IRONWOOD_VERSION_GROUP_ID: number;
|
|
6
15
|
/** Options for creating an empty Zcash PSBT (preferred method using block height) */
|
|
7
16
|
export type CreateEmptyZcashOptions = CreateEmptyOptions & {
|
|
8
17
|
/** Block height to determine consensus branch ID automatically */
|
|
@@ -98,6 +107,8 @@ export declare class ZcashBitGoPsbt extends BitGoPsbt {
|
|
|
98
107
|
*
|
|
99
108
|
* @param bytes - The PSBT bytes
|
|
100
109
|
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
110
|
+
* @throws Error if the deserialized PSBT is a v6 (Ironwood) PSBT — use
|
|
111
|
+
* {@link ZcashIronwoodBitGoPsbt.fromBytes} instead
|
|
101
112
|
* @returns A ZcashBitGoPsbt instance
|
|
102
113
|
*/
|
|
103
114
|
static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashBitGoPsbt;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZcashBitGoPsbt = void 0;
|
|
3
|
+
exports.ZcashBitGoPsbt = exports.IRONWOOD_VERSION_GROUP_ID = void 0;
|
|
4
4
|
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
5
5
|
const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
|
|
6
6
|
const BitGoPsbt_js_1 = require("./BitGoPsbt.js");
|
|
7
7
|
const transaction_js_1 = require("../transaction.js");
|
|
8
|
+
/**
|
|
9
|
+
* Zcash v6 (Ironwood) version group id (0xd884b698). Its presence marks a PSBT as v6 — see
|
|
10
|
+
* `ZcashIronwoodBitGoPsbt`.
|
|
11
|
+
*
|
|
12
|
+
* Read from the wasm layer rather than hard-coded, so it cannot drift from
|
|
13
|
+
* `ZCASH_IRONWOOD_VERSION_GROUP_ID` in `src/zcash/transaction.rs`: a divergence would make the
|
|
14
|
+
* v4/v6 discrimination in {@link ZcashBitGoPsbt.fromBytes} silently classify v6 bytes as v4.
|
|
15
|
+
*/
|
|
16
|
+
exports.IRONWOOD_VERSION_GROUP_ID = (0, wasm_utxo_js_1.zcash_ironwood_version_group_id)();
|
|
8
17
|
/**
|
|
9
18
|
* Zcash-specific PSBT implementation
|
|
10
19
|
*
|
|
@@ -90,11 +99,17 @@ class ZcashBitGoPsbt extends BitGoPsbt_js_1.BitGoPsbt {
|
|
|
90
99
|
*
|
|
91
100
|
* @param bytes - The PSBT bytes
|
|
92
101
|
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
102
|
+
* @throws Error if the deserialized PSBT is a v6 (Ironwood) PSBT — use
|
|
103
|
+
* {@link ZcashIronwoodBitGoPsbt.fromBytes} instead
|
|
93
104
|
* @returns A ZcashBitGoPsbt instance
|
|
94
105
|
*/
|
|
95
106
|
static fromBytes(bytes, network) {
|
|
96
107
|
const wasm = wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network);
|
|
97
|
-
|
|
108
|
+
const psbt = new ZcashBitGoPsbt(wasm);
|
|
109
|
+
if (psbt.versionGroupId === exports.IRONWOOD_VERSION_GROUP_ID) {
|
|
110
|
+
throw new Error("this is a v6 (Ironwood) PSBT: use ZcashIronwoodBitGoPsbt.fromBytes instead");
|
|
111
|
+
}
|
|
112
|
+
return psbt;
|
|
98
113
|
}
|
|
99
114
|
/**
|
|
100
115
|
* Reconstruct a Zcash PSBT from a network-format transaction (unsigned, half-signed, or fully-signed).
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
|
+
import { ZcashBitGoPsbt, type ZcashNetworkName } from "./ZcashBitGoPsbt.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating an empty Zcash v6 (Ironwood) shielding PSBT.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately narrower than `CreateEmptyZcashOptions`: `version` and `versionGroupId` are fixed by
|
|
7
|
+
* the v6 format, so accepting them would only let a caller ask for something that is then ignored.
|
|
8
|
+
*/
|
|
9
|
+
export type CreateEmptyIronwoodOptions = {
|
|
10
|
+
/** Block height to determine the consensus branch ID automatically (at/after NU6.3 activation) */
|
|
11
|
+
blockHeight: number;
|
|
12
|
+
/** Lock time (default: 0) */
|
|
13
|
+
lockTime?: number;
|
|
14
|
+
/** Zcash transaction expiry height */
|
|
15
|
+
expiryHeight?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Options for creating an empty Zcash v6 (Ironwood) shielding PSBT with an explicit consensus
|
|
19
|
+
* branch ID.
|
|
20
|
+
*
|
|
21
|
+
* Like {@link CreateEmptyIronwoodOptions}, this omits `version` and `versionGroupId` — both are
|
|
22
|
+
* fixed by the v6 format. The consensus branch ID is *not* fixed: it tracks the active network
|
|
23
|
+
* upgrade, so it stays a caller-supplied parameter exactly as it is for v4.
|
|
24
|
+
*/
|
|
25
|
+
export type CreateEmptyIronwoodWithConsensusBranchIdOptions = {
|
|
26
|
+
/** Zcash consensus branch ID (e.g. the NU6.3 branch ID) */
|
|
27
|
+
consensusBranchId: number;
|
|
28
|
+
/** Lock time (default: 0) */
|
|
29
|
+
lockTime?: number;
|
|
30
|
+
/** Zcash transaction expiry height */
|
|
31
|
+
expiryHeight?: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A fresh ZIP-302 "no memo" memo field: the `0xf6` marker byte followed by 511 zero bytes. The
|
|
35
|
+
* default for {@link ZcashIronwoodBitGoPsbt.addShieldedOutput}'s `memo` option.
|
|
36
|
+
*
|
|
37
|
+
* Not the same as an all-zeros memo, which decodes as a *text* memo holding the empty string and is
|
|
38
|
+
* rendered as such by wallets. Exported so callers can pass it explicitly, and so the distinction is
|
|
39
|
+
* visible rather than buried in a default.
|
|
40
|
+
*
|
|
41
|
+
* A function rather than a shared constant: a module-level `Uint8Array` is mutable, so one caller
|
|
42
|
+
* writing into it would silently change the default memo for every later output.
|
|
43
|
+
*/
|
|
44
|
+
export declare function zip302NoMemo(): Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* A Zcash **v6 (Ironwood / NU6.3)** shielding PSBT.
|
|
47
|
+
*
|
|
48
|
+
* Distinct from the generic `ZcashBitGoPsbt` (v4/Sapling-shaped transactions): a v6 PSBT carries
|
|
49
|
+
* its shielded side as an orchard PCZT in the proprietary map rather than Sapling fields, and its
|
|
50
|
+
* lifecycle mirrors the microservice build → sign → combine flow rather than the v4 ZIP-243
|
|
51
|
+
* signing path.
|
|
52
|
+
*
|
|
53
|
+
* Method names carry no `ironwood` prefix — the class name already says it. They follow the base
|
|
54
|
+
* `BitGoPsbt` vocabulary (`createEmpty`, `fromBytes`, `addOutput`-style adders, `getId`) so the v6
|
|
55
|
+
* surface reads the same as the v4 one; the wasm bindings keep their `ironwood_v6_*` names because
|
|
56
|
+
* they live on the single flat `BitGoPsbt` struct, where the prefix is what disambiguates them.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const psbt = ZcashIronwoodBitGoPsbt.createEmpty("zcash", walletKeys, { blockHeight });
|
|
61
|
+
* psbt.addWalletInput(...);
|
|
62
|
+
* psbt.addWalletOutput(...);
|
|
63
|
+
* psbt.addShieldedOutput(recipient, amount, { anchor });
|
|
64
|
+
* const sighash = psbt.transparentSighash(0);
|
|
65
|
+
* // ... sign sighash externally, then:
|
|
66
|
+
* psbt.addTransparentSignature(0, pubkey, sig);
|
|
67
|
+
* const tx = psbt.combineProof(proof);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
71
|
+
/**
|
|
72
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT, with the consensus branch ID
|
|
73
|
+
* determined from block height.
|
|
74
|
+
*
|
|
75
|
+
* Add transparent inputs/outputs with the usual `addWalletInput` / `addWalletOutput`, the
|
|
76
|
+
* shielded output with {@link addShieldedOutput}, then sign the transparent inputs over
|
|
77
|
+
* {@link transparentSighash} and finish with {@link combineProof}.
|
|
78
|
+
*
|
|
79
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
80
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
81
|
+
* @param options - Options including blockHeight (at/after NU6.3 activation)
|
|
82
|
+
*/
|
|
83
|
+
static createEmpty(network: ZcashNetworkName, walletKeys: WalletKeysArg, options: CreateEmptyIronwoodOptions): ZcashIronwoodBitGoPsbt;
|
|
84
|
+
/**
|
|
85
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT with an explicit consensus branch ID.
|
|
86
|
+
*
|
|
87
|
+
* **Advanced use only.** Prefer {@link createEmpty}, which derives the branch ID from a block
|
|
88
|
+
* height and rejects heights before NU6.3 activation. Reach for this only when you already know
|
|
89
|
+
* the branch ID — regtest, a future upgrade, or replaying a known-good value.
|
|
90
|
+
*
|
|
91
|
+
* Only the *version group ID* is fixed by the v6 format; the consensus branch ID tracks the active
|
|
92
|
+
* network upgrade and remains caller-supplied, exactly as for v4.
|
|
93
|
+
*
|
|
94
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
95
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
96
|
+
* @param options - Options including the required consensusBranchId
|
|
97
|
+
*/
|
|
98
|
+
static createEmptyWithConsensusBranchId(network: ZcashNetworkName, walletKeys: WalletKeysArg, options: CreateEmptyIronwoodWithConsensusBranchIdOptions): ZcashIronwoodBitGoPsbt;
|
|
99
|
+
/**
|
|
100
|
+
* Not applicable to v6, and not implementable: a broadcast v6 transaction carries the shielded
|
|
101
|
+
* side as a proof plus a binding signature, while every v6 operation here needs the PCZT — which
|
|
102
|
+
* holds witness data (`rseed`, `rcv`, `alpha`, the note plaintext) that is deliberately *not*
|
|
103
|
+
* recoverable from the transaction. Decoding the transparent skeleton alone would yield a PSBT
|
|
104
|
+
* that `getId`, `transparentSighash`, `combineProof`, and even `serialize`/{@link fromBytes} all
|
|
105
|
+
* reject. Inherited only because JS statics are inherited.
|
|
106
|
+
*/
|
|
107
|
+
static fromNetworkFormat(): never;
|
|
108
|
+
/**
|
|
109
|
+
* Not applicable to v6: the legacy half-signed format is a v4-era p2ms encoding with no way to
|
|
110
|
+
* carry the PCZT, and no v6 transaction has ever been produced in it. Inherited only because JS
|
|
111
|
+
* statics are inherited.
|
|
112
|
+
*/
|
|
113
|
+
static fromHalfSignedLegacyTransaction(): never;
|
|
114
|
+
/**
|
|
115
|
+
* Deserialize a v6 (Ironwood) Zcash PSBT from bytes.
|
|
116
|
+
*
|
|
117
|
+
* @param bytes - The PSBT bytes
|
|
118
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
119
|
+
* @throws Error if the deserialized PSBT is not a v6 (Ironwood) PSBT
|
|
120
|
+
* @returns A ZcashIronwoodBitGoPsbt instance
|
|
121
|
+
*/
|
|
122
|
+
static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashIronwoodBitGoPsbt;
|
|
123
|
+
/**
|
|
124
|
+
* Add the shielded output (Constructor role). Stores the orchard PCZT in the PSBT.
|
|
125
|
+
*
|
|
126
|
+
* Named for the shielded/transparent split rather than the note type, leaving room for a
|
|
127
|
+
* transparent-output variant alongside the inherited `addOutput` / `addWalletOutput`.
|
|
128
|
+
*
|
|
129
|
+
* @param recipient - 43-byte raw Orchard/Ironwood address
|
|
130
|
+
* @param amount - note value in zatoshi
|
|
131
|
+
* @param options.anchor - 32-byte Ironwood note-commitment-tree root
|
|
132
|
+
* @param options.memo - optional 512-byte memo (defaults to the ZIP-302 "no memo" encoding)
|
|
133
|
+
* @param options.ovk - optional 32-byte outgoing viewing key (omit for a keyless build)
|
|
134
|
+
*/
|
|
135
|
+
addShieldedOutput(recipient: Uint8Array, amount: bigint, options: {
|
|
136
|
+
anchor: Uint8Array;
|
|
137
|
+
memo?: Uint8Array;
|
|
138
|
+
ovk?: Uint8Array;
|
|
139
|
+
}): void;
|
|
140
|
+
/**
|
|
141
|
+
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
142
|
+
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
143
|
+
* in place; unchanged by signing or proving.
|
|
144
|
+
*/
|
|
145
|
+
getId(): string;
|
|
146
|
+
/**
|
|
147
|
+
* The ZIP-244 per-input transparent sighash (32 bytes) the key controlling transparent input
|
|
148
|
+
* `index` must sign.
|
|
149
|
+
*/
|
|
150
|
+
transparentSighash(index: number): Uint8Array;
|
|
151
|
+
/**
|
|
152
|
+
* Ingest a transparent-input signature returned by the client/HSM, after verifying it against
|
|
153
|
+
* {@link transparentSighash} for that input.
|
|
154
|
+
*
|
|
155
|
+
* @param index - transparent input index
|
|
156
|
+
* @param pubkey - the signing public key
|
|
157
|
+
* @param sig - DER ECDSA signature with the trailing SIGHASH_ALL byte (as in a scriptSig)
|
|
158
|
+
*/
|
|
159
|
+
addTransparentSignature(index: number, pubkey: Uint8Array, sig: Uint8Array): void;
|
|
160
|
+
/**
|
|
161
|
+
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
162
|
+
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
163
|
+
* transaction bytes. Requires every transparent input to be signed via
|
|
164
|
+
* {@link addTransparentSignature}.
|
|
165
|
+
*
|
|
166
|
+
* Terminal: the wasm binding drops the stored PCZT on success, so any later v6 call on this PSBT
|
|
167
|
+
* throws — including after a `serialize`/{@link fromBytes} round-trip, since the PCZT is gone
|
|
168
|
+
* from the bytes too. Build a fresh PSBT instead. On failure nothing is dropped, so a call that
|
|
169
|
+
* errors (bad proof, unsigned input) leaves the PSBT retryable.
|
|
170
|
+
*/
|
|
171
|
+
combineProof(proof: Uint8Array): Uint8Array;
|
|
172
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZcashIronwoodBitGoPsbt = void 0;
|
|
4
|
+
exports.zip302NoMemo = zip302NoMemo;
|
|
5
|
+
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
6
|
+
const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
|
|
7
|
+
const ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
|
|
8
|
+
/**
|
|
9
|
+
* A fresh ZIP-302 "no memo" memo field: the `0xf6` marker byte followed by 511 zero bytes. The
|
|
10
|
+
* default for {@link ZcashIronwoodBitGoPsbt.addShieldedOutput}'s `memo` option.
|
|
11
|
+
*
|
|
12
|
+
* Not the same as an all-zeros memo, which decodes as a *text* memo holding the empty string and is
|
|
13
|
+
* rendered as such by wallets. Exported so callers can pass it explicitly, and so the distinction is
|
|
14
|
+
* visible rather than buried in a default.
|
|
15
|
+
*
|
|
16
|
+
* A function rather than a shared constant: a module-level `Uint8Array` is mutable, so one caller
|
|
17
|
+
* writing into it would silently change the default memo for every later output.
|
|
18
|
+
*/
|
|
19
|
+
function zip302NoMemo() {
|
|
20
|
+
const memo = new Uint8Array(512);
|
|
21
|
+
memo[0] = 0xf6;
|
|
22
|
+
return memo;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A Zcash **v6 (Ironwood / NU6.3)** shielding PSBT.
|
|
26
|
+
*
|
|
27
|
+
* Distinct from the generic `ZcashBitGoPsbt` (v4/Sapling-shaped transactions): a v6 PSBT carries
|
|
28
|
+
* its shielded side as an orchard PCZT in the proprietary map rather than Sapling fields, and its
|
|
29
|
+
* lifecycle mirrors the microservice build → sign → combine flow rather than the v4 ZIP-243
|
|
30
|
+
* signing path.
|
|
31
|
+
*
|
|
32
|
+
* Method names carry no `ironwood` prefix — the class name already says it. They follow the base
|
|
33
|
+
* `BitGoPsbt` vocabulary (`createEmpty`, `fromBytes`, `addOutput`-style adders, `getId`) so the v6
|
|
34
|
+
* surface reads the same as the v4 one; the wasm bindings keep their `ironwood_v6_*` names because
|
|
35
|
+
* they live on the single flat `BitGoPsbt` struct, where the prefix is what disambiguates them.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const psbt = ZcashIronwoodBitGoPsbt.createEmpty("zcash", walletKeys, { blockHeight });
|
|
40
|
+
* psbt.addWalletInput(...);
|
|
41
|
+
* psbt.addWalletOutput(...);
|
|
42
|
+
* psbt.addShieldedOutput(recipient, amount, { anchor });
|
|
43
|
+
* const sighash = psbt.transparentSighash(0);
|
|
44
|
+
* // ... sign sighash externally, then:
|
|
45
|
+
* psbt.addTransparentSignature(0, pubkey, sig);
|
|
46
|
+
* const tx = psbt.combineProof(proof);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt_js_1.ZcashBitGoPsbt {
|
|
50
|
+
/**
|
|
51
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT, with the consensus branch ID
|
|
52
|
+
* determined from block height.
|
|
53
|
+
*
|
|
54
|
+
* Add transparent inputs/outputs with the usual `addWalletInput` / `addWalletOutput`, the
|
|
55
|
+
* shielded output with {@link addShieldedOutput}, then sign the transparent inputs over
|
|
56
|
+
* {@link transparentSighash} and finish with {@link combineProof}.
|
|
57
|
+
*
|
|
58
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
59
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
60
|
+
* @param options - Options including blockHeight (at/after NU6.3 activation)
|
|
61
|
+
*/
|
|
62
|
+
static createEmpty(network, walletKeys, options) {
|
|
63
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
64
|
+
const wasm = wasm_utxo_js_1.BitGoPsbt.create_empty_zcash_v6_at_height(network, keys.wasm, options.blockHeight, options.lockTime, options.expiryHeight);
|
|
65
|
+
return new ZcashIronwoodBitGoPsbt(wasm);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT with an explicit consensus branch ID.
|
|
69
|
+
*
|
|
70
|
+
* **Advanced use only.** Prefer {@link createEmpty}, which derives the branch ID from a block
|
|
71
|
+
* height and rejects heights before NU6.3 activation. Reach for this only when you already know
|
|
72
|
+
* the branch ID — regtest, a future upgrade, or replaying a known-good value.
|
|
73
|
+
*
|
|
74
|
+
* Only the *version group ID* is fixed by the v6 format; the consensus branch ID tracks the active
|
|
75
|
+
* network upgrade and remains caller-supplied, exactly as for v4.
|
|
76
|
+
*
|
|
77
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
78
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
79
|
+
* @param options - Options including the required consensusBranchId
|
|
80
|
+
*/
|
|
81
|
+
static createEmptyWithConsensusBranchId(network, walletKeys, options) {
|
|
82
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
83
|
+
const wasm = wasm_utxo_js_1.BitGoPsbt.create_empty_zcash_v6(network, keys.wasm, options.consensusBranchId, options.lockTime, options.expiryHeight);
|
|
84
|
+
return new ZcashIronwoodBitGoPsbt(wasm);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Not applicable to v6, and not implementable: a broadcast v6 transaction carries the shielded
|
|
88
|
+
* side as a proof plus a binding signature, while every v6 operation here needs the PCZT — which
|
|
89
|
+
* holds witness data (`rseed`, `rcv`, `alpha`, the note plaintext) that is deliberately *not*
|
|
90
|
+
* recoverable from the transaction. Decoding the transparent skeleton alone would yield a PSBT
|
|
91
|
+
* that `getId`, `transparentSighash`, `combineProof`, and even `serialize`/{@link fromBytes} all
|
|
92
|
+
* reject. Inherited only because JS statics are inherited.
|
|
93
|
+
*/
|
|
94
|
+
static fromNetworkFormat() {
|
|
95
|
+
throw new Error("not supported for v6 (Ironwood): the PCZT witness data cannot be recovered from a broadcast " +
|
|
96
|
+
"transaction; rebuild the PSBT with createEmpty");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Not applicable to v6: the legacy half-signed format is a v4-era p2ms encoding with no way to
|
|
100
|
+
* carry the PCZT, and no v6 transaction has ever been produced in it. Inherited only because JS
|
|
101
|
+
* statics are inherited.
|
|
102
|
+
*/
|
|
103
|
+
static fromHalfSignedLegacyTransaction() {
|
|
104
|
+
throw new Error("not supported for v6 (Ironwood): the legacy half-signed format is v4-only; " +
|
|
105
|
+
"rebuild the PSBT with createEmpty");
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deserialize a v6 (Ironwood) Zcash PSBT from bytes.
|
|
109
|
+
*
|
|
110
|
+
* @param bytes - The PSBT bytes
|
|
111
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
112
|
+
* @throws Error if the deserialized PSBT is not a v6 (Ironwood) PSBT
|
|
113
|
+
* @returns A ZcashIronwoodBitGoPsbt instance
|
|
114
|
+
*/
|
|
115
|
+
static fromBytes(bytes, network) {
|
|
116
|
+
const wasm = wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network);
|
|
117
|
+
const psbt = new ZcashIronwoodBitGoPsbt(wasm);
|
|
118
|
+
if (psbt.versionGroupId !== ZcashBitGoPsbt_js_1.IRONWOOD_VERSION_GROUP_ID) {
|
|
119
|
+
throw new Error("not a v6 (Ironwood) PSBT: use ZcashBitGoPsbt.fromBytes for v4/Sapling-shaped PSBTs");
|
|
120
|
+
}
|
|
121
|
+
return psbt;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Add the shielded output (Constructor role). Stores the orchard PCZT in the PSBT.
|
|
125
|
+
*
|
|
126
|
+
* Named for the shielded/transparent split rather than the note type, leaving room for a
|
|
127
|
+
* transparent-output variant alongside the inherited `addOutput` / `addWalletOutput`.
|
|
128
|
+
*
|
|
129
|
+
* @param recipient - 43-byte raw Orchard/Ironwood address
|
|
130
|
+
* @param amount - note value in zatoshi
|
|
131
|
+
* @param options.anchor - 32-byte Ironwood note-commitment-tree root
|
|
132
|
+
* @param options.memo - optional 512-byte memo (defaults to the ZIP-302 "no memo" encoding)
|
|
133
|
+
* @param options.ovk - optional 32-byte outgoing viewing key (omit for a keyless build)
|
|
134
|
+
*/
|
|
135
|
+
addShieldedOutput(recipient, amount, options) {
|
|
136
|
+
const memo = options.memo ?? zip302NoMemo();
|
|
137
|
+
this.wasm.add_ironwood_output(recipient, amount, options.ovk, options.anchor, memo);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
141
|
+
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
142
|
+
* in place; unchanged by signing or proving.
|
|
143
|
+
*/
|
|
144
|
+
getId() {
|
|
145
|
+
return this.wasm.ironwood_v6_txid();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The ZIP-244 per-input transparent sighash (32 bytes) the key controlling transparent input
|
|
149
|
+
* `index` must sign.
|
|
150
|
+
*/
|
|
151
|
+
transparentSighash(index) {
|
|
152
|
+
return this.wasm.ironwood_v6_transparent_sighash(index);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Ingest a transparent-input signature returned by the client/HSM, after verifying it against
|
|
156
|
+
* {@link transparentSighash} for that input.
|
|
157
|
+
*
|
|
158
|
+
* @param index - transparent input index
|
|
159
|
+
* @param pubkey - the signing public key
|
|
160
|
+
* @param sig - DER ECDSA signature with the trailing SIGHASH_ALL byte (as in a scriptSig)
|
|
161
|
+
*/
|
|
162
|
+
addTransparentSignature(index, pubkey, sig) {
|
|
163
|
+
this.wasm.add_ironwood_v6_signature(index, pubkey, sig);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
167
|
+
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
168
|
+
* transaction bytes. Requires every transparent input to be signed via
|
|
169
|
+
* {@link addTransparentSignature}.
|
|
170
|
+
*
|
|
171
|
+
* Terminal: the wasm binding drops the stored PCZT on success, so any later v6 call on this PSBT
|
|
172
|
+
* throws — including after a `serialize`/{@link fromBytes} round-trip, since the PCZT is gone
|
|
173
|
+
* from the bytes too. Build a fresh PSBT instead. On failure nothing is dropped, so a call that
|
|
174
|
+
* errors (bad proof, unsigned input) leaves the PSBT retryable.
|
|
175
|
+
*/
|
|
176
|
+
combineProof(proof) {
|
|
177
|
+
return this.wasm.combine_ironwood_proof(proof);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.ZcashIronwoodBitGoPsbt = ZcashIronwoodBitGoPsbt;
|
|
@@ -8,7 +8,8 @@ export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js"
|
|
|
8
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
|
-
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
|
|
11
|
+
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, IRONWOOD_VERSION_GROUP_ID, } from "./ZcashBitGoPsbt.js";
|
|
12
|
+
export { ZcashIronwoodBitGoPsbt, zip302NoMemo, type CreateEmptyIronwoodOptions, type CreateEmptyIronwoodWithConsensusBranchIdOptions, } from "./ZcashIronwoodBitGoPsbt.js";
|
|
12
13
|
export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
|
|
13
14
|
export { ZcashV6Transaction } from "./ZcashV6Transaction.js";
|
|
14
15
|
import type { ScriptType } from "./scriptType.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.ZcashV6Transaction = exports.ZcashUnifiedAddress = exports.zip302NoMemo = exports.ZcashIronwoodBitGoPsbt = exports.IRONWOOD_VERSION_GROUP_ID = exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.requiresPrevTxForP2sh = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
4
4
|
exports.supportsScriptType = supportsScriptType;
|
|
5
5
|
exports.createOpReturnScript = createOpReturnScript;
|
|
6
6
|
exports.p2shP2pkOutputScript = p2shP2pkOutputScript;
|
|
@@ -33,6 +33,11 @@ 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
|
+
Object.defineProperty(exports, "IRONWOOD_VERSION_GROUP_ID", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.IRONWOOD_VERSION_GROUP_ID; } });
|
|
37
|
+
// Zcash v6 (Ironwood / NU6.3) shielding PSBT
|
|
38
|
+
var ZcashIronwoodBitGoPsbt_js_1 = require("./ZcashIronwoodBitGoPsbt.js");
|
|
39
|
+
Object.defineProperty(exports, "ZcashIronwoodBitGoPsbt", { enumerable: true, get: function () { return ZcashIronwoodBitGoPsbt_js_1.ZcashIronwoodBitGoPsbt; } });
|
|
40
|
+
Object.defineProperty(exports, "zip302NoMemo", { enumerable: true, get: function () { return ZcashIronwoodBitGoPsbt_js_1.zip302NoMemo; } });
|
|
36
41
|
// Zcash ZIP-316 Unified Address
|
|
37
42
|
var ZcashUnifiedAddress_js_1 = require("./ZcashUnifiedAddress.js");
|
|
38
43
|
Object.defineProperty(exports, "ZcashUnifiedAddress", { enumerable: true, get: function () { return ZcashUnifiedAddress_js_1.ZcashUnifiedAddress; } });
|
|
@@ -136,6 +136,26 @@ export class BitGoPsbt {
|
|
|
136
136
|
* The index of the newly added input
|
|
137
137
|
*/
|
|
138
138
|
add_input_at_index(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
139
|
+
/**
|
|
140
|
+
* Constructor: add the shielded Ironwood output as an orchard PCZT stored in the PSBT.
|
|
141
|
+
*
|
|
142
|
+
* * `recipient` - raw Orchard/Ironwood address ([`ORCHARD_ADDRESS_SIZE`] bytes)
|
|
143
|
+
* * `amount` - note value in zatoshi
|
|
144
|
+
* * `ovk` - optional outgoing viewing key ([`OVK_SIZE`] bytes; `None` for a keyless build)
|
|
145
|
+
* * `anchor` - Ironwood note-commitment-tree root ([`ANCHOR_SIZE`] bytes)
|
|
146
|
+
* * `memo` - ZIP-302 memo field ([`MEMO_SIZE`] bytes)
|
|
147
|
+
*
|
|
148
|
+
* [`ORCHARD_ADDRESS_SIZE`]: crate::zcash::ironwood_build::ORCHARD_ADDRESS_SIZE
|
|
149
|
+
* [`OVK_SIZE`]: crate::zcash::ironwood_build::OVK_SIZE
|
|
150
|
+
* [`ANCHOR_SIZE`]: crate::zcash::ironwood_build::ANCHOR_SIZE
|
|
151
|
+
* [`MEMO_SIZE`]: crate::zcash::ironwood_build::MEMO_SIZE
|
|
152
|
+
*/
|
|
153
|
+
add_ironwood_output(recipient: Uint8Array, amount: bigint, ovk: Uint8Array | null | undefined, anchor: Uint8Array, memo: Uint8Array): void;
|
|
154
|
+
/**
|
|
155
|
+
* Ingest a transparent-input signature (`sig`: DER ECDSA with the trailing SIGHASH_ALL byte)
|
|
156
|
+
* after verifying it against `ironwood_v6_transparent_sighash(index)`.
|
|
157
|
+
*/
|
|
158
|
+
add_ironwood_v6_signature(index: number, pubkey: Uint8Array, sig: Uint8Array): void;
|
|
139
159
|
add_output(script: Uint8Array, value: bigint): number;
|
|
140
160
|
add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
|
|
141
161
|
add_output_with_address(address: string, value: bigint): number;
|
|
@@ -170,6 +190,17 @@ export class BitGoPsbt {
|
|
|
170
190
|
* Returns error if PSBT parsing fails or input counts don't match
|
|
171
191
|
*/
|
|
172
192
|
combine_inputs(other_bytes: Uint8Array): void;
|
|
193
|
+
/**
|
|
194
|
+
* Transaction Extractor: given the external prover's `proof` bytes, finalize the transparent
|
|
195
|
+
* inputs, apply the shielded binding signature, and return the broadcast-ready v6 transaction
|
|
196
|
+
* bytes. Requires the transparent inputs to be signed (via `add_ironwood_v6_signature`).
|
|
197
|
+
*
|
|
198
|
+
* Terminal: on success the stored PCZT is dropped, so a second call — or any other Ironwood
|
|
199
|
+
* operation, including after a `serialize`/`from_bytes` round-trip — fails rather than silently
|
|
200
|
+
* re-running against already-extracted state. Build a fresh PSBT instead. On failure nothing is
|
|
201
|
+
* dropped, so a call that errors (bad proof, unsigned input) leaves the PSBT retryable.
|
|
202
|
+
*/
|
|
203
|
+
combine_ironwood_proof(proof: Uint8Array): Uint8Array;
|
|
173
204
|
/**
|
|
174
205
|
* Combine/merge data from another PSBT into this one
|
|
175
206
|
*
|
|
@@ -236,6 +267,23 @@ export class BitGoPsbt {
|
|
|
236
267
|
* Returns error if block height is before Overwinter activation
|
|
237
268
|
*/
|
|
238
269
|
static create_empty_zcash_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
270
|
+
/**
|
|
271
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT with an explicit consensus branch id.
|
|
272
|
+
*
|
|
273
|
+
* The version group id is fixed by the v6 format, but the consensus branch id tracks the active
|
|
274
|
+
* network upgrade and stays caller-supplied — the v6 analogue of `create_empty_zcash`. Prefer
|
|
275
|
+
* `create_empty_zcash_v6_at_height`, which derives it from a block height and rejects heights
|
|
276
|
+
* before NU6.3 activation; this is the escape hatch for callers that already know the value.
|
|
277
|
+
*/
|
|
278
|
+
static create_empty_zcash_v6(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, lock_time?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
279
|
+
/**
|
|
280
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT, with the consensus branch id
|
|
281
|
+
* resolved from `block_height`. Transparent inputs/outputs are added with the usual
|
|
282
|
+
* `add_wallet_input` / `add_wallet_output`; the shielded output and the v6 sign/combine
|
|
283
|
+
* steps use the dedicated `add_ironwood_output` / `ironwood_v6_*` / `combine_ironwood_proof`
|
|
284
|
+
* methods.
|
|
285
|
+
*/
|
|
286
|
+
static create_empty_zcash_v6_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, lock_time?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
239
287
|
delete_input_kv(index: number, key: any): void;
|
|
240
288
|
delete_kv(key: any): void;
|
|
241
289
|
delete_output_kv(index: number, key: any): void;
|
|
@@ -426,6 +474,16 @@ export class BitGoPsbt {
|
|
|
426
474
|
*/
|
|
427
475
|
get_unsigned_tx(): Uint8Array;
|
|
428
476
|
input_count(): number;
|
|
477
|
+
/**
|
|
478
|
+
* The ZIP-244 per-input transparent sighash (32 bytes) that the key controlling transparent
|
|
479
|
+
* input `index` must sign.
|
|
480
|
+
*/
|
|
481
|
+
ironwood_v6_transparent_sighash(index: number): Uint8Array;
|
|
482
|
+
/**
|
|
483
|
+
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching the
|
|
484
|
+
* `getId()` convention used elsewhere (see [`crate::wasm::zcash::ZcashV6Transaction::get_id`]).
|
|
485
|
+
*/
|
|
486
|
+
ironwood_v6_txid(): string;
|
|
429
487
|
/**
|
|
430
488
|
* Check if an input is a MuSig2 keypath input.
|
|
431
489
|
*
|
|
@@ -1761,3 +1819,12 @@ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
|
|
|
1761
1819
|
* with `.message` and `.code`), not a bare string.
|
|
1762
1820
|
*/
|
|
1763
1821
|
export function zcash_branch_id_for_height(network: string, height: number): number | undefined;
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* The Zcash v6 (Ironwood / NU6.3) version group id.
|
|
1825
|
+
*
|
|
1826
|
+
* Exported so the TypeScript layer can derive its `IRONWOOD_VERSION_GROUP_ID` from the Rust
|
|
1827
|
+
* constant instead of hard-coding a second copy: the two are used together to tell v6 PSBTs from
|
|
1828
|
+
* v4/Sapling ones, and a silent divergence would route v6 bytes down the v4 path.
|
|
1829
|
+
*/
|
|
1830
|
+
export function zcash_ironwood_version_group_id(): number;
|