@bitgo/wasm-utxo 5.0.0 → 5.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 (37) hide show
  1. package/dist/cjs/js/descriptorWallet/psbt/findDescriptors.js +16 -12
  2. package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +12 -0
  3. package/dist/cjs/js/fixedScriptWallet/ZcashBitGoPsbt.js +13 -0
  4. package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +3 -0
  5. package/dist/cjs/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +4 -0
  6. package/dist/cjs/js/fixedScriptWallet/ZcashPsbt.d.ts +15 -0
  7. package/dist/cjs/js/fixedScriptWallet/ZcashPsbt.js +24 -0
  8. package/dist/cjs/js/fixedScriptWallet/index.d.ts +2 -1
  9. package/dist/cjs/js/fixedScriptWallet/index.js +3 -1
  10. package/dist/cjs/js/index.d.ts +17 -0
  11. package/dist/cjs/js/index.js +8 -1
  12. package/dist/cjs/js/psbt.d.ts +2 -1
  13. package/dist/cjs/js/psbtBase.d.ts +3 -1
  14. package/dist/cjs/js/psbtBase.js +3 -0
  15. package/dist/cjs/js/wasm/wasm_utxo.d.ts +2 -0
  16. package/dist/cjs/js/wasm/wasm_utxo.js +38 -0
  17. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  18. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +157 -155
  19. package/dist/esm/js/descriptorWallet/psbt/findDescriptors.js +16 -12
  20. package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.d.ts +12 -0
  21. package/dist/esm/js/fixedScriptWallet/ZcashBitGoPsbt.js +13 -0
  22. package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.d.ts +3 -0
  23. package/dist/esm/js/fixedScriptWallet/ZcashIronwoodBitGoPsbt.js +4 -0
  24. package/dist/esm/js/fixedScriptWallet/ZcashPsbt.d.ts +15 -0
  25. package/dist/esm/js/fixedScriptWallet/ZcashPsbt.js +20 -0
  26. package/dist/esm/js/fixedScriptWallet/index.d.ts +2 -1
  27. package/dist/esm/js/fixedScriptWallet/index.js +1 -0
  28. package/dist/esm/js/index.d.ts +17 -0
  29. package/dist/esm/js/index.js +1 -0
  30. package/dist/esm/js/psbt.d.ts +2 -1
  31. package/dist/esm/js/psbtBase.d.ts +3 -1
  32. package/dist/esm/js/psbtBase.js +3 -0
  33. package/dist/esm/js/wasm/wasm_utxo.d.ts +2 -0
  34. package/dist/esm/js/wasm/wasm_utxo_bg.js +38 -0
  35. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  36. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +157 -155
  37. package/package.json +1 -1
