@bitgo/wasm-utxo 4.0.2 → 4.2.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.
Files changed (44) hide show
  1. package/dist/cjs/js/descriptorWallet/Psbt.d.ts +3 -15
  2. package/dist/cjs/js/descriptorWallet/Psbt.js +3 -41
  3. package/dist/cjs/js/fixedScriptWallet/BitGoKeySubtype.d.ts +37 -0
  4. package/dist/cjs/js/fixedScriptWallet/BitGoKeySubtype.js +5 -0
  5. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +7 -52
  6. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +4 -75
  7. package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -1
  8. package/dist/cjs/js/fixedScriptWallet/index.js +3 -1
  9. package/dist/cjs/js/index.d.ts +5 -0
  10. package/dist/cjs/js/index.js +8 -3
  11. package/dist/cjs/js/psbt.d.ts +7 -0
  12. package/dist/cjs/js/psbtBase.d.ts +44 -0
  13. package/dist/cjs/js/psbtBase.js +62 -0
  14. package/dist/cjs/js/transaction.d.ts +6 -58
  15. package/dist/cjs/js/transaction.js +10 -117
  16. package/dist/cjs/js/transactionBase.d.ts +28 -0
  17. package/dist/cjs/js/transactionBase.js +37 -0
  18. package/dist/cjs/js/wasm/wasm_utxo.d.ts +31 -4
  19. package/dist/cjs/js/wasm/wasm_utxo.js +333 -13
  20. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  21. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +148 -133
  22. package/dist/esm/js/descriptorWallet/Psbt.d.ts +3 -15
  23. package/dist/esm/js/descriptorWallet/Psbt.js +3 -41
  24. package/dist/esm/js/fixedScriptWallet/BitGoKeySubtype.d.ts +37 -0
  25. package/dist/esm/js/fixedScriptWallet/BitGoKeySubtype.js +2 -0
  26. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +7 -52
  27. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +4 -75
  28. package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -1
  29. package/dist/esm/js/fixedScriptWallet/index.js +1 -0
  30. package/dist/esm/js/index.d.ts +5 -0
  31. package/dist/esm/js/index.js +4 -0
  32. package/dist/esm/js/psbt.d.ts +7 -0
  33. package/dist/esm/js/psbtBase.d.ts +44 -0
  34. package/dist/esm/js/psbtBase.js +58 -0
  35. package/dist/esm/js/transaction.d.ts +6 -58
  36. package/dist/esm/js/transaction.js +11 -118
  37. package/dist/esm/js/transactionBase.d.ts +28 -0
  38. package/dist/esm/js/transactionBase.js +33 -0
  39. package/dist/esm/js/wasm/wasm_utxo.d.ts +31 -4
  40. package/dist/esm/js/wasm/wasm_utxo.js +1 -1
  41. package/dist/esm/js/wasm/wasm_utxo_bg.js +332 -13
  42. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  43. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +148 -133
  44. package/package.json +1 -1
@@ -1,5 +1,7 @@
1
- import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction, type TxInputData, type TxOutputData, type TxOutputDataWithAddress } from "./wasm/wasm_utxo.js";
1
+ import { WasmDashTransaction, WasmTransaction, WasmZcashTransaction } from "./wasm/wasm_utxo.js";
2
+ import type { TxInputData, TxOutputData, TxOutputDataWithAddress } from "./wasm/wasm_utxo.js";
2
3
  import type { CoinName } from "./coinName.js";
4
+ import { TransactionBase } from "./transactionBase.js";
3
5
  /** Common read-only interface shared by transactions and PSBTs */
