@bitgo/wasm-utxo 1.18.0 → 1.20.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.
@@ -57,10 +57,13 @@ export type AddInputOptions = {
57
57
  prevTx?: Uint8Array;
58
58
  };
59
59
  export type AddOutputOptions = {
60
- /** Output script (scriptPubKey) */
61
60
  script: Uint8Array;
62
61
  /** Value in satoshis */
63
62
  value: bigint;
63
+ } | {
64
+ address: string;
65
+ /** Value in satoshis */
66
+ value: bigint;
64
67
  };
65
68
  /** Key identifier for signing ("user", "backup", or "bitgo") */
66
69
  export type SignerKey = "user" | "backup" | "bitgo";
@@ -86,8 +89,13 @@ export type AddWalletOutputOptions = {
86
89
  value: bigint;
87
90
  };
88
91
  export declare class BitGoPsbt {
89
- protected wasm: WasmBitGoPsbt;
90
- protected constructor(wasm: WasmBitGoPsbt);
92
+ protected _wasm: WasmBitGoPsbt;
93
+ protected constructor(_wasm: WasmBitGoPsbt);
94
+ /**
95
+ * Get the underlying WASM instance
96
+ * @internal - for use by other wasm-utxo modules
97
+ */
98
+ get wasm(): WasmBitGoPsbt;
91
99
  /**
92
100
  * Create an empty PSBT for the given network with wallet keys
93
101
  *
@@ -141,15 +149,48 @@ export declare class BitGoPsbt {
141
149
  /**
142
150
  * Add an output to the PSBT
143
151
  *
144
- * @param options - Output options (script, value)
152
+ * @param script - The output script (scriptPubKey)
153
+ * @param value - Value in satoshis
154
+ * @returns The index of the newly added output
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const outputIndex = psbt.addOutput(outputScript, 50000n);
159
+ * ```
160
+ */
161
+ addOutput(script: Uint8Array, value: bigint): number;
162
+ /**
163
+ * Add an output to the PSBT by address
164
+ *
165
+ * @param address - The destination address
166
+ * @param value - Value in satoshis
167
+ * @returns The index of the newly added output
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const outputIndex = psbt.addOutput("bc1q...", 50000n);
172
+ * ```
173
+ */
174
+ addOutput(address: string, value: bigint): number;
175
+ /**
176
+ * Add an output to the PSBT
177
+ *
178
+ * @param options - Output options (script or address, and value)
145
179
  * @returns The index of the newly added output
146
180
  *
147
181
  * @example
148
182
  * ```typescript
183
+ * // Using script
149
184
  * const outputIndex = psbt.addOutput({
150
185
  * script: outputScript,
151
186
  * value: 50000n,
152
187
  * });
188
+ *
189
+ * // Using address
190
+ * const outputIndex = psbt.addOutput({
191
+ * address: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
192
+ * value: 50000n,
193
+ * });
153
194
  * ```
154
195
  */
155
196
  addOutput(options: AddOutputOptions): number;
@@ -7,9 +7,16 @@ const ReplayProtection_js_1 = require("./ReplayProtection.js");
7
7
  const bip32_js_1 = require("../bip32.js");
8
8
  const ecpair_js_1 = require("../ecpair.js");
9
9
  class BitGoPsbt {
10
- wasm;
11
- constructor(wasm) {
12
- this.wasm = wasm;
10
+ _wasm;
11
+ constructor(_wasm) {
12
+ this._wasm = _wasm;
13
+ }
14
+ /**
15
+ * Get the underlying WASM instance
16
+ * @internal - for use by other wasm-utxo modules
17
+ */
18
+ get wasm() {
19
+ return this._wasm;
13
20
  }
14
21
  /**
15
22
  * Create an empty PSBT for the given network with wallet keys
@@ -35,8 +42,8 @@ class BitGoPsbt {
35
42
  */
36
43
  static createEmpty(network, walletKeys, options) {
37
44
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
38
- const wasm = wasm_utxo_js_1.BitGoPsbt.create_empty(network, keys.wasm, options?.version, options?.lockTime);
39
- return new BitGoPsbt(wasm);
45
+ const wasmPsbt = wasm_utxo_js_1.BitGoPsbt.create_empty(network, keys.wasm, options?.version, options?.lockTime);
46
+ return new BitGoPsbt(wasmPsbt);
40
47
  }
41
48
  /**
42
49
  * Deserialize a PSBT from bytes
@@ -68,24 +75,26 @@ class BitGoPsbt {
68
75
  * ```
69
76
  */
70
77
  addInput(options, script) {
71
- return this.wasm.add_input(options.txid, options.vout, options.value, script, options.sequence, options.prevTx);
78
+ return this._wasm.add_input(options.txid, options.vout, options.value, script, options.sequence, options.prevTx);
72
79
  }
73
- /**
74
- * Add an output to the PSBT
75
- *
76
- * @param options - Output options (script, value)
77
- * @returns The index of the newly added output
78
- *
79
- * @example
80
- * ```typescript
81
- * const outputIndex = psbt.addOutput({
82
- * script: outputScript,
83
- * value: 50000n,
84
- * });
85
- * ```
86
- */
87
- addOutput(options) {
88
- return this.wasm.add_output(options.script, options.value);
80
+ addOutput(scriptOrOptions, value) {
81
+ if (scriptOrOptions instanceof Uint8Array || typeof scriptOrOptions === "string") {
82
+ if (value === undefined) {
83
+ throw new Error("Value is required when passing a script or address");
84
+ }
85
+ if (scriptOrOptions instanceof Uint8Array) {
86
+ return this._wasm.add_output(scriptOrOptions, value);
87
+ }
88
+ return this._wasm.add_output_with_address(scriptOrOptions, value);
89
+ }
90
+ const options = scriptOrOptions;
91
+ if ("script" in options) {
92
+ return this._wasm.add_output(options.script, options.value);
93
+ }
94
+ if ("address" in options) {
95
+ return this._wasm.add_output_with_address(options.address, options.value);
96
+ }
97
+ throw new Error("Invalid output options");
89
98
  }
90
99
  /**
91
100
  * Add a wallet input with full PSBT metadata
@@ -128,7 +137,7 @@ class BitGoPsbt {
128
137
  */
129
138
  addWalletInput(inputOptions, walletKeys, walletOptions) {
130
139
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
131
- return this.wasm.add_wallet_input(inputOptions.txid, inputOptions.vout, inputOptions.value, keys.wasm, walletOptions.scriptId.chain, walletOptions.scriptId.index, walletOptions.signPath?.signer, walletOptions.signPath?.cosigner, inputOptions.sequence, inputOptions.prevTx);
140
+ return this._wasm.add_wallet_input(inputOptions.txid, inputOptions.vout, inputOptions.value, keys.wasm, walletOptions.scriptId.chain, walletOptions.scriptId.index, walletOptions.signPath?.signer, walletOptions.signPath?.cosigner, inputOptions.sequence, inputOptions.prevTx);
132
141
  }
133
142
  /**
134
143
  * Add a wallet output with full PSBT metadata
@@ -162,7 +171,7 @@ class BitGoPsbt {
162
171
  */
163
172
  addWalletOutput(walletKeys, options) {
164
173
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
165
- return this.wasm.add_wallet_output(options.chain, options.index, options.value, keys.wasm);
174
+ return this._wasm.add_wallet_output(options.chain, options.index, options.value, keys.wasm);
166
175
  }
167
176
  /**
168
177
  * Add a replay protection input to the PSBT
@@ -185,28 +194,28 @@ class BitGoPsbt {
185
194
  */
186
195
  addReplayProtectionInput(inputOptions, key) {
187
196
  const ecpair = ecpair_js_1.ECPair.from(key);
188
- return this.wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence);
197
+ return this._wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence);
189
198
  }
190
199
  /**
191
200
  * Get the unsigned transaction ID
192
201
  * @returns The unsigned transaction ID
193
202
  */
194
203
  unsignedTxid() {
195
- return this.wasm.unsigned_txid();
204
+ return this._wasm.unsigned_txid();
196
205
  }
197
206
  /**
198
207
  * Get the transaction version
199
208
  * @returns The transaction version number
200
209
  */
201
210
  get version() {
202
- return this.wasm.version();
211
+ return this._wasm.version();
203
212
  }
204
213
  /**
205
214
  * Get the transaction lock time
206
215
  * @returns The transaction lock time
207
216
  */
208
217
  get lockTime() {
209
- return this.wasm.lock_time();
218
+ return this._wasm.lock_time();
210
219
  }
211
220
  /**
212
221
  * Parse transaction with wallet keys to identify wallet inputs/outputs
@@ -217,9 +226,9 @@ class BitGoPsbt {
217
226
  */
218
227
  parseTransactionWithWalletKeys(walletKeys, replayProtection, payGoPubkeys) {
219
228
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
220
- const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this.wasm.network());
229
+ const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this._wasm.network());
221
230
  const pubkeys = payGoPubkeys?.map((arg) => ecpair_js_1.ECPair.from(arg).wasm);
222
- return this.wasm.parse_transaction_with_wallet_keys(keys.wasm, rp.wasm, pubkeys);
231
+ return this._wasm.parse_transaction_with_wallet_keys(keys.wasm, rp.wasm, pubkeys);
223
232
  }
