@bitgo/wasm-utxo 1.18.0 → 1.19.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.
@@ -86,8 +86,13 @@ export type AddWalletOutputOptions = {
86
86
  value: bigint;
87
87
  };
88
88
  export declare class BitGoPsbt {
89
- protected wasm: WasmBitGoPsbt;
90
- protected constructor(wasm: WasmBitGoPsbt);
89
+ protected _wasm: WasmBitGoPsbt;
90
+ protected constructor(_wasm: WasmBitGoPsbt);
91
+ /**
92
+ * Get the underlying WASM instance
93
+ * @internal - for use by other wasm-utxo modules
94
+ */
95
+ get wasm(): WasmBitGoPsbt;
91
96
  /**
92
97
  * Create an empty PSBT for the given network with wallet keys
93
98
  *
@@ -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,7 +75,7 @@ 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
80
  /**
74
81
  * Add an output to the PSBT
@@ -85,7 +92,7 @@ class BitGoPsbt {
85
92
  * ```
86
93
  */
87
94
  addOutput(options) {
88
- return this.wasm.add_output(options.script, options.value);
95
+ return this._wasm.add_output(options.script, options.value);
89
96
  }
90
97
  /**
91
98
  * Add a wallet input with full PSBT metadata
@@ -128,7 +135,7 @@ class BitGoPsbt {
128
135
  */
129
136
  addWalletInput(inputOptions, walletKeys, walletOptions) {
130
137
  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);
138
+ 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
139
  }
133
140
  /**
134
141
  * Add a wallet output with full PSBT metadata
@@ -162,7 +169,7 @@ class BitGoPsbt {
162
169
  */
163
170
  addWalletOutput(walletKeys, options) {
164
171
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
165
- return this.wasm.add_wallet_output(options.chain, options.index, options.value, keys.wasm);
172
+ return this._wasm.add_wallet_output(options.chain, options.index, options.value, keys.wasm);
166
173
  }
167
174
  /**
168
175
  * Add a replay protection input to the PSBT
@@ -185,28 +192,28 @@ class BitGoPsbt {
185
192
  */
186
193
  addReplayProtectionInput(inputOptions, key) {
187
194
  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);
195
+ return this._wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence);
189
196
  }
190
197
  /**
191
198
  * Get the unsigned transaction ID
192
199
  * @returns The unsigned transaction ID
193
200
  */
194
201
  unsignedTxid() {
195
- return this.wasm.unsigned_txid();
202
+ return this._wasm.unsigned_txid();
196
203
  }
197
204
  /**
198
205
  * Get the transaction version
199
206
  * @returns The transaction version number
200
207
  */
201
208
  get version() {
202
- return this.wasm.version();
209
+ return this._wasm.version();
203
210
  }
204
211
  /**
205
212
  * Get the transaction lock time
206
213
  * @returns The transaction lock time
207
214
  */
208
215
  get lockTime() {
209
- return this.wasm.lock_time();
216
+ return this._wasm.lock_time();
210
217
  }
211
218
  /**
212
219
  * Parse transaction with wallet keys to identify wallet inputs/outputs
@@ -217,9 +224,9 @@ class BitGoPsbt {
217
224
  */
218
225
  parseTransactionWithWalletKeys(walletKeys, replayProtection, payGoPubkeys) {
219
226
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
220
- const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this.wasm.network());
227
+ const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this._wasm.network());
221
228
  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);
229
+ return this._wasm.parse_transaction_with_wallet_keys(keys.wasm, rp.wasm, pubkeys);
223
230
  }
224
231
  /**
225
232
  * Parse outputs with wallet keys to identify which outputs belong to a wallet
@@ -236,7 +243,7 @@ class BitGoPsbt {
236
243
  parseOutputsWithWalletKeys(walletKeys, payGoPubkeys) {
237
244
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
238
245
  const pubkeys = payGoPubkeys?.map((arg) => ecpair_js_1.ECPair.from(arg).wasm);
239
- return this.wasm.parse_outputs_with_wallet_keys(keys.wasm, pubkeys);
246
+ return this._wasm.parse_outputs_with_wallet_keys(keys.wasm, pubkeys);
240
247
  }
241
248
  /**
242
249
  * Add a PayGo attestation to a PSBT output
@@ -250,7 +257,7 @@ class BitGoPsbt {
250
257
  * @throws Error if output index is out of bounds or entropy is not 64 bytes
251
258
  */
