@bitgo/wasm-utxo 4.31.0 → 4.33.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 +233 -0
- package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +227 -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 +98 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +296 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +62 -52
- 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 +233 -0
- package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +222 -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 +98 -0
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +295 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +62 -52
- package/package.json +1 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { BitGoPsbt as WasmBitGoPsbt } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { BIP32, isBIP32Arg } from "../bip32.js";
|
|
3
|
+
import { RootWalletKeys } from "./RootWalletKeys.js";
|
|
4
|
+
import { IRONWOOD_VERSION_GROUP_ID, ZcashBitGoPsbt, } from "./ZcashBitGoPsbt.js";
|
|
5
|
+
/**
|
|
6
|
+
* A fresh ZIP-302 "no memo" memo field: the `0xf6` marker byte followed by 511 zero bytes. The
|
|
7
|
+
* default for {@link ZcashIronwoodBitGoPsbt.addShieldedOutput}'s `memo` option.
|
|
8
|
+
*
|
|
9
|
+
* Not the same as an all-zeros memo, which decodes as a *text* memo holding the empty string and is
|
|
10
|
+
* rendered as such by wallets. Exported so callers can pass it explicitly, and so the distinction is
|
|
11
|
+
* visible rather than buried in a default.
|
|
12
|
+
*
|
|
13
|
+
* A function rather than a shared constant: a module-level `Uint8Array` is mutable, so one caller
|
|
14
|
+
* writing into it would silently change the default memo for every later output.
|
|
15
|
+
*/
|
|
16
|
+
export function zip302NoMemo() {
|
|
17
|
+
const memo = new Uint8Array(512);
|
|
18
|
+
memo[0] = 0xf6;
|
|
19
|
+
return memo;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A Zcash **v6 (Ironwood / NU6.3)** shielding PSBT.
|
|
23
|
+
*
|
|
24
|
+
* Distinct from the generic `ZcashBitGoPsbt` (v4/Sapling-shaped transactions): a v6 PSBT carries
|
|
25
|
+
* its shielded side as an orchard PCZT in the proprietary map rather than Sapling fields, and its
|
|
26
|
+
* lifecycle mirrors the microservice build → sign → combine flow rather than the v4 ZIP-243
|
|
27
|
+
* signing path.
|
|
28
|
+
*
|
|
29
|
+
* Method names carry no `ironwood` prefix — the class name already says it. They follow the base
|
|
30
|
+
* `BitGoPsbt` vocabulary (`createEmpty`, `fromBytes`, `addOutput`-style adders, `getId`) so the v6
|
|
31
|
+
* surface reads the same as the v4 one; the wasm bindings keep their `ironwood_v6_*` names because
|
|
32
|
+
* they live on the single flat `BitGoPsbt` struct, where the prefix is what disambiguates them.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const psbt = ZcashIronwoodBitGoPsbt.createEmpty("zcash", walletKeys, { blockHeight });
|
|
37
|
+
* psbt.addWalletInput(...);
|
|
38
|
+
* psbt.addWalletOutput(...);
|
|
39
|
+
* psbt.addShieldedOutput(recipient, amount, { anchor });
|
|
40
|
+
* const sighash = psbt.transparentSighash(0);
|
|
41
|
+
* // ... sign sighash externally, then:
|
|
42
|
+
* psbt.addTransparentSignature(0, pubkey, sig);
|
|
43
|
+
* const tx = psbt.combineProof(proof);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
|
|
47
|
+
/**
|
|
48
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT, with the consensus branch ID
|
|
49
|
+
* determined from block height.
|
|
50
|
+
*
|
|
51
|
+
* Add transparent inputs/outputs with the usual `addWalletInput` / `addWalletOutput`, the
|
|
52
|
+
* shielded output with {@link addShieldedOutput}, then sign the transparent inputs over
|
|
53
|
+
* {@link transparentSighash} and finish with {@link combineProof}.
|
|
54
|
+
*
|
|
55
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
56
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
57
|
+
* @param options - Options including blockHeight (at/after NU6.3 activation)
|
|
58
|
+
*/
|
|
59
|
+
static createEmpty(network, walletKeys, options) {
|
|
60
|
+
const keys = RootWalletKeys.from(walletKeys);
|
|
61
|
+
const wasm = WasmBitGoPsbt.create_empty_zcash_v6_at_height(network, keys.wasm, options.blockHeight, options.lockTime, options.expiryHeight);
|
|
62
|
+
return new ZcashIronwoodBitGoPsbt(wasm);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create an empty Zcash **v6 (Ironwood)** shielding PSBT with an explicit consensus branch ID.
|
|
66
|
+
*
|
|
67
|
+
* **Advanced use only.** Prefer {@link createEmpty}, which derives the branch ID from a block
|
|
68
|
+
* height and rejects heights before NU6.3 activation. Reach for this only when you already know
|
|
69
|
+
* the branch ID — regtest, a future upgrade, or replaying a known-good value.
|
|
70
|
+
*
|
|
71
|
+
* Only the *version group ID* is fixed by the v6 format; the consensus branch ID tracks the active
|
|
72
|
+
* network upgrade and remains caller-supplied, exactly as for v4.
|
|
73
|
+
*
|
|
74
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
75
|
+
* @param walletKeys - The wallet's root keys (sets global xpubs in the PSBT)
|
|
76
|
+
* @param options - Options including the required consensusBranchId
|
|
77
|
+
*/
|
|
78
|
+
static createEmptyWithConsensusBranchId(network, walletKeys, options) {
|
|
79
|
+
const keys = RootWalletKeys.from(walletKeys);
|
|
80
|
+
const wasm = WasmBitGoPsbt.create_empty_zcash_v6(network, keys.wasm, options.consensusBranchId, options.lockTime, options.expiryHeight);
|
|
81
|
+
return new ZcashIronwoodBitGoPsbt(wasm);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Not applicable to v6, and not implementable: a broadcast v6 transaction carries the shielded
|
|
85
|
+
* side as a proof plus a binding signature, while every v6 operation here needs the PCZT — which
|
|
86
|
+
* holds witness data (`rseed`, `rcv`, `alpha`, the note plaintext) that is deliberately *not*
|
|
87
|
+
* recoverable from the transaction. Decoding the transparent skeleton alone would yield a PSBT
|
|
88
|
+
* that `getId`, `transparentSighash`, `combineProof`, and even `serialize`/{@link fromBytes} all
|
|
89
|
+
* reject. Inherited only because JS statics are inherited.
|
|
90
|
+
*/
|
|
91
|
+
static fromNetworkFormat() {
|
|
92
|
+
throw new Error("not supported for v6 (Ironwood): the PCZT witness data cannot be recovered from a broadcast " +
|
|
93
|
+
"transaction; rebuild the PSBT with createEmpty");
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Not applicable to v6: the legacy half-signed format is a v4-era p2ms encoding with no way to
|
|
97
|
+
* carry the PCZT, and no v6 transaction has ever been produced in it. Inherited only because JS
|
|
98
|
+
* statics are inherited.
|
|
99
|
+
*/
|
|
100
|
+
static fromHalfSignedLegacyTransaction() {
|
|
101
|
+
throw new Error("not supported for v6 (Ironwood): the legacy half-signed format is v4-only; " +
|
|
102
|
+
"rebuild the PSBT with createEmpty");
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Deserialize a v6 (Ironwood) Zcash PSBT from bytes.
|
|
106
|
+
*
|
|
107
|
+
* @param bytes - The PSBT bytes
|
|
108
|
+
* @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
|
|
109
|
+
* @throws Error if the deserialized PSBT is not a v6 (Ironwood) PSBT
|
|
110
|
+
* @returns A ZcashIronwoodBitGoPsbt instance
|
|
111
|
+
*/
|
|
112
|
+
static fromBytes(bytes, network) {
|
|
113
|
+
const wasm = WasmBitGoPsbt.from_bytes(bytes, network);
|
|
114
|
+
const psbt = new ZcashIronwoodBitGoPsbt(wasm);
|
|
115
|
+
if (psbt.versionGroupId !== IRONWOOD_VERSION_GROUP_ID) {
|
|
116
|
+
throw new Error("not a v6 (Ironwood) PSBT: use ZcashBitGoPsbt.fromBytes for v4/Sapling-shaped PSBTs");
|
|
117
|
+
}
|
|
118
|
+
return psbt;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Add the shielded output (Constructor role). Stores the orchard PCZT in the PSBT.
|
|
122
|
+
*
|
|
123
|
+
* Named for the shielded/transparent split rather than the note type, leaving room for a
|
|
124
|
+
* transparent-output variant alongside the inherited `addOutput` / `addWalletOutput`.
|
|
125
|
+
*
|
|
126
|
+
* @param recipient - 43-byte raw Orchard/Ironwood address
|
|
127
|
+
* @param amount - note value in zatoshi
|
|
128
|
+
* @param options.anchor - 32-byte Ironwood note-commitment-tree root
|
|
129
|
+
* @param options.memo - optional 512-byte memo (defaults to the ZIP-302 "no memo" encoding)
|
|
130
|
+
* @param options.ovk - optional 32-byte outgoing viewing key (omit for a keyless build)
|
|
131
|
+
*/
|
|
132
|
+
addShieldedOutput(recipient, amount, options) {
|
|
133
|
+
const memo = options.memo ?? zip302NoMemo();
|
|
134
|
+
this.wasm.add_ironwood_output(recipient, amount, options.ovk, options.anchor, memo);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
|
|
138
|
+
* `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
|
|
139
|
+
* keys, so the `ovk` does not depend on which inputs the transaction spends, and the server can
|
|
140
|
+
* re-derive the identical value from its own private key plus the user's public key in order to
|
|
141
|
+
* validate `out_ciphertext` before countersigning. The server never sees `userKey` or the `ovk`.
|
|
142
|
+
*
|
|
143
|
+
* `userKey` must be the wallet's user root key — passing the backup or BitGo key throws, since an
|
|
144
|
+
* `ovk` derived from those is one neither the user nor the server can reproduce, and the resulting
|
|
145
|
+
* transaction would broadcast fine while leaving the shielded output permanently unrecoverable.
|
|
146
|
+
*
|
|
147
|
+
* Normally you do not call this directly: {@link sign} performs it on the first signing round.
|
|
148
|
+
*
|
|
149
|
+
* Must be called **before** signing: `out_ciphertext` is committed by the ZIP-244 sighash, so
|
|
150
|
+
* calling this after any transparent signature has been added (via
|
|
151
|
+
* {@link addTransparentSignature}) throws rather than silently invalidating that signature.
|
|
152
|
+
*
|
|
153
|
+
* @param actionIndex - index of the Ironwood action whose output to re-encrypt (always `0`: only
|
|
154
|
+
* one shielded output per transaction is supported, see {@link addShieldedOutput})
|
|
155
|
+
* @param userKey - the wallet's user root key (an xpriv)
|
|
156
|
+
* @param rootWalletKeys - the wallet's root keys, supplying the BitGo cosigner pubkey
|
|
157
|
+
*/
|
|
158
|
+
setShieldedOutCiphertext(actionIndex, userKey, rootWalletKeys) {
|
|
159
|
+
this.wasm.set_ironwood_out_ciphertext(actionIndex, BIP32.from(userKey).wasm, RootWalletKeys.from(rootWalletKeys).wasm);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The canonical (display-order) ZIP-244 v6 txid as a lowercase hex string, matching
|
|
163
|
+
* `ITransaction.getId()`. Defined once the transparent inputs/outputs and the shielded output are
|
|
164
|
+
* in place; unchanged by signing or proving.
|
|
165
|
+
*/
|
|
166
|
+
getId() {
|
|
167
|
+
return this.wasm.ironwood_v6_txid();
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The ZIP-244 per-input transparent sighash (32 bytes) the key controlling transparent input
|
|
171
|
+
* `index` must sign.
|
|
172
|
+
*/
|
|
173
|
+
transparentSighash(index) {
|
|
174
|
+
return this.wasm.ironwood_v6_transparent_sighash(index);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Ingest a transparent-input signature returned by the client/HSM, after verifying it against
|
|
178
|
+
* {@link transparentSighash} for that input.
|
|
179
|
+
*
|
|
180
|
+
* @param index - transparent input index
|
|
181
|
+
* @param pubkey - the signing public key
|
|
182
|
+
* @param sig - DER ECDSA signature with the trailing SIGHASH_ALL byte (as in a scriptSig)
|
|
183
|
+
*/
|
|
184
|
+
addTransparentSignature(index, pubkey, sig) {
|
|
185
|
+
this.wasm.add_ironwood_v6_signature(index, pubkey, sig);
|
|
186
|
+
}
|
|
187
|
+
// The second parameter is `WalletKeysArg` in the public (first) overload above — the only form
|
|
188
|
+
// callers see. It widens here solely to stay assignable to the deprecated `(inputIndex, key)`
|
|
189
|
+
// overload, whose own second parameter is a key; narrowing it to `WalletKeysArg` is TS2394.
|
|
190
|
+
sign(keyOrIndex, keyOrRootWalletKeys) {
|
|
191
|
+
if (typeof keyOrIndex === "number") {
|
|
192
|
+
throw new Error("not supported for v6 (Ironwood): single-input sign(inputIndex, key) has no ZIP-244 " +
|
|
193
|
+
"equivalent; use sign(key) to sign all matching inputs");
|
|
194
|
+
}
|
|
195
|
+
if (!isBIP32Arg(keyOrIndex)) {
|
|
196
|
+
throw new Error("not supported for v6 (Ironwood): a raw privkey (ECPairArg) has no bip32_derivation path " +
|
|
197
|
+
"to resolve out_ciphertext's ovk from; pass an xpriv");
|
|
198
|
+
}
|
|
199
|
+
if (keyOrRootWalletKeys === undefined) {
|
|
200
|
+
throw new Error("rootWalletKeys is required for v6 (Ironwood) signing: sign(key, rootWalletKeys) — pass it " +
|
|
201
|
+
"on every signing round, even Bitgo's, so the client-managed-ovk step is never silently " +
|
|
202
|
+
"skipped");
|
|
203
|
+
}
|
|
204
|
+
const wasmKey = BIP32.from(keyOrIndex).wasm;
|
|
205
|
+
const keys = RootWalletKeys.from(keyOrRootWalletKeys);
|
|
206
|
+
return Array.from(this.wasm.sign_ironwood_v6(wasmKey, keys.wasm), Number);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Transaction Extractor role: given the external prover's `proof` bytes, finalize the
|
|
210
|
+
* transparent inputs, apply the shielded binding signature, and return the broadcast-ready v6
|
|
211
|
+
* transaction bytes. Requires every transparent input to be signed via
|
|
212
|
+
* {@link addTransparentSignature}.
|
|
213
|
+
*
|
|
214
|
+
* Terminal: the wasm binding drops the stored PCZT on success, so any later v6 call on this PSBT
|
|
215
|
+
* throws — including after a `serialize`/{@link fromBytes} round-trip, since the PCZT is gone
|
|
216
|
+
* from the bytes too. Build a fresh PSBT instead. On failure nothing is dropped, so a call that
|
|
217
|
+
* errors (bad proof, unsigned input) leaves the PSBT retryable.
|
|
218
|
+
*/
|
|
219
|
+
combineProof(proof) {
|
|
220
|
+
return this.wasm.combine_ironwood_proof(proof);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -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";
|
|
@@ -11,7 +11,9 @@ export { requiresPrevTxForP2sh } from "./prevTx.js";
|
|
|
11
11
|
export { BitGoPsbt, getWalletKeysFromPsbt, } from "./BitGoPsbt.js";
|
|
12
12
|
export { BitGoKeySubtype } from "./BitGoKeySubtype.js";
|
|
13
13
|
// Zcash-specific PSBT subclass
|
|
14
|
-
export { ZcashBitGoPsbt, } from "./ZcashBitGoPsbt.js";
|
|
14
|
+
export { ZcashBitGoPsbt, IRONWOOD_VERSION_GROUP_ID, } from "./ZcashBitGoPsbt.js";
|
|
15
|
+
// Zcash v6 (Ironwood / NU6.3) shielding PSBT
|
|
16
|
+
export { ZcashIronwoodBitGoPsbt, zip302NoMemo, } from "./ZcashIronwoodBitGoPsbt.js";
|
|
15
17
|
// Zcash ZIP-316 Unified Address
|
|
16
18
|
export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
|
|
17
19
|
// Zcash v6 (Ironwood / NU6.3) transaction
|
|
@@ -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
|
*
|
|
@@ -466,6 +524,21 @@ export class BitGoPsbt {
|
|
|
466
524
|
*/
|
|
467
525
|
serialize(): Uint8Array;
|
|
468
526
|
set_input_kv(index: number, key: any, value: Uint8Array): void;
|
|
527
|
+
/**
|
|
528
|
+
* Client-managed `ovk`: re-encrypt the Ironwood output's `out_ciphertext` under this wallet's
|
|
529
|
+
* `ovk`, derived as the ECDH agreement of `root_wallet_keys.bitgo_key()` and `user_xpriv` — two
|
|
530
|
+
* root keys, so the result is transaction-independent and the server can re-derive the identical
|
|
531
|
+
* `ovk` from its own privkey plus the user's pubkey in order to validate `out_ciphertext`. The
|
|
532
|
+
* server never sees `user_xpriv` or the `ovk` itself.
|
|
533
|
+
*
|
|
534
|
+
* `user_xpriv` must be the wallet's user root key; any other key is rejected, since an `ovk`
|
|
535
|
+
* derived from it is one neither the user nor the server can reproduce.
|
|
536
|
+
*
|
|
537
|
+
* Must be called before signing: `out_ciphertext` is ZIP-244 sighash-committed, so calling this
|
|
538
|
+
* after any transparent signature has been collected for the PSBT is rejected (it would
|
|
539
|
+
* silently invalidate that signature).
|
|
540
|
+
*/
|
|
541
|
+
set_ironwood_out_ciphertext(action_index: number, user_xpriv: WasmBIP32, root_wallet_keys: WasmRootWalletKeys): void;
|
|
469
542
|
set_kv(key: any, value: Uint8Array): void;
|
|
470
543
|
set_output_kv(index: number, key: any, value: Uint8Array): void;
|
|
471
544
|
/**
|
|
@@ -535,6 +608,22 @@ export class BitGoPsbt {
|
|
|
535
608
|
* - `Err(WasmUtxoError)` if signing fails
|
|
536
609
|
*/
|
|
537
610
|
sign_all_with_xpriv(xpriv: WasmBIP32): any;
|
|
611
|
+
/**
|
|
612
|
+
* Sign every transparent input `xpriv` resolves a key for, over the ZIP-244 transparent
|
|
613
|
+
* sighash — the v6 (Ironwood) counterpart to `sign_all_wallet_inputs`, which rejects v6 PSBTs
|
|
614
|
+
* (it only knows the ZIP-243 digest).
|
|
615
|
+
*
|
|
616
|
+
* If no transparent signature has been collected yet, this is the first signing round and
|
|
617
|
+
* `xpriv` must be the wallet's user root key: it is used with `root_wallet_keys.bitgo_key()` to
|
|
618
|
+
* derive this wallet's `ovk` and finalize `out_ciphertext` before computing any sighash (it is
|
|
619
|
+
* sighash-committed). Any other key signing first is rejected, rather than deriving an `ovk`
|
|
620
|
+
* nobody can reproduce. Once a signature exists, the step is skipped and any key may sign — so
|
|
621
|
+
* callers pass `root_wallet_keys` unconditionally on every signing round without needing to know
|
|
622
|
+
* which key is signing; it is mandatory precisely so the step can never be skipped by omission.
|
|
623
|
+
*
|
|
624
|
+
* Returns the indices of the transparent inputs that were signed.
|
|
625
|
+
*/
|
|
626
|
+
sign_ironwood_v6(xpriv: WasmBIP32, root_wallet_keys: WasmRootWalletKeys): Uint32Array;
|
|
538
627
|
/**
|
|
539
628
|
* Sign a single MuSig2 keypath input.
|
|
540
629
|
*
|
|
@@ -1761,3 +1850,12 @@ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
|
|
|
1761
1850
|
* with `.message` and `.code`), not a bare string.
|
|
1762
1851
|
*/
|
|
1763
1852
|
export function zcash_branch_id_for_height(network: string, height: number): number | undefined;
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* The Zcash v6 (Ironwood / NU6.3) version group id.
|
|
1856
|
+
*
|
|
1857
|
+
* Exported so the TypeScript layer can derive its `IRONWOOD_VERSION_GROUP_ID` from the Rust
|
|
1858
|
+
* constant instead of hard-coding a second copy: the two are used together to tell v6 PSBTs from
|
|
1859
|
+
* v4/Sapling ones, and a silent divergence would route v6 bytes down the v4 path.
|
|
1860
|
+
*/
|
|
1861
|
+
export function zcash_ironwood_version_group_id(): number;
|
|
@@ -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
|
|
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
|
|
9
9
|
} from "./wasm_utxo_bg.js";
|