224
233
  /**
225
234
  * Parse outputs with wallet keys to identify which outputs belong to a wallet
@@ -236,7 +245,7 @@ class BitGoPsbt {
236
245
  parseOutputsWithWalletKeys(walletKeys, payGoPubkeys) {
237
246
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
238
247
  const pubkeys = payGoPubkeys?.map((arg) => ecpair_js_1.ECPair.from(arg).wasm);
239
- return this.wasm.parse_outputs_with_wallet_keys(keys.wasm, pubkeys);
248
+ return this._wasm.parse_outputs_with_wallet_keys(keys.wasm, pubkeys);
240
249
  }
241
250
  /**
242
251
  * Add a PayGo attestation to a PSBT output
@@ -250,7 +259,7 @@ class BitGoPsbt {
250
259
  * @throws Error if output index is out of bounds or entropy is not 64 bytes
251
260
  */
252
261
  addPayGoAttestation(outputIndex, entropy, signature) {
253
- this.wasm.add_paygo_attestation(outputIndex, entropy, signature);
262
+ this._wasm.add_paygo_attestation(outputIndex, entropy, signature);
254
263
  }
255
264
  /**
256
265
  * Verify if a valid signature exists for a given key at the specified input index.
@@ -291,11 +300,11 @@ class BitGoPsbt {
291
300
  // Try to parse as BIP32Arg first (string or BIP32 instance)
292
301
  if (typeof key === "string" || ("derive" in key && typeof key.derive === "function")) {
293
302
  const wasmKey = bip32_js_1.BIP32.from(key).wasm;
294
- return this.wasm.verify_signature_with_xpub(inputIndex, wasmKey);
303
+ return this._wasm.verify_signature_with_xpub(inputIndex, wasmKey);
295
304
  }
296
305
  // Otherwise it's an ECPairArg (Uint8Array, ECPair, or WasmECPair)
297
306
  const wasmECPair = ecpair_js_1.ECPair.from(key).wasm;
298
- return this.wasm.verify_signature_with_pub(inputIndex, wasmECPair);
307
+ return this._wasm.verify_signature_with_pub(inputIndex, wasmECPair);
299
308
  }
300
309
  /**
301
310
  * Sign a single input with a private key
@@ -347,12 +356,12 @@ class BitGoPsbt {
347
356
  typeof key.derive === "function")) {
348
357
  // It's a BIP32Arg
349
358
  const wasmKey = bip32_js_1.BIP32.from(key);
350
- this.wasm.sign_with_xpriv(inputIndex, wasmKey.wasm);
359
+ this._wasm.sign_with_xpriv(inputIndex, wasmKey.wasm);
351
360
  }
352
361
  else {
353
362
  // It's an ECPairArg
354
363
  const wasmKey = ecpair_js_1.ECPair.from(key);
355
- this.wasm.sign_with_privkey(inputIndex, wasmKey.wasm);
364
+ this._wasm.sign_with_privkey(inputIndex, wasmKey.wasm);
356
365
  }
357
366
  }
358
367
  /**
@@ -376,8 +385,8 @@ class BitGoPsbt {
376
385
  * @throws Error if the input is not a replay protection input, index is out of bounds, or scripts are invalid
377
386
  */