252
259
  addPayGoAttestation(outputIndex, entropy, signature) {
253
- this.wasm.add_paygo_attestation(outputIndex, entropy, signature);
260
+ this._wasm.add_paygo_attestation(outputIndex, entropy, signature);
254
261
  }
255
262
  /**
256
263
  * Verify if a valid signature exists for a given key at the specified input index.
@@ -291,11 +298,11 @@ class BitGoPsbt {
291
298
  // Try to parse as BIP32Arg first (string or BIP32 instance)
292
299
  if (typeof key === "string" || ("derive" in key && typeof key.derive === "function")) {
293
300
  const wasmKey = bip32_js_1.BIP32.from(key).wasm;
294
- return this.wasm.verify_signature_with_xpub(inputIndex, wasmKey);
301
+ return this._wasm.verify_signature_with_xpub(inputIndex, wasmKey);
295
302
  }
296
303
  // Otherwise it's an ECPairArg (Uint8Array, ECPair, or WasmECPair)
297
304
  const wasmECPair = ecpair_js_1.ECPair.from(key).wasm;
298
- return this.wasm.verify_signature_with_pub(inputIndex, wasmECPair);
305
+ return this._wasm.verify_signature_with_pub(inputIndex, wasmECPair);
299
306
  }
300
307
  /**
301
308
  * Sign a single input with a private key
@@ -347,12 +354,12 @@ class BitGoPsbt {
347
354
  typeof key.derive === "function")) {
348
355
  // It's a BIP32Arg
349
356
  const wasmKey = bip32_js_1.BIP32.from(key);
350
- this.wasm.sign_with_xpriv(inputIndex, wasmKey.wasm);
357
+ this._wasm.sign_with_xpriv(inputIndex, wasmKey.wasm);
351
358
  }
352
359
  else {
353
360
  // It's an ECPairArg
354
361
  const wasmKey = ecpair_js_1.ECPair.from(key);
355
- this.wasm.sign_with_privkey(inputIndex, wasmKey.wasm);
362
+ this._wasm.sign_with_privkey(inputIndex, wasmKey.wasm);
356
363
  }
357
364
  }
358
365
  /**
@@ -376,8 +383,8 @@ class BitGoPsbt {
376
383
  * @throws Error if the input is not a replay protection input, index is out of bounds, or scripts are invalid
377
384
  */
378
385
  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);
386
+ const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this._wasm.network());
387
+ return this._wasm.verify_replay_protection_signature(inputIndex, rp.wasm);
381
388
  }
382
389
  /**
383
390
  * Serialize the PSBT to bytes
@@ -385,7 +392,7 @@ class BitGoPsbt {
385
392
  * @returns The serialized PSBT as a byte array
386
393
  */
387
394
  serialize() {
388
- return this.wasm.serialize();
395
+ return this._wasm.serialize();
389
396
  }
390
397
  /**
391
398
  * Generate and store MuSig2 nonces for all MuSig2 inputs
@@ -427,7 +434,7 @@ class BitGoPsbt {
427
434
  */
428
435
  generateMusig2Nonces(key, sessionId) {
429
436
  const wasmKey = bip32_js_1.BIP32.from(key);
430
- this.wasm.generate_musig2_nonces(wasmKey.wasm, sessionId);
437
+ this._wasm.generate_musig2_nonces(wasmKey.wasm, sessionId);
431
438
  }
432
439
  /**
433
440
  * Combine/merge data from another PSBT into this one
@@ -449,7 +456,7 @@ class BitGoPsbt {
449
456
  * ```
450
457
  */