@@ -48,11 +48,11 @@ function findDescriptorForDerivationIndex(script, index, descriptorMap) {
48
48
  function getDerivationIndexFromPath(path) {
49
49
  const indexStr = path.split("/").pop();
50
50
  if (!indexStr) {
51
- throw new Error(`Invalid derivation path ${path}`);
51
+ return undefined;
52
52
  }
53
- const index = parseInt(indexStr, 10);
54
- if (index.toString() !== indexStr) {
55
- throw new Error(`Invalid derivation path ${path}`);
53
+ const index = Number(indexStr);
54
+ if (!Number.isSafeInteger(index) || index < 0 || index.toString() !== indexStr) {
55
+ return undefined;
56
56
  }
57
57
  return index;
58
58
  }
@@ -63,7 +63,13 @@ function getDerivationIndexFromPath(path) {
63
63
  * @param descriptorMap
64
64
  */
65
65
  function findDescriptorForAnyDerivationPath(script, derivationPaths, descriptorMap) {
66
- const derivationIndexSet = new Set(derivationPaths.map((p) => getDerivationIndexFromPath(p)));
66
+ const derivationIndexSet = new Set();
67
+ for (const path of derivationPaths) {
68
+ const index = getDerivationIndexFromPath(path);
69
+ if (index !== undefined) {
70
+ derivationIndexSet.add(index);
71
+ }
72
+ }
67
73
  for (const index of [...derivationIndexSet]) {
68
74
  const desc = findDescriptorForDerivationIndex(script, index, descriptorMap);
69
75
  if (desc) {
@@ -73,13 +79,11 @@ function findDescriptorForAnyDerivationPath(script, derivationPaths, descriptorM
73
79
  return undefined;
74
80
  }
75
81
  function getDerivationPaths(v) {
76
- if ("bip32Derivation" in v && v.bip32Derivation && v.bip32Derivation.length > 0) {
77
- return v.bip32Derivation.map((v) => v.path);
78
- }
79
- if ("tapBip32Derivation" in v && v.tapBip32Derivation && v.tapBip32Derivation.length > 0) {
80
- return v.tapBip32Derivation.map((v) => v.path).filter((v) => v !== "" && v !== "m");
81
- }
82
- return undefined;
82
+ const paths = [
83
+ ...(v.bip32Derivation ?? []).map((derivation) => derivation.path),
84
+ ...(v.tapBip32Derivation ?? []).map((derivation) => derivation.path),
85
+ ].filter((path) => path !== "" && path !== "m");
86
+ return paths.length > 0 ? paths : undefined;
83
87
  }
84
88
  /**
85
89
  * @param input
@@ -1,3 +1,4 @@
1
+ import { BitGoPsbt as WasmBitGoPsbt } from "../wasm/wasm_utxo.js";
1
2
  import { type WalletKeysArg } from "./RootWalletKeys.js";
2
3
  import { BitGoPsbt, type CreateEmptyOptions, type HydrationUnspent, type ParsedOutput } from "./BitGoPsbt.js";
3
4
  import { ZcashTransaction, type ITransaction } from "../transaction.js";
@@ -15,6 +16,8 @@ export type ZcashParsedOutput = ParsedOutput & {
15
16
  */
16
17
  isShielded: boolean;
17
18
  };
19
+ /** Zcash transaction versions supported by the fixed-script PSBT API. */
20
+ export type ZcashTransactionVersion = 4 | 6;
18
21
  /**
19
22
  * Zcash v6 (Ironwood) version group id (0xd884b698). Its presence marks a PSBT as v6 — see
20
23
  * `ZcashIronwoodBitGoPsbt`.
@@ -124,6 +127,8 @@ export declare class ZcashBitGoPsbt extends BitGoPsbt<ZcashParsedOutput> {
124
127
  * @returns A ZcashBitGoPsbt instance
125
128
  */
126
129
  static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashBitGoPsbt;
130
+ /** @internal Create from a parsed WASM instance without reparsing the bytes. */
131
+ static fromWasm(wasm: WasmBitGoPsbt): ZcashBitGoPsbt;
127
132
  /**
128
133
  * Reconstruct a Zcash PSBT from a network-format transaction (unsigned, half-signed, or fully-signed).
129
134
  *
@@ -173,6 +178,13 @@ export declare class ZcashBitGoPsbt extends BitGoPsbt<ZcashParsedOutput> {
173
178
  * @returns The version group ID (e.g., 0x892F2085 for Sapling)
174
179
  */
175
180
  get versionGroupId(): number;
181
+ /**
182
+ * Get the Zcash transaction version represented by this PSBT.
183
+ *
184
+ * The version group ID is the discriminator because the v4 and v6 PSBT encodings do not expose
185
+ * the same unsigned transaction bytes to a standard PSBT parser.
186
+ */
187
+ getVersion(): ZcashTransactionVersion;
176
188
  /**
177
189
  * Get the Zcash expiry height
178
190
  * @returns The expiry height (0 if not set)
@@ -111,6 +111,10 @@ class ZcashBitGoPsbt extends BitGoPsbt_js_1.BitGoPsbt {
111
111
  }
112
112
  return psbt;
113
113
  }
114
+ /** @internal Create from a parsed WASM instance without reparsing the bytes. */
115
+ static fromWasm(wasm) {
116
+ return new ZcashBitGoPsbt(wasm);
117
+ }
114
118
  /**
115
119
  * Reconstruct a Zcash PSBT from a network-format transaction (unsigned, half-signed, or fully-signed).
116
120
  *
@@ -181,6 +185,15 @@ class ZcashBitGoPsbt extends BitGoPsbt_js_1.BitGoPsbt {
181
185
  get versionGroupId() {
182
186
  return this.wasm.version_group_id();
183
187
  }
188
+ /**
189
+ * Get the Zcash transaction version represented by this PSBT.
190
+ *
191
+ * The version group ID is the discriminator because the v4 and v6 PSBT encodings do not expose
192
+ * the same unsigned transaction bytes to a standard PSBT parser.
193
+ */
194
+ getVersion() {
195
+ return this.versionGroupId === exports.IRONWOOD_VERSION_GROUP_ID ? 6 : 4;
196
+ }
184
197
  /**
185
198
  * Get the Zcash expiry height
186
199
  * @returns The expiry height (0 if not set)
@@ -1,3 +1,4 @@
1
+ import { BitGoPsbt as WasmBitGoPsbt } from "../wasm/wasm_utxo.js";
1
2
  import { type BIP32Arg } from "../bip32.js";
2
3
  import { type ECPairArg } from "../ecpair.js";
3
4
  import { type WalletKeysArg } from "./RootWalletKeys.js";
@@ -122,6 +123,8 @@ export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
122
123
  * @returns A ZcashIronwoodBitGoPsbt instance
123
124
  */
124
125
  static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashIronwoodBitGoPsbt;
126
+ /** @internal Create from a parsed WASM instance without reparsing the bytes. */
127
+ static fromWasm(wasm: WasmBitGoPsbt): ZcashIronwoodBitGoPsbt;
125
128
  /**
126
129
  * Add the shielded output (Constructor role). Stores the orchard PCZT in the PSBT.
127
130
  *
@@ -121,6 +121,10 @@ class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt_js_1.ZcashBitGoPsbt {
121
121
  }
122
122
  return psbt;
123
123
  }
124
+ /** @internal Create from a parsed WASM instance without reparsing the bytes. */
125
+ static fromWasm(wasm) {
126
+ return new ZcashIronwoodBitGoPsbt(wasm);
127
+ }
124
128
  /**
125
129
  * Add the shielded output (Constructor role). Stores the orchard PCZT in the PSBT.
126
130
  *
@@ -0,0 +1,15 @@
1
+ import { ZcashBitGoPsbt, type ZcashNetworkName } from "./ZcashBitGoPsbt.js";
2
+ import { ZcashIronwoodBitGoPsbt } from "./ZcashIronwoodBitGoPsbt.js";
3
+ export type ZcashPsbtInstance = ZcashBitGoPsbt | ZcashIronwoodBitGoPsbt;
4
+ /** Factory for deserializing either supported Zcash PSBT format. */
5
+ export declare class ZcashPsbt {
6
+ private constructor();
7
+ /**
8
+ * Deserialize a Zcash PSBT and return the format-specific implementation.
9
+ *
10
+ * The version is read from the parsed Zcash metadata, so callers do not need to run a separate
11
+ * byte-level detector or choose a concrete parser before deserializing.
12
+ */
13
+ static from(bytes: Uint8Array, network: ZcashNetworkName): ZcashPsbtInstance;
14
+ static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashPsbtInstance;
15
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZcashPsbt = void 0;
4
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
5
+ const ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
6
+ const ZcashIronwoodBitGoPsbt_js_1 = require("./ZcashIronwoodBitGoPsbt.js");
7
+ /** Factory for deserializing either supported Zcash PSBT format. */
8
+ class ZcashPsbt {
9
+ constructor() { }
10
+ /**
11
+ * Deserialize a Zcash PSBT and return the format-specific implementation.
12
+ *
13
+ * The version is read from the parsed Zcash metadata, so callers do not need to run a separate
14
+ * byte-level detector or choose a concrete parser before deserializing.
15
+ */
16
+ static from(bytes, network) {
17
+ const parsed = ZcashBitGoPsbt_js_1.ZcashBitGoPsbt.fromWasm(wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network));
18
+ return parsed.getVersion() === 6 ? ZcashIronwoodBitGoPsbt_js_1.ZcashIronwoodBitGoPsbt.fromWasm(parsed.wasm) : parsed;
19
+ }
20
+ static fromBytes(bytes, network) {
21
+ return ZcashPsbt.from(bytes, network);
22
+ }
23
+ }
24
+ exports.ZcashPsbt = ZcashPsbt;
@@ -8,7 +8,8 @@ export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js"
8
8
  export { requiresPrevTxForP2sh } from "./prevTx.js";
9
9
  export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, type HydrationUnspent, } from "./BitGoPsbt.js";
10
10
  export { BitGoKeySubtype, type PsbtKvKey } from "./BitGoKeySubtype.js";
11
- export { ZcashBitGoPsbt, type ZcashNetworkName, type ZcashParsedOutput, type CreateEmptyZcashOptions, IRONWOOD_VERSION_GROUP_ID, } from "./ZcashBitGoPsbt.js";
11
+ export { ZcashBitGoPsbt, type ZcashNetworkName, type ZcashParsedOutput, type ZcashTransactionVersion, type CreateEmptyZcashOptions, IRONWOOD_VERSION_GROUP_ID, } from "./ZcashBitGoPsbt.js";
12
+ export { ZcashPsbt, type ZcashPsbtInstance } from "./ZcashPsbt.js";
12
13
  export { ZcashIronwoodBitGoPsbt, zip302NoMemo, type CreateEmptyIronwoodOptions, type CreateEmptyIronwoodWithConsensusBranchIdOptions, } from "./ZcashIronwoodBitGoPsbt.js";
13
14
  export { ZcashUnifiedAddress } from "./ZcashUnifiedAddress.js";
14
15
  export { ZcashV6Transaction } from "./ZcashV6Transaction.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZcashIronwoodWitness = exports.ZcashV6Transaction = exports.ZcashUnifiedAddress = exports.zip302NoMemo = exports.ZcashIronwoodBitGoPsbt = exports.IRONWOOD_VERSION_GROUP_ID = exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.requiresPrevTxForP2sh = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
3
+ exports.ZcashIronwoodWitness = exports.ZcashV6Transaction = exports.ZcashUnifiedAddress = exports.zip302NoMemo = exports.ZcashIronwoodBitGoPsbt = exports.ZcashPsbt = exports.IRONWOOD_VERSION_GROUP_ID = exports.ZcashBitGoPsbt = exports.BitGoKeySubtype = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.requiresPrevTxForP2sh = 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;
@@ -34,6 +34,8 @@ Object.defineProperty(exports, "BitGoKeySubtype", { enumerable: true, get: funct
34
34
  var ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
35
35
  Object.defineProperty(exports, "ZcashBitGoPsbt", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.ZcashBitGoPsbt; } });
36
36
  Object.defineProperty(exports, "IRONWOOD_VERSION_GROUP_ID", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.IRONWOOD_VERSION_GROUP_ID; } });
37
+ var ZcashPsbt_js_1 = require("./ZcashPsbt.js");
38
+ Object.defineProperty(exports, "ZcashPsbt", { enumerable: true, get: function () { return ZcashPsbt_js_1.ZcashPsbt; } });
37
39
  // Zcash v6 (Ironwood / NU6.3) shielding PSBT
38
40
  var ZcashIronwoodBitGoPsbt_js_1 = require("./ZcashIronwoodBitGoPsbt.js");
39
41
  Object.defineProperty(exports, "ZcashIronwoodBitGoPsbt", { enumerable: true, get: function () { return ZcashIronwoodBitGoPsbt_js_1.ZcashIronwoodBitGoPsbt; } });
@@ -13,6 +13,7 @@ export { ECPair } from "./ecpair.js";
13
13
  export { BIP32 } from "./bip32.js";
14
14
  export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
15
15
  export { ZcashDimensions } from "./fixedScriptWallet/ZcashDimensions.js";
16
+ export { ZcashBitGoPsbt, ZcashPsbt, ZcashIronwoodBitGoPsbt, type ZcashPsbtInstance, type ZcashTransactionVersion, ZcashUnifiedAddress, ZcashV6Transaction, ZcashIronwoodWitness, } from "./fixedScriptWallet/index.js";
16
17
  export type WasmUtxoVersionInfo = {
17
18
  version: string;
18
19
  gitHash: string;
@@ -70,6 +71,21 @@ declare module "./wasm/wasm_utxo.js" {
70
71
  bip32Derivation: PsbtBip32Derivation[];
71
72
  tapBip32Derivation: PsbtBip32Derivation[];
72
73
  }
74
+ /** A serialized input-map record with a standard PSBT key type. */
75
+ interface PsbtKnownInputKeyValue {
76
+ type: "known";
77
+ key: string;
78
+ keyData: Uint8Array;
79
+ value: Uint8Array;
80
+ }
81
+ /** A serialized input-map record whose key type is unrecognized. */
82
+ interface PsbtUnknownInputKeyValue {
83
+ type: "unknown";
84
+ keyType: bigint;
85
+ keyData: Uint8Array;
86
+ value: Uint8Array;
87
+ }
88
+ type PsbtInputKeyValue = PsbtKnownInputKeyValue | PsbtUnknownInputKeyValue;
73
89
  /** Raw PSBT output data returned by getOutputs() */
74
90
  interface PsbtOutputData {
75
91
  script: Uint8Array;
@@ -112,3 +128,4 @@ export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
112
128
  export { Psbt } from "./descriptorWallet/Psbt.js";
113
129
  export { DashTransaction, Transaction, ZcashTransaction, type ITransaction, type ITransactionCommon, } from "./transaction.js";
114
130
  export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
131
+ export type { PsbtInputKeyValue } from "./wasm/wasm_utxo.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.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.requiresPrevTxForP2sh = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.ZcashDimensions = 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.zcashAddress = exports.address = void 0;
36
+ exports.hasPsbtMagic = exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.requiresPrevTxForP2sh = exports.isCoinName = exports.isTestnet = exports.isMainnet = exports.getMainnet = exports.ZcashIronwoodWitness = exports.ZcashV6Transaction = exports.ZcashUnifiedAddress = exports.ZcashIronwoodBitGoPsbt = exports.ZcashPsbt = exports.ZcashBitGoPsbt = exports.ZcashDimensions = 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.zcashAddress = exports.address = void 0;
37
37
  exports.getWasmUtxoVersion = getWasmUtxoVersion;
38
38
  exports.isWasmUtxoError = isWasmUtxoError;
39
39
  const wasm = __importStar(require("./wasm/wasm_utxo.js"));
@@ -63,6 +63,13 @@ var Dimensions_js_1 = require("./fixedScriptWallet/Dimensions.js");
63
63
  Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
64
64
  var ZcashDimensions_js_1 = require("./fixedScriptWallet/ZcashDimensions.js");
65
65
  Object.defineProperty(exports, "ZcashDimensions", { enumerable: true, get: function () { return ZcashDimensions_js_1.ZcashDimensions; } });
66
+ var index_js_1 = require("./fixedScriptWallet/index.js");
67
+ Object.defineProperty(exports, "ZcashBitGoPsbt", { enumerable: true, get: function () { return index_js_1.ZcashBitGoPsbt; } });
68
+ Object.defineProperty(exports, "ZcashPsbt", { enumerable: true, get: function () { return index_js_1.ZcashPsbt; } });
69
+ Object.defineProperty(exports, "ZcashIronwoodBitGoPsbt", { enumerable: true, get: function () { return index_js_1.ZcashIronwoodBitGoPsbt; } });
70
+ Object.defineProperty(exports, "ZcashUnifiedAddress", { enumerable: true, get: function () { return index_js_1.ZcashUnifiedAddress; } });
71
+ Object.defineProperty(exports, "ZcashV6Transaction", { enumerable: true, get: function () { return index_js_1.ZcashV6Transaction; } });
72
+ Object.defineProperty(exports, "ZcashIronwoodWitness", { enumerable: true, get: function () { return index_js_1.ZcashIronwoodWitness; } });
66
73
  function getWasmUtxoVersion() {
67
74
  return wasm_utxo_js_1.WasmUtxoNamespace.get_wasm_utxo_version();
68
75
  }
@@ -1,10 +1,11 @@
1
- import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
1
+ import type { PsbtInputData, PsbtInputKeyValue, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
2
2
  import type { BIP32 } from "./bip32.js";
3
3
  import type { ITransactionCommon } from "./transaction.js";
4
4
  import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
5
5
  /** Common interface for PSBT types */
6
6
  export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData> {
7
7
  getGlobalXpubs(): BIP32[];
8
+ getInputKeyValues(index: number): PsbtInputKeyValue[];
8
9
  unsignedTxId(): string;
9
10
  addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
10
11
  addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
@@ -1,4 +1,4 @@
1
- import type { PsbtInputData, PsbtOutputData } from "./wasm/wasm_utxo.js";
1
+ import type { PsbtInputData, PsbtInputKeyValue, PsbtOutputData } from "./wasm/wasm_utxo.js";
2
2
  import { BIP32 } from "./bip32.js";
3
3
  import type { PsbtKvKey } from "./fixedScriptWallet/BitGoKeySubtype.js";
4
4
  interface WasmPsbtBase {
@@ -9,6 +9,7 @@ interface WasmPsbtBase {
9
9
  unsigned_tx_id(): string;
10
10
  serialize(): Uint8Array;
11
11
  get_inputs(): unknown;
12
+ get_input_key_values(index: number): unknown;
12
13
  get_outputs(): unknown;
13
14
  get_global_xpubs(): unknown;
14
15
  remove_input(index: number): void;
@@ -33,6 +34,7 @@ export declare abstract class PsbtBase<W extends WasmPsbtBase> {
33
34
  unsignedTxId(): string;
34
35
  serialize(): Uint8Array;
35
36
  getInputs(): PsbtInputData[];
37
+ getInputKeyValues(index: number): PsbtInputKeyValue[];
36
38
  getOutputs(): PsbtOutputData[];
37
39
  getGlobalXpubs(): BIP32[];
38
40
  removeInput(index: number): void;
@@ -28,6 +28,9 @@ class PsbtBase {
28
28
  getInputs() {
29
29
  return this._wasm.get_inputs();
30
30
  }
31
+ getInputKeyValues(index) {
32
+ return this._wasm.get_input_key_values(index);
33
+ }
31
34
  getOutputs() {
32
35
  return this._wasm.get_outputs();
33
36
  }
@@ -488,6 +488,7 @@ export class BitGoPsbt {
488
488
  */
489
489
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
490
490
  get_global_xpubs(): any;
491
+ get_input_key_values(index: number): any;
491
492
  get_input_kv(index: number, key: any): Uint8Array | undefined;
492
493
  get_inputs(): any;
493
494
  get_kv(key: any): Uint8Array | undefined;
@@ -1658,6 +1659,7 @@ export class WrapPsbt {
1658
1659
  */
1659
1660
  finalize_mut_zcash(consensus_branch_id: number, version_group_id?: number | null, expiry_height?: number | null): void;
1660
1661
  get_global_xpubs(): any;
1662
+ get_input_key_values(index: number): any;
1661
1663
  get_input_kv(index: number, key: any): Uint8Array | undefined;
1662
1664
  get_inputs(): any;
1663
1665
  get_kv(key: any): Uint8Array | undefined;
@@ -1691,6 +1691,25 @@ class BitGoPsbt {
1691
1691
  const ret = wasm.bitgopsbt_get_global_xpubs(this.__wbg_ptr);
1692
1692
  return takeObject(ret);
1693
1693
  }
1694
+ /**
1695
+ * @param {number} index
1696
+ * @returns {any}
1697
+ */
1698
+ get_input_key_values(index) {
1699
+ try {
1700
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1701
+ wasm.bitgopsbt_get_input_key_values(retptr, this.__wbg_ptr, index);
1702
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1703
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1704
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1705
+ if (r2) {
1706
+ throw takeObject(r1);
1707
+ }
1708
+ return takeObject(r0);
1709
+ } finally {
1710
+ wasm.__wbindgen_add_to_stack_pointer(16);
1711
+ }
1712
+ }
1694
1713
  /**
1695
1714
  * @param {number} index
1696
1715
  * @param {any} key
@@ -6105,6 +6124,25 @@ class WrapPsbt {
6105
6124
  const ret = wasm.wrappsbt_get_global_xpubs(this.__wbg_ptr);
6106
6125
  return takeObject(ret);
6107
6126
  }
6127
+ /**
6128
+ * @param {number} index
6129
+ * @returns {any}
6130
+ */
6131
+ get_input_key_values(index) {
6132
+ try {
6133
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
6134
+ wasm.wrappsbt_get_input_key_values(retptr, this.__wbg_ptr, index);
6135
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
6136
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
6137
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
6138
+ if (r2) {
6139
+ throw takeObject(r1);
6140
+ }
6141
+ return takeObject(r0);
6142
+ } finally {
6143
+ wasm.__wbindgen_add_to_stack_pointer(16);
6144
+ }
6145
+ }
6108
6146
  /**
6109
6147
  * @param {number} index
6110
6148
  * @param {any} key
Binary file