378
387
  verifyReplayProtectionSignature(inputIndex, replayProtection) {
379
- const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this.wasm.network());
380
- return this.wasm.verify_replay_protection_signature(inputIndex, rp.wasm);
388
+ const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this._wasm.network());
389
+ return this._wasm.verify_replay_protection_signature(inputIndex, rp.wasm);
381
390
  }
382
391
  /**
383
392
  * Serialize the PSBT to bytes
@@ -385,7 +394,7 @@ class BitGoPsbt {
385
394
  * @returns The serialized PSBT as a byte array
386
395
  */
387
396
  serialize() {
388
- return this.wasm.serialize();
397
+ return this._wasm.serialize();
389
398
  }
390
399
  /**
391
400
  * Generate and store MuSig2 nonces for all MuSig2 inputs
@@ -427,7 +436,7 @@ class BitGoPsbt {
427
436
  */
428
437
  generateMusig2Nonces(key, sessionId) {
429
438
  const wasmKey = bip32_js_1.BIP32.from(key);
430
- this.wasm.generate_musig2_nonces(wasmKey.wasm, sessionId);
439
+ this._wasm.generate_musig2_nonces(wasmKey.wasm, sessionId);
431
440
  }
432
441
  /**
433
442
  * Combine/merge data from another PSBT into this one
@@ -449,7 +458,7 @@ class BitGoPsbt {
449
458
  * ```
450
459
  */