451
458
  combineMusig2Nonces(sourcePsbt) {
452
- this.wasm.combine_musig2_nonces(sourcePsbt.wasm);
459
+ this._wasm.combine_musig2_nonces(sourcePsbt.wasm);
453
460
  }
454
461
  /**
455
462
  * Finalize all inputs in the PSBT
@@ -457,7 +464,7 @@ class BitGoPsbt {
457
464
  * @throws Error if any input failed to finalize
458
465
  */
459
466
  finalizeAllInputs() {
460
- this.wasm.finalize_all_inputs();
467
+ this._wasm.finalize_all_inputs();
461
468
  }
462
469
  /**
463
470
  * Extract the final transaction from a finalized PSBT
@@ -466,7 +473,7 @@ class BitGoPsbt {
466
473
  * @throws Error if the PSBT is not fully finalized or extraction fails
467
474
  */
468
475
  extractTransaction() {
469
- return this.wasm.extract_transaction();
476
+ return this._wasm.extract_transaction();
470
477
  }
471
478
  }
472
479
  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
  */
@@ -502,6 +502,67 @@ export class WasmDashTransaction {
502
502
  to_bytes(): Uint8Array;
503
503
  }
504
504
 
505
+ export class WasmDimensions {
506
+ private constructor();
507
+ free(): void;
508
+ [Symbol.dispose](): void;
509
+ /**
510
+ * Create dimensions for a single input from chain code
511
+ *
512
+ * # Arguments
513
+ * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
514
+ * * `signer` - Optional signer key ("user", "backup", "bitgo")
515
+ * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
516
+ */
517
+ static from_input(chain: number, signer?: string | null, cosigner?: string | null): WasmDimensions;
518
+ /**
519
+ * Get total weight (min or max)
520
+ *
521
+ * # Arguments
522
+ * * `size` - "min" or "max", defaults to "max"
523
+ */
524
+ get_weight(size?: string | null): number;
525
+ /**
526
+ * Whether any inputs are segwit (affects overhead calculation)
527
+ */
528
+ has_segwit(): boolean;
529
+ /**
530
+ * Create dimensions for a single output from script bytes
531
+ */
532
+ static from_output_script(script: Uint8Array): WasmDimensions;
533
+ /**
534
+ * Create dimensions for a single input from script type string
535
+ *
536
+ * # Arguments
537
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
538
+ * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
539
+ */
540
+ static from_input_script_type(script_type: string): WasmDimensions;
541
+ /**
542
+ * Combine with another Dimensions instance
543
+ */
544
+ plus(other: WasmDimensions): WasmDimensions;
545
+ /**
546
+ * Create empty dimensions (zero weight)
547
+ */
548
+ static empty(): WasmDimensions;
549
+ /**
550
+ * Create dimensions from a BitGoPsbt
551
+ *
552
+ * Parses PSBT inputs and outputs to compute weight bounds without
553
+ * requiring wallet keys. Input types are detected from BIP32 derivation
554
+ * paths stored in the PSBT.
555
+ */
556
+ static from_psbt(psbt: BitGoPsbt): WasmDimensions;
557
+ /**
558
+ * Get virtual size (min or max)
559
+ *
560
+ * # Arguments
561
+ * * `size` - "min" or "max", defaults to "max"
562
+ */
563
+ get_vsize(size?: string | null): number;
564
+ }
565
+
505
566
  export class WasmECPair {
506
567
  private constructor();
507
568
  free(): void;
@@ -629,6 +690,16 @@ export class WasmTransaction {
629
690
  * The serialized transaction bytes
630
691
  */
631
692
  to_bytes(): Uint8Array;
693
+ /**
694
+ * Get the virtual size of the transaction
695
+ *
696
+ * Virtual size is calculated as ceil(weight / 4), where weight accounts
697
+ * for the segwit discount on witness data.
698
+ *
699
+ * # Returns
700
+ * The virtual size in virtual bytes (vbytes)
701
+ */
702
+ get_vsize(): number;
632
703
  }
633
704
 
634
705
  export class WasmZcashTransaction {