4
6
  export interface ITransactionCommon<TInput, TOutput> {
5
7
  inputCount(): number;
@@ -20,8 +22,7 @@ export interface ITransaction extends ITransactionCommon<TxInputData, TxOutputDa
20
22
  *
21
23
  * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
22
24
  */
23
- export declare class Transaction implements ITransaction {
24
- private _wasm;
25
+ export declare class Transaction extends TransactionBase<WasmTransaction> {
25
26
  private constructor();
26
27
  /**
27
28
  * Create an empty transaction (version 1, locktime 0)
@@ -41,16 +42,6 @@ export declare class Transaction implements ITransaction {
41
42
  addInput(txid: string, vout: number, sequence?: number): number;
42
43
  addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
43
44
  addOutput(script: Uint8Array, value: bigint): number;
44
- toBytes(): Uint8Array;
45
- /**
46
- * Get the transaction ID (txid)
47
- *
48
- * The txid is the double SHA256 of the transaction bytes (excluding witness
49
- * data for segwit transactions), displayed in reverse byte order as is standard.
50
- *
51
- * @returns The transaction ID as a hex string
52
- */
53
- getId(): string;
54
45
  /**
55
46
  * Get the virtual size of the transaction
56
47
  *
@@ -59,13 +50,6 @@ export declare class Transaction implements ITransaction {
59
50
  * @returns The virtual size in virtual bytes (vbytes)
60
51
  */
61
52
  getVSize(): number;
62
- inputCount(): number;
63
- outputCount(): number;
64
- version(): number;
65
- lockTime(): number;
66
- getInputs(): TxInputData[];
67
- getOutputs(): TxOutputData[];
68
- getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
69
53
  /** @internal */
70
54
  get wasm(): WasmTransaction;
71
55
  }
@@ -74,29 +58,11 @@ export declare class Transaction implements ITransaction {
74
58
  *
75
59
  * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
76
60
  */
77
- export declare class ZcashTransaction implements ITransaction {
78
- private _wasm;
61
+ export declare class ZcashTransaction extends TransactionBase<WasmZcashTransaction> {
79
62
  private constructor();
80
63
  static fromBytes(bytes: Uint8Array): ZcashTransaction;
81
64
  /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
82
65
  static fromWasm(wasm: WasmZcashTransaction): ZcashTransaction;
83
- toBytes(): Uint8Array;
84
- /**
85
- * Get the transaction ID (txid)
86
- *
87
- * The txid is the double SHA256 of the full Zcash transaction bytes,
88
- * displayed in reverse byte order as is standard.
89
- *
90
- * @returns The transaction ID as a hex string
91
- */
92
- getId(): string;
93
- inputCount(): number;
94
- outputCount(): number;
95
- version(): number;
96
- lockTime(): number;
97
- getInputs(): TxInputData[];
98
- getOutputs(): TxOutputData[];
99
- getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
100
66
  /** @internal */
101
67
  get wasm(): WasmZcashTransaction;
102
68
  }
@@ -105,29 +71,11 @@ export declare class ZcashTransaction implements ITransaction {
105
71
  *
106
72
  * Round-trip only: bytes -> parse -> bytes.
107
73
  */
108
- export declare class DashTransaction implements ITransaction {
109
- private _wasm;
74
+ export declare class DashTransaction extends TransactionBase<WasmDashTransaction> {
110
75
  private constructor();
111
76
  static fromBytes(bytes: Uint8Array): DashTransaction;
112
77
  /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
113
78
  static fromWasm(wasm: WasmDashTransaction): DashTransaction;
114
- toBytes(): Uint8Array;
115
- /**
116
- * Get the transaction ID (txid)
117
- *
118
- * The txid is the double SHA256 of the full Dash transaction bytes,
119
- * displayed in reverse byte order as is standard.
120
- *
121
- * @returns The transaction ID as a hex string
122
- */
123
- getId(): string;
124
- inputCount(): number;
125
- outputCount(): number;
126
- version(): number;
127
- lockTime(): number;
128
- getInputs(): TxInputData[];
129
- getOutputs(): TxOutputData[];
130
- getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
131
79
  /** @internal */
132
80
  get wasm(): WasmDashTransaction;
133
81
  }
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DashTransaction = exports.ZcashTransaction = exports.Transaction = void 0;
4
4
  const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
5
+ const transactionBase_js_1 = require("./transactionBase.js");
5
6
  /**
6
7
  * Transaction wrapper (Bitcoin-like networks)
7
8
  *
8
9
  * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
9
10
  */
10
- class Transaction {
11
- _wasm;
12
- constructor(_wasm) {
13
- this._wasm = _wasm;
11
+ class Transaction extends transactionBase_js_1.TransactionBase {
12
+ constructor(wasm) {
13
+ super(wasm);
14
14
  }
15
15
  /**
16
16
  * Create an empty transaction (version 1, locktime 0)
@@ -44,20 +44,6 @@ class Transaction {
44
44
  addOutput(script, value) {
45
45
  return this._wasm.add_output(script, value);
46
46
  }
47
- toBytes() {
48
- return this._wasm.to_bytes();
49
- }
50
- /**
51
- * Get the transaction ID (txid)
52
- *
53
- * The txid is the double SHA256 of the transaction bytes (excluding witness
54
- * data for segwit transactions), displayed in reverse byte order as is standard.
55
- *
56
- * @returns The transaction ID as a hex string
57
- */
58
- getId() {
59
- return this._wasm.get_txid();
60
- }
61
47
  /**
62
48
  * Get the virtual size of the transaction
63
49
  *
@@ -68,27 +54,6 @@ class Transaction {
68
54
  getVSize() {
69
55
  return this._wasm.get_vsize();
70
56
  }
71
- inputCount() {
72
- return this._wasm.input_count();
73
- }
74
- outputCount() {
75
- return this._wasm.output_count();
76
- }
77
- version() {
78
- return this._wasm.version();
79
- }
80
- lockTime() {
81
- return this._wasm.lock_time();
82
- }
83
- getInputs() {
84
- return this._wasm.get_inputs();
85
- }
86
- getOutputs() {
87
- return this._wasm.get_outputs();
88
- }
89
- getOutputsWithAddress(coin) {
90
- return this._wasm.get_outputs_with_address(coin);
91
- }
92
57
  /** @internal */
93
58
  get wasm() {
94
59
  return this._wasm;
@@ -100,10 +65,9 @@ exports.Transaction = Transaction;
100
65
  *
101
66
  * Provides a camelCase, strongly-typed API over the snake_case WASM bindings.
102
67
  */
103
- class ZcashTransaction {
104
- _wasm;
105
- constructor(_wasm) {
106
- this._wasm = _wasm;
68
+ class ZcashTransaction extends transactionBase_js_1.TransactionBase {
69
+ constructor(wasm) {
70
+ super(wasm);
107
71
  }
108
72
  static fromBytes(bytes) {
109
73
  return new ZcashTransaction(wasm_utxo_js_1.WasmZcashTransaction.from_bytes(bytes));
@@ -112,41 +76,6 @@ class ZcashTransaction {
112
76
  static fromWasm(wasm) {
113
77
  return new ZcashTransaction(wasm);
114
78
  }
115
- toBytes() {
116
- return this._wasm.to_bytes();
117
- }
118
- /**
119
- * Get the transaction ID (txid)
120
- *
121
- * The txid is the double SHA256 of the full Zcash transaction bytes,
122
- * displayed in reverse byte order as is standard.
123
- *
124
- * @returns The transaction ID as a hex string
125
- */
126
- getId() {
127
- return this._wasm.get_txid();
128
- }
129
- inputCount() {
130
- return this._wasm.input_count();
131
- }
132
- outputCount() {
133
- return this._wasm.output_count();
134
- }
135
- version() {
136
- return this._wasm.version();
137
- }
138
- lockTime() {
139
- return this._wasm.lock_time();
140
- }
141
- getInputs() {
142
- return this._wasm.get_inputs();
143
- }
144
- getOutputs() {
145
- return this._wasm.get_outputs();
146
- }
147
- getOutputsWithAddress(coin) {
148
- return this._wasm.get_outputs_with_address(coin);
149
- }
150
79
  /** @internal */
151
80
  get wasm() {
152
81
  return this._wasm;
@@ -158,10 +87,9 @@ exports.ZcashTransaction = ZcashTransaction;
158
87
  *
159
88
  * Round-trip only: bytes -> parse -> bytes.
160
89
  */
161
- class DashTransaction {
162
- _wasm;
163
- constructor(_wasm) {
164
- this._wasm = _wasm;
90
+ class DashTransaction extends transactionBase_js_1.TransactionBase {
91
+ constructor(wasm) {
92
+ super(wasm);
165
93
  }
166
94
  static fromBytes(bytes) {
167
95
  return new DashTransaction(wasm_utxo_js_1.WasmDashTransaction.from_bytes(bytes));
@@ -170,41 +98,6 @@ class DashTransaction {
170
98
  static fromWasm(wasm) {
171
99
  return new DashTransaction(wasm);
172
100
  }
173
- toBytes() {
174
- return this._wasm.to_bytes();
175
- }
176
- /**
177
- * Get the transaction ID (txid)
178
- *
179
- * The txid is the double SHA256 of the full Dash transaction bytes,
180
- * displayed in reverse byte order as is standard.
181
- *
182
- * @returns The transaction ID as a hex string
183
- */
184
- getId() {
185
- return this._wasm.get_txid();
186
- }
187
- inputCount() {
188
- return this._wasm.input_count();
189
- }
190
- outputCount() {
191
- return this._wasm.output_count();
192
- }
193
- version() {
194
- return this._wasm.version();
195
- }
196
- lockTime() {
197
- return this._wasm.lock_time();
198
- }
199
- getInputs() {
200
- return this._wasm.get_inputs();
201
- }
202
- getOutputs() {
203
- return this._wasm.get_outputs();
204
- }
205
- getOutputsWithAddress(coin) {
206
- return this._wasm.get_outputs_with_address(coin);
207
- }
208
101
  /** @internal */
209
102
  get wasm() {
210
103
  return this._wasm;
@@ -0,0 +1,28 @@
1
+ import type { TxInputData, TxOutputData, TxOutputDataWithAddress } from "./wasm/wasm_utxo.js";
2
+ import type { CoinName } from "./coinName.js";
3
+ import type { ITransaction } from "./transaction.js";
4
+ interface WasmTransactionLike {
5
+ input_count(): number;
6
+ output_count(): number;
7
+ version(): number;
8
+ lock_time(): number;
9
+ to_bytes(): Uint8Array;
10
+ get_txid(): string;
11
+ get_inputs(): unknown;
12
+ get_outputs(): unknown;
13
+ get_outputs_with_address(coin: string): unknown;
14
+ }
15
+ export declare abstract class TransactionBase<W extends WasmTransactionLike> implements ITransaction {
16
+ protected _wasm: W;
17
+ constructor(wasm: W);
18
+ inputCount(): number;
19
+ outputCount(): number;
20
+ version(): number;
21
+ lockTime(): number;
22
+ toBytes(): Uint8Array;
23
+ getId(): string;
24
+ getInputs(): TxInputData[];
25
+ getOutputs(): TxOutputData[];
26
+ getOutputsWithAddress(coin: CoinName): TxOutputDataWithAddress[];
27
+ }
28
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionBase = void 0;
4
+ class TransactionBase {
5
+ _wasm;
6
+ constructor(wasm) {
7
+ this._wasm = wasm;
8
+ }
9
+ inputCount() {
10
+ return this._wasm.input_count();
11
+ }
12
+ outputCount() {
13
+ return this._wasm.output_count();
14
+ }
15
+ version() {
16
+ return this._wasm.version();
17
+ }
18
+ lockTime() {
19
+ return this._wasm.lock_time();
20
+ }
21
+ toBytes() {
22
+ return this._wasm.to_bytes();
23
+ }
24
+ getId() {
25
+ return this._wasm.get_txid();
26
+ }
27
+ getInputs() {
28
+ return this._wasm.get_inputs();
29
+ }
30
+ getOutputs() {
31
+ return this._wasm.get_outputs();
32
+ }
33
+ getOutputsWithAddress(coin) {
34
+ return this._wasm.get_outputs_with_address(coin);
35
+ }
36
+ }
37
+ exports.TransactionBase = TransactionBase;
@@ -334,7 +334,9 @@ export class BitGoPsbt {
334
334
  */
335
335
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
336
336
  get_global_xpubs(): any;
337
+ get_input_kv(index: number, key: any): Uint8Array | undefined;
337
338
  get_inputs(): any;
339
+ get_kv(key: any): Uint8Array | undefined;
338
340
  /**
339
341
  * Get the network type for transaction extraction
340
342
  *
@@ -342,6 +344,7 @@ export class BitGoPsbt {
342
344
  * wrapper class should be used in TypeScript.
343
345
  */
344
346
  get_network_type(): string;
347
+ get_output_kv(index: number, key: any): Uint8Array | undefined;
345
348
  get_outputs(): any;
346
349
  get_outputs_with_address(): any;
347
350
  input_count(): number;
@@ -384,6 +387,9 @@ export class BitGoPsbt {
384
387
  * The serialized PSBT as a byte array
385
388
  */
386
389
  serialize(): Uint8Array;
390
+ set_input_kv(index: number, key: any, value: Uint8Array): void;
391
+ set_kv(key: any, value: Uint8Array): void;
392
+ set_output_kv(index: number, key: any, value: Uint8Array): void;
387
393
  /**
388
394
  * Sign all MuSig2 keypath inputs in a single pass with optimized sighash computation.
389
395
  *
@@ -583,10 +589,7 @@ export class BitGoPsbt {
583
589
  * - `Err(WasmUtxoError)` if signing fails
584
590
  */
585
591
  sign_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
586
- /**
587
- * Get the unsigned transaction ID
588
- */
589
- unsigned_txid(): string;
592
+ unsigned_tx_id(): string;
590
593
  /**
591
594
  * Verify if a replay protection input has a valid signature
592
595
  *
@@ -676,6 +679,11 @@ export class FixedScriptWalletNamespace {
676
679
  * The OP_RETURN script as bytes
677
680
  */
678
681
  static create_op_return_script(data?: Uint8Array | null): Uint8Array;
682
+ /**
683
+ * Returns an object mapping BitGo proprietary key subtype names to their `u8` values.
684
+ * Values are loaded directly from the Rust enum at build time — no duplication in TypeScript.
685
+ */
686
+ static get_bitgo_key_subtypes(): any;
679
687
  static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
680
688
  static output_script_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string): Uint8Array;
681
689
  /**
@@ -1234,6 +1242,19 @@ export class WasmTransaction {
1234
1242
  version(): number;
1235
1243
  }
1236
1244
 
1245
+ /**
1246
+ * Top-level package info namespace
1247
+ */
1248
+ export class WasmUtxoNamespace {
1249
+ private constructor();
1250
+ free(): void;
1251
+ [Symbol.dispose](): void;
1252
+ /**
1253
+ * Returns the wasm-utxo build version as `{ version: string, gitHash: string }`.
1254
+ */
1255
+ static get_wasm_utxo_version(): any;
1256
+ }
1257
+
1237
1258
  /**
1238
1259
  * A Zcash transaction with network-specific fields
1239
1260
  *
@@ -1356,7 +1377,10 @@ export class WrapPsbt {
1356
1377
  extract_transaction(): WasmTransaction;
1357
1378
  finalize_mut(): void;
1358
1379
  get_global_xpubs(): any;
1380
+ get_input_kv(index: number, key: any): Uint8Array | undefined;
1359
1381
  get_inputs(): any;
1382
+ get_kv(key: any): Uint8Array | undefined;
1383
+ get_output_kv(index: number, key: any): Uint8Array | undefined;
1360
1384
  get_outputs(): any;
1361
1385
  get_outputs_with_address(coin: string): any;
1362
1386
  get_partial_signatures(input_index: number): any;
@@ -1382,6 +1406,9 @@ export class WrapPsbt {
1382
1406
  remove_input(index: number): void;
1383
1407
  remove_output(index: number): void;
1384
1408
  serialize(): Uint8Array;
1409
+ set_input_kv(index: number, key: any, value: Uint8Array): void;
1410
+ set_kv(key: any, value: Uint8Array): void;
1411
+ set_output_kv(index: number, key: any, value: Uint8Array): void;
1385
1412
  /**
1386
1413
  * Sign all inputs with a WasmBIP32 key
1387
1414
  *