451
460
  combineMusig2Nonces(sourcePsbt) {
452
- this.wasm.combine_musig2_nonces(sourcePsbt.wasm);
461
+ this._wasm.combine_musig2_nonces(sourcePsbt.wasm);
453
462
  }
454
463
  /**
455
464
  * Finalize all inputs in the PSBT
@@ -457,7 +466,7 @@ class BitGoPsbt {
457
466
  * @throws Error if any input failed to finalize
458
467
  */
459
468
  finalizeAllInputs() {
460
- this.wasm.finalize_all_inputs();
469
+ this._wasm.finalize_all_inputs();
461
470
  }
462
471
  /**
463
472
  * Extract the final transaction from a finalized PSBT
@@ -466,7 +475,7 @@ class BitGoPsbt {
466
475
  * @throws Error if the PSBT is not fully finalized or extraction fails
467
476
  */
468
477
  extractTransaction() {
469
- return this.wasm.extract_transaction();
478
+ return this._wasm.extract_transaction();
470
479
  }
471
480
  }
472
481
  exports.BitGoPsbt = BitGoPsbt;
@@ -0,0 +1,65 @@
1
+ import type { BitGoPsbt, InputScriptType, SignPath } from "./BitGoPsbt.js";
2
+ import type { CoinName } from "../coinName.js";
3
+ type FromInputParams = {
4
+ chain: number;
5
+ signPath?: SignPath;
6
+ } | {
7
+ scriptType: InputScriptType;
8
+ };
9
+ /**
10
+ * Dimensions class for estimating transaction virtual size.
11
+ *
12
+ * Tracks weight internally with min/max bounds to handle ECDSA signature variance.
13
+ * Schnorr signatures have no variance (always 64 bytes).
14
+ *
15
+ * This is a thin wrapper over the WASM implementation.
16
+ */
17
+ export declare class Dimensions {
18
+ private _wasm;
19
+ private constructor();
20
+ /**
21
+ * Create empty dimensions (zero weight)
22
+ */
23
+ static empty(): Dimensions;
24
+ /**
25
+ * Create dimensions from a BitGoPsbt
26
+ *
27
+ * Parses PSBT inputs and outputs to compute weight bounds without
28
+ * requiring wallet keys. Input types are detected from BIP32 derivation
29
+ * paths stored in the PSBT.
30
+ */
31
+ static fromPsbt(psbt: BitGoPsbt): Dimensions;
32
+ /**
33
+ * Create dimensions for a single input
34
+ *
35
+ * @param params - Either `{ chain, signPath? }` or `{ scriptType }`
36
+ */
37
+ static fromInput(params: FromInputParams): Dimensions;
38
+ /**
39
+ * Create dimensions for a single output from script bytes
40
+ */
41
+ static fromOutput(script: Uint8Array): Dimensions;
42
+ /**
43
+ * Create dimensions for a single output from an address
44
+ */
45
+ static fromOutput(address: string, network: CoinName): Dimensions;
46
+ /**
47
+ * Combine with another Dimensions instance
48
+ */
49
+ plus(other: Dimensions): Dimensions;
50
+ /**
51
+ * Whether any inputs are segwit (affects overhead calculation)
52
+ */
53
+ get hasSegwit(): boolean;
54
+ /**
55
+ * Get total weight (min or max)
56
+ * @param size - "min" or "max", defaults to "max"
57
+ */
58
+ getWeight(size?: "min" | "max"): number;
59
+ /**
60
+ * Get virtual size (min or max)
61
+ * @param size - "min" or "max", defaults to "max"
62
+ */
63
+ getVSize(size?: "min" | "max"): number;
64
+ }
65
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dimensions = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ const address_js_1 = require("../address.js");
6
+ /**
7
+ * Dimensions class for estimating transaction virtual size.
8
+ *
9
+ * Tracks weight internally with min/max bounds to handle ECDSA signature variance.
10
+ * Schnorr signatures have no variance (always 64 bytes).
11
+ *
12
+ * This is a thin wrapper over the WASM implementation.
13
+ */
14
+ class Dimensions {
15
+ _wasm;
16
+ constructor(_wasm) {
17
+ this._wasm = _wasm;
18
+ }
19
+ /**
20
+ * Create empty dimensions (zero weight)
21
+ */
22
+ static empty() {
23
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.empty());
24
+ }
25
+ /**
26
+ * Create dimensions from a BitGoPsbt
27
+ *
28
+ * Parses PSBT inputs and outputs to compute weight bounds without
29
+ * requiring wallet keys. Input types are detected from BIP32 derivation
30
+ * paths stored in the PSBT.
31
+ */
32
+ static fromPsbt(psbt) {
33
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_psbt(psbt.wasm));
34
+ }
35
+ /**
36
+ * Create dimensions for a single input
37
+ *
38
+ * @param params - Either `{ chain, signPath? }` or `{ scriptType }`
39
+ */
40
+ static fromInput(params) {
41
+ if ("scriptType" in params) {
42
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input_script_type(params.scriptType));
43
+ }
44
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
45
+ }
46
+ static fromOutput(scriptOrAddress, network) {
47
+ if (typeof scriptOrAddress === "string") {
48
+ if (network === undefined) {
49
+ throw new Error("network is required when passing an address string");
50
+ }
51
+ const script = (0, address_js_1.toOutputScriptWithCoin)(scriptOrAddress, network);
52
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script(script));
53
+ }
54
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script(scriptOrAddress));
55
+ }
56
+ /**
57
+ * Combine with another Dimensions instance
58
+ */
59
+ plus(other) {
60
+ return new Dimensions(this._wasm.plus(other._wasm));
61
+ }
62
+ /**
63
+ * Whether any inputs are segwit (affects overhead calculation)
64
+ */
65
+ get hasSegwit() {
66
+ return this._wasm.has_segwit();
67
+ }
68
+ /**
69
+ * Get total weight (min or max)
70
+ * @param size - "min" or "max", defaults to "max"
71
+ */
72
+ getWeight(size = "max") {
73
+ return this._wasm.get_weight(size);
74
+ }
75
+ /**
76
+ * Get virtual size (min or max)
77
+ * @param size - "min" or "max", defaults to "max"
78
+ */
79
+ getVSize(size = "max") {
80
+ return this._wasm.get_vsize(size);
81
+ }
82
+ }
83
+ exports.Dimensions = Dimensions;
@@ -1,5 +1,6 @@
1
1
  export { RootWalletKeys, type WalletKeysArg, type IWalletKeys } from "./RootWalletKeys.js";
