@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,35 +1,23 @@
1
- import { WrapPsbt as WasmPsbt, type WasmBIP32, type WasmECPair, type WrapDescriptor, type PsbtInputData, type PsbtOutputData, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
1
+ import { WrapPsbt as WasmPsbt, type WasmBIP32, type WasmECPair, type WrapDescriptor, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
2
2
  import type { IPsbt } from "../psbt.js";
3
3
  import type { CoinName } from "../coinName.js";
4
- import type { BIP32 } from "../bip32.js";
5
4
  import { Transaction } from "../transaction.js";
5
+ import { PsbtBase } from "../psbtBase.js";
6
6
  export type SignPsbtResult = {
7
7
  [inputIndex: number]: [pubkey: string][];
8
8
  };
9
- export declare class Psbt implements IPsbt {
10
- private _wasm;
9
+ export declare class Psbt extends PsbtBase<WasmPsbt> implements IPsbt {
11
10
  constructor(versionOrWasm?: number | WasmPsbt, lockTime?: number);
12
11
  /** @internal Access the underlying WASM instance */
13
12
  get wasm(): WasmPsbt;
14
13
  static create(version?: number, lockTime?: number): Psbt;
15
14
  static deserialize(bytes: Uint8Array): Psbt;
16
- serialize(): Uint8Array;
17
15
  clone(): Psbt;
18
- inputCount(): number;
19
- outputCount(): number;
20
- version(): number;
21
- lockTime(): number;
22
- unsignedTxId(): string;
23
- getInputs(): PsbtInputData[];
24
- getOutputs(): PsbtOutputData[];
25
- getGlobalXpubs(): BIP32[];
26
16
  getOutputsWithAddress(coin: CoinName): PsbtOutputDataWithAddress[];
27
17
  addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
28
18
  addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
29
19
  addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
30
20
  addOutput(script: Uint8Array, value: bigint): number;
31
- removeInput(index: number): void;
32
- removeOutput(index: number): void;
33
21
  updateInputWithDescriptor(inputIndex: number, descriptor: WrapDescriptor): void;
34
22
  updateOutputWithDescriptor(outputIndex: number, descriptor: WrapDescriptor): void;
35
23
  signWithXprv(xprv: string): SignPsbtResult;
@@ -3,15 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Psbt = void 0;
4
4
  const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
5
  const transaction_js_1 = require("../transaction.js");
6
- class Psbt {
7
- _wasm;
6
+ const psbtBase_js_1 = require("../psbtBase.js");
7
+ class Psbt extends psbtBase_js_1.PsbtBase {
8
8
  constructor(versionOrWasm, lockTime) {
9
- if (versionOrWasm instanceof wasm_utxo_js_1.WrapPsbt) {
10
- this._wasm = versionOrWasm;
11
- }
12
- else {
13
- this._wasm = new wasm_utxo_js_1.WrapPsbt(versionOrWasm, lockTime);
14
- }
9
+ super(versionOrWasm instanceof wasm_utxo_js_1.WrapPsbt ? versionOrWasm : new wasm_utxo_js_1.WrapPsbt(versionOrWasm, lockTime));
15
10
  }
16
11
  /** @internal Access the underlying WASM instance */
17
12
  get wasm() {
@@ -25,37 +20,10 @@ class Psbt {
25
20
  return new Psbt(wasm_utxo_js_1.WrapPsbt.deserialize(bytes));
26
21
  }
27
22
  // -- Serialization --
28
- serialize() {
29
- return this._wasm.serialize();
30
- }
31
23
  clone() {
32
24
  return new Psbt(this._wasm.clone());
33
25
  }
34
26
  // -- IPsbt: introspection --
35
- inputCount() {
36
- return this._wasm.input_count();
37
- }
38
- outputCount() {
39
- return this._wasm.output_count();
40
- }
41
- version() {
42
- return this._wasm.version();
43
- }
44
- lockTime() {
45
- return this._wasm.lock_time();
46
- }
47
- unsignedTxId() {
48
- return this._wasm.unsigned_tx_id();
49
- }
50
- getInputs() {
51
- return this._wasm.get_inputs();
52
- }
53
- getOutputs() {
54
- return this._wasm.get_outputs();
55
- }
56
- getGlobalXpubs() {
57
- return this._wasm.get_global_xpubs();
58
- }
59
27
  getOutputsWithAddress(coin) {
60
28
  return this._wasm.get_outputs_with_address(coin);
61
29
  }
@@ -72,12 +40,6 @@ class Psbt {
72
40
  addOutput(script, value) {
73
41
  return this._wasm.add_output(script, value);
74
42
  }
75
- removeInput(index) {
76
- this._wasm.remove_input(index);
77
- }
78
- removeOutput(index) {
79
- this._wasm.remove_output(index);
80
- }
81
43
  // -- Descriptor updates --
82
44
  updateInputWithDescriptor(inputIndex, descriptor) {
83
45
  this._wasm.update_input_with_descriptor(inputIndex, descriptor);
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Subtype constants for BitGo proprietary PSBT key-values.
3
+ * Values are loaded from the Rust enum at module init time — no duplication.
4
+ * The type shape is declared here for IDE support.
5
+ */
6
+ export type BitGoKeySubtypeMap = {
7
+ readonly ZecConsensusBranchId: number;
8
+ readonly Musig2ParticipantPubKeys: number;
9
+ readonly Musig2PubNonce: number;
10
+ readonly Musig2PartialSig: number;
11
+ readonly PayGoAddressAttestationProof: number;
12
+ readonly Bip322Message: number;
13
+ readonly WasmUtxoSignedWith: number;
14
+ };
15
+ export declare const BitGoKeySubtype: BitGoKeySubtypeMap;
16
+ export type BitGoKeySubtype = BitGoKeySubtypeMap[keyof BitGoKeySubtypeMap];
17
+ /**
18
+ * A composable PSBT key for use with `setKV` / `getKV` / `setInputKV` / `getInputKV` etc.
19
+ *
20
+ * - `"unknown"`: stored in the PSBT `unknown` map (raw BIP-174 key-value pair)
21
+ * - `"proprietary"`: stored in the PSBT `proprietary` map with an arbitrary prefix
22
+ * - `"bitgo"`: stored in the PSBT `proprietary` map with the `BITGO` prefix
23
+ */
24
+ export type PsbtKvKey = {
25
+ type: "unknown";
26
+ keyType: number;
27
+ data?: Uint8Array;
28
+ } | {
29
+ type: "proprietary";
30
+ prefix: Uint8Array;
31
+ subtype: number;
32
+ key?: Uint8Array;
33
+ } | {
34
+ type: "bitgo";
35
+ subtype: number;
36
+ key?: Uint8Array;
37
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BitGoKeySubtype = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ exports.BitGoKeySubtype = wasm_utxo_js_1.FixedScriptWalletNamespace.get_bitgo_key_subtypes();
@@ -1,5 +1,6 @@
1
- import { BitGoPsbt as WasmBitGoPsbt, type PsbtInputData, type PsbtOutputData, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
1
+ import { BitGoPsbt as WasmBitGoPsbt, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
2
2
  import type { IPsbtWithAddress } from "../psbt.js";
3
+ import { PsbtBase } from "../psbtBase.js";
3
4
  import { type WalletKeysArg, RootWalletKeys } from "./RootWalletKeys.js";
4
5
  import { type ReplayProtectionArg } from "./ReplayProtection.js";
5
6
  import { type BIP32Arg, BIP32 } from "../bip32.js";
@@ -102,10 +103,12 @@ export type HydrationUnspent = {
102
103
  chain: number;
103
104
  index: number;
104
105
  value: bigint;
106
+ } | {
107
+ pubkey: Uint8Array;
108
+ value: bigint;
105
109
  };
106
- export declare class BitGoPsbt implements IPsbtWithAddress {
107
- protected _wasm: WasmBitGoPsbt;
108
- protected constructor(_wasm: WasmBitGoPsbt);
110
+ export declare class BitGoPsbt extends PsbtBase<WasmBitGoPsbt> implements IPsbtWithAddress {
111
+ protected constructor(wasm: WasmBitGoPsbt);
109
112
  /**
110
113
  * Get the underlying WASM instance
111
114
  * @internal - for use by other wasm-utxo modules
@@ -288,19 +291,6 @@ export declare class BitGoPsbt implements IPsbtWithAddress {
288
291
  */
289
292
  addReplayProtectionInputAtIndex(index: number, inputOptions: AddInputOptions, key: ECPairArg): number;
290
293
  addReplayProtectionInput(inputOptions: AddInputOptions, key: ECPairArg): number;
291
- removeInput(index: number): void;
292
- removeOutput(index: number): void;
293
- /**
294
- * Get the unsigned transaction ID
295
- * @returns The unsigned transaction ID
296
- */
297
- unsignedTxId(): string;
298
- /**
299
- * Get the transaction version
300
- * @returns The transaction version number
301
- */
302
- version(): number;
303
- lockTime(): number;
304
294
  /**
305
295
  * Parse transaction with wallet keys to identify wallet inputs/outputs
306
296
  * @param walletKeys - The wallet keys to use for identification
@@ -467,12 +457,6 @@ export declare class BitGoPsbt implements IPsbtWithAddress {
467
457
  * @throws Error if the input is not a replay protection input, index is out of bounds, or scripts are invalid
468
458
  */
469
459
  verifyReplayProtectionSignature(inputIndex: number, replayProtection: ReplayProtectionArg): boolean;
470
- /**
471
- * Serialize the PSBT to bytes
472
- *
473
- * @returns The serialized PSBT as a byte array
474
- */
475
- serialize(): Uint8Array;
476
460
  /**
477
461
  * Generate and store MuSig2 nonces for all MuSig2 inputs
478
462
  *
@@ -571,31 +555,6 @@ export declare class BitGoPsbt implements IPsbtWithAddress {
571
555
  * ```
572
556
  */
573
557
  getHalfSignedLegacyFormat(): Uint8Array;
574
- /**
575
- * Get the number of inputs in the PSBT
576
- * @returns The number of inputs
577
- */
578
- inputCount(): number;
579
- outputCount(): number;
580
- /**
581
- * Get all PSBT inputs as an array
582
- *
583
- * Returns raw PSBT input data including witness_utxo and derivation info.
584
- * For parsed transaction data with address identification, use
585
- * parseTransactionWithWalletKeys() instead.
586
- *
587
- * @returns Array of PsbtInputData objects
588
- */
589
- getInputs(): PsbtInputData[];
590
- /**
591
- * Get all PSBT outputs as an array
592
- *
593
- * Returns raw PSBT output data without address resolution.
594
- * For output data with addresses, use getOutputsWithAddress().
595
- *
596
- * @returns Array of PsbtOutputData objects
597
- */
598
- getOutputs(): PsbtOutputData[];
599
558
  /**
600
559
  * Get all PSBT outputs with resolved address strings
601
560
  *
@@ -613,10 +572,6 @@ export declare class BitGoPsbt implements IPsbtWithAddress {
613
572
  * ```
614
573
  */
615
574
  getOutputsWithAddress(): PsbtOutputDataWithAddress[];
616
- /**
617
- * Returns the unordered global xpubs from this PSBT as BIP32 instances.
618
- */
619
- getGlobalXpubs(): BIP32[];
620
575
  }
621
576
  /**
622
577
  * Extract sorted wallet keys from a PSBT's global xpub fields.
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BitGoPsbt = void 0;
4
4
  exports.getWalletKeysFromPsbt = getWalletKeysFromPsbt;
5
5
  const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
6
+ const psbtBase_js_1 = require("../psbtBase.js");
6
7
  const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
7
8
  const ReplayProtection_js_1 = require("./ReplayProtection.js");
8
9
  const bip32_js_1 = require("../bip32.js");
9
10
  const ecpair_js_1 = require("../ecpair.js");
10
11
  const transaction_js_1 = require("../transaction.js");
11
- class BitGoPsbt {
12
- _wasm;
13
- constructor(_wasm) {
14
- this._wasm = _wasm;
12
+ class BitGoPsbt extends psbtBase_js_1.PsbtBase {
13
+ constructor(wasm) {
14
+ super(wasm);
15
15
  }
16
16
  /**
17
17
  * Get the underlying WASM instance
@@ -234,29 +234,6 @@ class BitGoPsbt {
234
234
  const ecpair = ecpair_js_1.ECPair.from(key);
235
235
  return this._wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence, inputOptions.prevTx);
236
236
  }
237
- removeInput(index) {
238
- this._wasm.remove_input(index);
239
- }
240
- removeOutput(index) {
241
- this._wasm.remove_output(index);
242
- }
243
- /**
244
- * Get the unsigned transaction ID
245
- * @returns The unsigned transaction ID
246
- */
247
- unsignedTxId() {
248
- return this._wasm.unsigned_txid();
249
- }
250
- /**
251
- * Get the transaction version
252
- * @returns The transaction version number
253
- */
254
- version() {
255
- return this._wasm.version();
256
- }
257
- lockTime() {
258
- return this._wasm.lock_time();
259
- }
260
237
  /**
261
238
  * Parse transaction with wallet keys to identify wallet inputs/outputs
262
239
  * @param walletKeys - The wallet keys to use for identification
@@ -450,14 +427,6 @@ class BitGoPsbt {
450
427
  const rp = ReplayProtection_js_1.ReplayProtection.from(replayProtection, this._wasm.network());
451
428
  return this._wasm.verify_replay_protection_signature(inputIndex, rp.wasm);
452
429
  }
453
- /**
454
- * Serialize the PSBT to bytes
455
- *
456
- * @returns The serialized PSBT as a byte array
457
- */
458
- serialize() {
459
- return this._wasm.serialize();
460
- }
461
430
  /**
462
431
  * Generate and store MuSig2 nonces for all MuSig2 inputs
463
432
  *
@@ -576,39 +545,6 @@ class BitGoPsbt {
576
545
  getHalfSignedLegacyFormat() {
577
546
  return this._wasm.extract_half_signed_legacy_tx();
578
547
  }
579
- /**
580
- * Get the number of inputs in the PSBT
581
- * @returns The number of inputs
582
- */
583
- inputCount() {
584
- return this._wasm.input_count();
585
- }
586
- outputCount() {
587
- return this._wasm.output_count();
588
- }
589
- /**
590
- * Get all PSBT inputs as an array
591
- *
592
- * Returns raw PSBT input data including witness_utxo and derivation info.
593
- * For parsed transaction data with address identification, use
594
- * parseTransactionWithWalletKeys() instead.
595
- *
596
- * @returns Array of PsbtInputData objects
597
- */
598
- getInputs() {
599
- return this._wasm.get_inputs();
600
- }
601
- /**
602
- * Get all PSBT outputs as an array
603
- *
604
- * Returns raw PSBT output data without address resolution.
605
- * For output data with addresses, use getOutputsWithAddress().
606
- *
607
- * @returns Array of PsbtOutputData objects
608
- */
609
- getOutputs() {
610
- return this._wasm.get_outputs();
611
- }
612
548
  /**
613
549
  * Get all PSBT outputs with resolved address strings
614
550
  *
@@ -628,13 +564,6 @@ class BitGoPsbt {
628
564
  getOutputsWithAddress() {
629
565
  return this._wasm.get_outputs_with_address();
630
566
  }
631
- /**
632
- * Returns the unordered global xpubs from this PSBT as BIP32 instances.
633
- */
634
- getGlobalXpubs() {
635
- const result = this._wasm.get_global_xpubs();
636
- return result.map((w) => bip32_js_1.BIP32.fromWasm(w));
637
- }
638
567
  }
639
568
  exports.BitGoPsbt = BitGoPsbt;
640
569
  /**
@@ -6,8 +6,8 @@ export { Dimensions } from "./Dimensions.js";
6
6
  export { outputScriptTypes, inputScriptTypes, type OutputScriptType, type InputScriptType, type ScriptType, } from "./scriptType.js";
7
7
  export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js";
8
8
  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";
9
+ export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
9
10
  export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
10
- export type { PsbtBip32Derivation, PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress, PsbtWitnessUtxo, } from "../wasm/wasm_utxo.js";
11
11
  import type { ScriptType } from "./scriptType.js";
12
12
  /**
13
13
  * Check if a network supports a given fixed-script wallet script type
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZcashBitGoPsbt = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
3
+ exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
4
4
  exports.supportsScriptType = supportsScriptType;
5
5
  exports.createOpReturnScript = createOpReturnScript;
6
6
  exports.p2shP2pkOutputScript = p2shP2pkOutputScript;
@@ -25,6 +25,8 @@ Object.defineProperty(exports, "assertChainCode", { enumerable: true, get: funct
25
25
  var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
26
26
  Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
27
27
  Object.defineProperty(exports, "getWalletKeysFromPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.getWalletKeysFromPsbt; } });
28
+ var BitGoKeySubtype_js_1 = require("./BitGoKeySubtype.js");
29
+ Object.defineProperty(exports, "BitGoKeySubtype", { enumerable: true, get: function () { return BitGoKeySubtype_js_1.BitGoKeySubtype; } });
28
30
  // Zcash-specific PSBT subclass
29
31
  var ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
30
32
  Object.defineProperty(exports, "ZcashBitGoPsbt", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.ZcashBitGoPsbt; } });
@@ -11,6 +11,11 @@ export * as ecpair from "./ecpair.js";
11
11
  export { ECPair } from "./ecpair.js";
12
12
  export { BIP32 } from "./bip32.js";
13
13
  export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
14
+ export type WasmUtxoVersionInfo = {
15
+ version: string;
16
+ gitHash: string;
17
+ };
18
+ export declare function getWasmUtxoVersion(): WasmUtxoVersionInfo;
14
19
  export { type CoinName, getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
15
20
  export type { Triple } from "./triple.js";
16
21
  export type { AddressFormat } from "./address.js";
@@ -34,7 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.descriptorWallet = exports.fixedScriptWallet = exports.utxolibCompat = exports.message = exports.inscriptions = exports.bip322 = exports.ast = exports.address = void 0;
37
+ exports.getWasmUtxoVersion = getWasmUtxoVersion;
37
38
  const wasm = __importStar(require("./wasm/wasm_utxo.js"));
39
+ const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
38
40
  // we need to access the wasm module here, otherwise webpack gets all weird
39
41
  // and forgets to include it in the bundle
40
42
  void wasm;
@@ -57,15 +59,18 @@ var bip32_js_1 = require("./bip32.js");
57
59
  Object.defineProperty(exports, "BIP32", { enumerable: true, get: function () { return bip32_js_1.BIP32; } });
58
60
  var Dimensions_js_1 = require("./fixedScriptWallet/Dimensions.js");
59
61
  Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
62
+ function getWasmUtxoVersion() {
63
+ return wasm_utxo_js_1.WasmUtxoNamespace.get_wasm_utxo_version();
64
+ }
60
65
  var coinName_js_1 = require("./coinName.js");
61
66
  Object.defineProperty(exports, "getMainnet", { enumerable: true, get: function () { return coinName_js_1.getMainnet; } });
62
67
  Object.defineProperty(exports, "isMainnet", { enumerable: true, get: function () { return coinName_js_1.isMainnet; } });
63
68
  Object.defineProperty(exports, "isTestnet", { enumerable: true, get: function () { return coinName_js_1.isTestnet; } });
64
69
  Object.defineProperty(exports, "isCoinName", { enumerable: true, get: function () { return coinName_js_1.isCoinName; } });
65
- var wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
66
- Object.defineProperty(exports, "Descriptor", { enumerable: true, get: function () { return wasm_utxo_js_1.WrapDescriptor; } });
67
70
  var wasm_utxo_js_2 = require("./wasm/wasm_utxo.js");
68
- Object.defineProperty(exports, "Miniscript", { enumerable: true, get: function () { return wasm_utxo_js_2.WrapMiniscript; } });
71
+ Object.defineProperty(exports, "Descriptor", { enumerable: true, get: function () { return wasm_utxo_js_2.WrapDescriptor; } });
72
+ var wasm_utxo_js_3 = require("./wasm/wasm_utxo.js");
73
+ Object.defineProperty(exports, "Miniscript", { enumerable: true, get: function () { return wasm_utxo_js_3.WrapMiniscript; } });
69
74
  var Psbt_js_1 = require("./descriptorWallet/Psbt.js");
70
75
  Object.defineProperty(exports, "Psbt", { enumerable: true, get: function () { return Psbt_js_1.Psbt; } });
71
76
  var transaction_js_1 = require("./transaction.js");
@@ -1,6 +1,7 @@
1
1
  import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
2
2
  import type { BIP32 } from "./bip32.js";
3
3
  import type { ITransactionCommon } from "./transaction.js";
4
+ import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
4
5
  /** Common interface for PSBT types */
5
6
  export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData> {
6
7
  getGlobalXpubs(): BIP32[];
@@ -9,6 +10,12 @@ export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData>
9
10
  addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
10
11
  removeInput(index: number): void;
11
12
  removeOutput(index: number): void;
13
+ setKV(key: PsbtKvKey, value: Uint8Array): void;
14
+ getKV(key: PsbtKvKey): Uint8Array | undefined;
15
+ setInputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
16
+ getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
17
+ setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
18
+ getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
12
19
  }
13
20
  /** Extended PSBT with address resolution (no coin parameter needed) */
14
21
  export interface IPsbtWithAddress extends IPsbt {
@@ -0,0 +1,44 @@
1
+ import type { PsbtInputData, PsbtOutputData } from "./wasm/wasm_utxo.js";
2
+ import { BIP32 } from "./bip32.js";
3
+ import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
4
+ interface WasmPsbtBase {
5
+ input_count(): number;
6
+ output_count(): number;
7
+ version(): number;
8
+ lock_time(): number;
9
+ unsigned_tx_id(): string;
10
+ serialize(): Uint8Array;
11
+ get_inputs(): unknown;
12
+ get_outputs(): unknown;
13
+ get_global_xpubs(): unknown;
14
+ remove_input(index: number): void;
15
+ remove_output(index: number): void;
16
+ set_kv(key: unknown, value: Uint8Array): void;
17
+ get_kv(key: unknown): Uint8Array | null | undefined;
18
+ set_input_kv(index: number, key: unknown, value: Uint8Array): void;
19
+ get_input_kv(index: number, key: unknown): Uint8Array | null | undefined;
20
+ set_output_kv(index: number, key: unknown, value: Uint8Array): void;
21
+ get_output_kv(index: number, key: unknown): Uint8Array | null | undefined;
22
+ }
23
+ export declare abstract class PsbtBase<W extends WasmPsbtBase> {
24
+ protected _wasm: W;
25
+ constructor(wasm: W);
26
+ inputCount(): number;
27
+ outputCount(): number;
28
+ version(): number;
29
+ lockTime(): number;
30
+ unsignedTxId(): string;
31
+ serialize(): Uint8Array;
32
+ getInputs(): PsbtInputData[];
33
+ getOutputs(): PsbtOutputData[];
34
+ getGlobalXpubs(): BIP32[];
35
+ removeInput(index: number): void;
36
+ removeOutput(index: number): void;
37
+ setKV(key: PsbtKvKey, value: Uint8Array): void;
38
+ getKV(key: PsbtKvKey): Uint8Array | undefined;
39
+ setInputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
40
+ getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
41
+ setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
42
+ getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
43
+ }
44
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsbtBase = void 0;
4
+ const bip32_js_1 = require("./bip32.js");
5
+ class PsbtBase {
6
+ _wasm;
7
+ constructor(wasm) {
8
+ this._wasm = wasm;
9
+ }
10
+ inputCount() {
11
+ return this._wasm.input_count();
12
+ }
13
+ outputCount() {
14
+ return this._wasm.output_count();
15
+ }
16
+ version() {
17
+ return this._wasm.version();
18
+ }
19
+ lockTime() {
20
+ return this._wasm.lock_time();
21
+ }
22
+ unsignedTxId() {
23
+ return this._wasm.unsigned_tx_id();
24
+ }
25
+ serialize() {
26
+ return this._wasm.serialize();
27
+ }
28
+ getInputs() {
29
+ return this._wasm.get_inputs();
30
+ }
31
+ getOutputs() {
32
+ return this._wasm.get_outputs();
33
+ }
34
+ getGlobalXpubs() {
35
+ return this._wasm.get_global_xpubs().map((w) => bip32_js_1.BIP32.fromWasm(w));
36
+ }
37
+ removeInput(index) {
38
+ this._wasm.remove_input(index);
39
+ }
40
+ removeOutput(index) {
41
+ this._wasm.remove_output(index);
42
+ }
43
+ setKV(key, value) {
44
+ this._wasm.set_kv(key, value);
45
+ }
46
+ getKV(key) {
47
+ return this._wasm.get_kv(key) ?? undefined;
48
+ }
49
+ setInputKV(index, key, value) {
50
+ this._wasm.set_input_kv(index, key, value);
51
+ }
52
+ getInputKV(index, key) {
53
+ return this._wasm.get_input_kv(index, key) ?? undefined;
54
+ }
55
+ setOutputKV(index, key, value) {
56
+ this._wasm.set_output_kv(index, key, value);
57
+ }
58
+ getOutputKV(index, key) {
59
+ return this._wasm.get_output_kv(index, key) ?? undefined;
60
+ }
61
+ }
62
+ exports.PsbtBase = PsbtBase;