2
2
  export { ReplayProtection, type ReplayProtectionArg } from "./ReplayProtection.js";
3
3
  export { outputScript, address } from "./address.js";
4
+ export { Dimensions } from "./Dimensions.js";
4
5
  export { BitGoPsbt, type NetworkName, type ScriptId, type InputScriptType, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, } from "./BitGoPsbt.js";
5
6
  export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
3
+ exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
4
4
  var RootWalletKeys_js_1 = require("./RootWalletKeys.js");
5
5
  Object.defineProperty(exports, "RootWalletKeys", { enumerable: true, get: function () { return RootWalletKeys_js_1.RootWalletKeys; } });
6
6
  var ReplayProtection_js_1 = require("./ReplayProtection.js");
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "ReplayProtection", { enumerable: true, get: func
8
8
  var address_js_1 = require("./address.js");
9
9
  Object.defineProperty(exports, "outputScript", { enumerable: true, get: function () { return address_js_1.outputScript; } });
10
10
  Object.defineProperty(exports, "address", { enumerable: true, get: function () { return address_js_1.address; } });
11
+ var Dimensions_js_1 = require("./Dimensions.js");
12
+ Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
11
13
  // Bitcoin-like PSBT (for all non-Zcash networks)
12
14
  var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
13
15
  Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
@@ -6,6 +6,7 @@ export * as bip32 from "./bip32.js";
6
6
  export * as ecpair from "./ecpair.js";
7
7
  export { ECPair } from "./ecpair.js";
8
8
  export { BIP32 } from "./bip32.js";
9
+ export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
9
10
  export type { CoinName } from "./coinName.js";
10
11
  export type { Triple } from "./triple.js";
11
12
  export type { AddressFormat } from "./address.js";
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.ast = exports.address = void 0;
36
+ exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.ast = exports.address = void 0;
37
37
  const wasm = __importStar(require("./wasm/wasm_utxo.js"));
38
38
  // we need to access the wasm module here, otherwise webpack gets all weird
39
39
  // and forgets to include it in the bundle
@@ -51,6 +51,8 @@ var ecpair_js_1 = require("./ecpair.js");
51
51
  Object.defineProperty(exports, "ECPair", { enumerable: true, get: function () { return ecpair_js_1.ECPair; } });
52
52
  var bip32_js_1 = require("./bip32.js");
53
53
  Object.defineProperty(exports, "BIP32", { enumerable: true, get: function () { return bip32_js_1.BIP32; } });
54
+ var Dimensions_js_1 = require("./fixedScriptWallet/Dimensions.js");
55
+ Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
54
56
  var wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
55
57
  Object.defineProperty(exports, "Descriptor", { enumerable: true, get: function () { return wasm_utxo_js_1.WrapDescriptor; } });
56
58
  var wasm_utxo_js_2 = require("./wasm/wasm_utxo.js");
@@ -9,6 +9,14 @@ export declare class Transaction {
9
9
  private constructor();
10
10
  static fromBytes(bytes: Uint8Array): Transaction;
11
11
  toBytes(): Uint8Array;
12
+ /**
13
+ * Get the virtual size of the transaction
14
+ *
15
+ * Virtual size accounts for the segwit discount on witness data.
16
+ *
17
+ * @returns The virtual size in virtual bytes (vbytes)
18
+ */
19
+ getVSize(): number;
12
20
  /**
13
21
  * @internal
14
22
  */
@@ -18,6 +18,16 @@ class Transaction {
18
18
  toBytes() {
19
19
  return this._wasm.to_bytes();
20
20
  }
21
+ /**
22
+ * Get the virtual size of the transaction
23
+ *
24
+ * Virtual size accounts for the segwit discount on witness data.
25
+ *
26
+ * @returns The virtual size in virtual bytes (vbytes)
27
+ */
28
+ getVSize() {
29
+ return this._wasm.get_vsize();
30
+ }
21
31
  /**
22
32
  * @internal
23
33
  */
@@ -225,6 +225,17 @@ export class BitGoPsbt {
225
225
  * generated for security. Custom session_id is only allowed on testnets for testing purposes.
226
226
  */
227
227
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
228
+ /**
229
+ * Add an output to the PSBT by address
230
+ *
231
+ * # Arguments
232
+ * * `address` - The destination address
233
+ * * `value` - The value in satoshis
234
+ *
235
+ * # Returns
236
+ * The index of the newly added output
237
+ */
238
+ add_output_with_address(address: string, value: bigint): number;
228
239
  /**
229
240
  * Verify if a valid signature exists for a given ECPair key at the specified input index
230
241
  *
@@ -502,6 +513,67 @@ export class WasmDashTransaction {
502
513
  to_bytes(): Uint8Array;
503
514
  }
504
515
 
516
+ export class WasmDimensions {
517
+ private constructor();
518
+ free(): void;
519
+ [Symbol.dispose](): void;
520
+ /**
521
+ * Create dimensions for a single input from chain code
522
+ *
523
+ * # Arguments
524
+ * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
525
+ * * `signer` - Optional signer key ("user", "backup", "bitgo")
526
+ * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
527
+ */
528
+ static from_input(chain: number, signer?: string | null, cosigner?: string | null): WasmDimensions;
529
+ /**
530
+ * Get total weight (min or max)
531
+ *
532
+ * # Arguments
533
+ * * `size` - "min" or "max", defaults to "max"
534
+ */
535
+ get_weight(size?: string | null): number;
536
+ /**
537
+ * Whether any inputs are segwit (affects overhead calculation)
538
+ */
539
+ has_segwit(): boolean;
540
+ /**
541
+ * Create dimensions for a single output from script bytes
542
+ */
543
+ static from_output_script(script: Uint8Array): WasmDimensions;
544
+ /**
545
+ * Create dimensions for a single input from script type string
546
+ *
547
+ * # Arguments
548
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
549
+ * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
550
+ */
551
+ static from_input_script_type(script_type: string): WasmDimensions;
552
+ /**
553
+ * Combine with another Dimensions instance
554
+ */
555
+ plus(other: WasmDimensions): WasmDimensions;
556
+ /**
557
+ * Create empty dimensions (zero weight)
558
+ */
559
+ static empty(): WasmDimensions;
560
+ /**
561
+ * Create dimensions from a BitGoPsbt
562
+ *
563
+ * Parses PSBT inputs and outputs to compute weight bounds without
564
+ * requiring wallet keys. Input types are detected from BIP32 derivation
565
+ * paths stored in the PSBT.
566
+ */
567
+ static from_psbt(psbt: BitGoPsbt): WasmDimensions;
568
+ /**
569
+ * Get virtual size (min or max)
570
+ *
571
+ * # Arguments
572
+ * * `size` - "min" or "max", defaults to "max"
573
+ */
574
+ get_vsize(size?: string | null): number;
575
+ }
576
+
505
577
  export class WasmECPair {
506
578
  private constructor();
507
579
  free(): void;
@@ -629,6 +701,16 @@ export class WasmTransaction {
629
701
  * The serialized transaction bytes
630
702
  */
631
703
  to_bytes(): Uint8Array;
704
+ /**
705
+ * Get the virtual size of the transaction
706
+ *
707
+ * Virtual size is calculated as ceil(weight / 4), where weight accounts
708
+ * for the segwit discount on witness data.
709
+ *
710
+ * # Returns
711
+ * The virtual size in virtual bytes (vbytes)
712
+ */
713
+ get_vsize(): number;
632
714
  }
633
715
 
634
716
  export class WasmZcashTransaction {