@bitgo/wasm-utxo 1.42.0 → 1.44.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.
@@ -521,15 +521,18 @@ class BitGoPsbt {
521
521
  * @param {number} vout
522
522
  * @param {bigint} value
523
523
  * @param {number | null} [sequence]
524
+ * @param {Uint8Array | null} [prev_tx]
524
525
  * @returns {number}
525
526
  */
526
- add_replay_protection_input(ecpair, txid, vout, value, sequence) {
527
+ add_replay_protection_input(ecpair, txid, vout, value, sequence, prev_tx) {
527
528
  try {
528
529
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
530
  _assertClass(ecpair, WasmECPair);
530
531
  const ptr0 = passStringToWasm0(txid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
531
532
  const len0 = WASM_VECTOR_LEN;
532
- wasm.bitgopsbt_add_replay_protection_input(retptr, this.__wbg_ptr, ecpair.__wbg_ptr, ptr0, len0, vout, value, isLikeNone(sequence) ? 0x100000001 : (sequence) >>> 0);
533
+ var ptr1 = isLikeNone(prev_tx) ? 0 : passArray8ToWasm0(prev_tx, wasm.__wbindgen_export);
534
+ var len1 = WASM_VECTOR_LEN;
535
+ wasm.bitgopsbt_add_replay_protection_input(retptr, this.__wbg_ptr, ecpair.__wbg_ptr, ptr0, len0, vout, value, isLikeNone(sequence) ? 0x100000001 : (sequence) >>> 0, ptr1, len1);
533
536
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
534
537
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
535
538
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1950,6 +1953,37 @@ class FixedScriptWalletNamespace {
1950
1953
  wasm.__wbindgen_add_to_stack_pointer(16);
1951
1954
  }
1952
1955
  }
1956
+ /**
1957
+ * Get the P2SH-P2PK output script for a compressed public key
1958
+ *
1959
+ * # Arguments
1960
+ * * `pubkey` - The compressed public key bytes (33 bytes)
1961
+ *
1962
+ * # Returns
1963
+ * The P2SH-P2PK output script as bytes
1964
+ * @param {Uint8Array} pubkey
1965
+ * @returns {Uint8Array}
1966
+ */
1967
+ static p2sh_p2pk_output_script(pubkey) {
1968
+ try {
1969
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1970
+ const ptr0 = passArray8ToWasm0(pubkey, wasm.__wbindgen_export);
1971
+ const len0 = WASM_VECTOR_LEN;
1972
+ wasm.fixedscriptwalletnamespace_p2sh_p2pk_output_script(retptr, ptr0, len0);
1973
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1974
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1975
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1976
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1977
+ if (r3) {
1978
+ throw takeObject(r2);
1979
+ }
1980
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1981
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1982
+ return v2;
1983
+ } finally {
1984
+ wasm.__wbindgen_add_to_stack_pointer(16);
1985
+ }
1986
+ }
1953
1987
  /**
1954
1988
  * Check if a network supports a given fixed-script wallet script type
1955
1989
  *
@@ -3478,6 +3512,65 @@ class WasmTransaction {
3478
3512
  const ptr = this.__destroy_into_raw();
3479
3513
  wasm.__wbg_wasmtransaction_free(ptr, 0);
3480
3514
  }
3515
+ /**
3516
+ * Add an input to the transaction
3517
+ *
3518
+ * # Arguments
3519
+ * * `txid` - The transaction ID (hex string) of the output being spent
3520
+ * * `vout` - The output index being spent
3521
+ * * `sequence` - Optional sequence number (default: 0xFFFFFFFF)
3522
+ *
3523
+ * # Returns
3524
+ * The index of the newly added input
3525
+ * @param {string} txid
3526
+ * @param {number} vout
3527
+ * @param {number | null} [sequence]
3528
+ * @returns {number}
3529
+ */
3530
+ add_input(txid, vout, sequence) {
3531
+ try {
3532
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3533
+ const ptr0 = passStringToWasm0(txid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3534
+ const len0 = WASM_VECTOR_LEN;
3535
+ wasm.wasmtransaction_add_input(retptr, this.__wbg_ptr, ptr0, len0, vout, isLikeNone(sequence) ? 0x100000001 : (sequence) >>> 0);
3536
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3537
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3538
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3539
+ if (r2) {
3540
+ throw takeObject(r1);
3541
+ }
3542
+ return r0 >>> 0;
3543
+ } finally {
3544
+ wasm.__wbindgen_add_to_stack_pointer(16);
3545
+ }
3546
+ }
3547
+ /**
3548
+ * Add an output to the transaction
3549
+ *
3550
+ * # Arguments
3551
+ * * `script` - The output script (scriptPubKey)
3552
+ * * `value` - The value in satoshis
3553
+ *
3554
+ * # Returns
3555
+ * The index of the newly added output
3556
+ * @param {Uint8Array} script
3557
+ * @param {bigint} value
3558
+ * @returns {number}
3559
+ */
3560
+ add_output(script, value) {
3561
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export);
3562
+ const len0 = WASM_VECTOR_LEN;
3563
+ const ret = wasm.wasmtransaction_add_output(this.__wbg_ptr, ptr0, len0, value);
3564
+ return ret >>> 0;
3565
+ }
3566
+ /**
3567
+ * Create an empty transaction (version 1, locktime 0)
3568
+ * @returns {WasmTransaction}
3569
+ */
3570
+ static create() {
3571
+ const ret = wasm.wasmtransaction_create();
3572
+ return WasmTransaction.__wrap(ret);
3573
+ }
3481
3574
  /**
3482
3575
  * Deserialize a transaction from bytes
3483
3576
  *
@@ -4685,6 +4778,175 @@ class WrapPsbt {
4685
4778
  if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
4686
4779
  exports.WrapPsbt = WrapPsbt;
4687
4780
 
4781
+ /**
4782
+ * Check if the inspect feature is enabled.
4783
+ *
4784
+ * # Returns
4785
+ * `true` if the feature is enabled, `false` otherwise
4786
+ * @returns {boolean}
4787
+ */
4788
+ function isInspectEnabled() {
4789
+ const ret = wasm.isInspectEnabled();
4790
+ return ret !== 0;
4791
+ }
4792
+ exports.isInspectEnabled = isInspectEnabled;
4793
+
4794
+ /**
4795
+ * Parse a PSBT at the raw byte level and return a JSON representation.
4796
+ *
4797
+ * Unlike `parsePsbtToJson`, this function exposes the raw key-value pair
4798
+ * structure as defined in BIP-174, showing:
4799
+ * - Raw key type IDs and their human-readable names
4800
+ * - Proprietary keys with their structured format
4801
+ * - Unknown/unrecognized keys that standard parsers might skip
4802
+ *
4803
+ * # Arguments
4804
+ * * `psbt_bytes` - The raw PSBT bytes
4805
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "zec")
4806
+ *
4807
+ * # Returns
4808
+ * A JSON string representing the raw PSBT key-value structure
4809
+ *
4810
+ * # Errors
4811
+ * Returns an error if:
4812
+ * - The `inspect` feature is not enabled
4813
+ * - The PSBT bytes are invalid
4814
+ * - The network name is unknown
4815
+ * @param {Uint8Array} psbt_bytes
4816
+ * @param {string} coin_name
4817
+ * @returns {string}
4818
+ */
4819
+ function parsePsbtRawToJson(psbt_bytes, coin_name) {
4820
+ let deferred4_0;
4821
+ let deferred4_1;
4822
+ try {
4823
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4824
+ const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_export);
4825
+ const len0 = WASM_VECTOR_LEN;
4826
+ const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4827
+ const len1 = WASM_VECTOR_LEN;
4828
+ wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
4829
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4830
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4831
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4832
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
4833
+ var ptr3 = r0;
4834
+ var len3 = r1;
4835
+ if (r3) {
4836
+ ptr3 = 0; len3 = 0;
4837
+ throw takeObject(r2);
4838
+ }
4839
+ deferred4_0 = ptr3;
4840
+ deferred4_1 = len3;
4841
+ return getStringFromWasm0(ptr3, len3);
4842
+ } finally {
4843
+ wasm.__wbindgen_add_to_stack_pointer(16);
4844
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
4845
+ }
4846
+ }
4847
+ exports.parsePsbtRawToJson = parsePsbtRawToJson;
4848
+
4849
+ /**
4850
+ * Parse a PSBT and return a JSON representation of its structure.
4851
+ *
4852
+ * This function parses the PSBT using the standard bitcoin crate parser
4853
+ * and returns a hierarchical node structure suitable for display.
4854
+ *
4855
+ * # Arguments
4856
+ * * `psbt_bytes` - The raw PSBT bytes
4857
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
4858
+ *
4859
+ * # Returns
4860
+ * A JSON string representing the parsed PSBT structure
4861
+ *
4862
+ * # Errors
4863
+ * Returns an error if:
4864
+ * - The `inspect` feature is not enabled
4865
+ * - The PSBT bytes are invalid
4866
+ * - The network name is unknown
4867
+ * @param {Uint8Array} psbt_bytes
4868
+ * @param {string} coin_name
4869
+ * @returns {string}
4870
+ */
4871
+ function parsePsbtToJson(psbt_bytes, coin_name) {
4872
+ let deferred4_0;
4873
+ let deferred4_1;
4874
+ try {
4875
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4876
+ const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_export);
4877
+ const len0 = WASM_VECTOR_LEN;
4878
+ const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4879
+ const len1 = WASM_VECTOR_LEN;
4880
+ wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
4881
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4882
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4883
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4884
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
4885
+ var ptr3 = r0;
4886
+ var len3 = r1;
4887
+ if (r3) {
4888
+ ptr3 = 0; len3 = 0;
4889
+ throw takeObject(r2);
4890
+ }
4891
+ deferred4_0 = ptr3;
4892
+ deferred4_1 = len3;
4893
+ return getStringFromWasm0(ptr3, len3);
4894
+ } finally {
4895
+ wasm.__wbindgen_add_to_stack_pointer(16);
4896
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
4897
+ }
4898
+ }
4899
+ exports.parsePsbtToJson = parsePsbtToJson;
4900
+
4901
+ /**
4902
+ * Parse a transaction and return a JSON representation of its structure.
4903
+ *
4904
+ * # Arguments
4905
+ * * `tx_bytes` - The raw transaction bytes
4906
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
4907
+ *
4908
+ * # Returns
4909
+ * A JSON string representing the parsed transaction structure
4910
+ *
4911
+ * # Errors
4912
+ * Returns an error if:
4913
+ * - The `inspect` feature is not enabled
4914
+ * - The transaction bytes are invalid
4915
+ * - The network name is unknown
4916
+ * @param {Uint8Array} tx_bytes
4917
+ * @param {string} coin_name
4918
+ * @returns {string}
4919
+ */
4920
+ function parseTxToJson(tx_bytes, coin_name) {
4921
+ let deferred4_0;
4922
+ let deferred4_1;
4923
+ try {
4924
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4925
+ const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_export);
4926
+ const len0 = WASM_VECTOR_LEN;
4927
+ const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4928
+ const len1 = WASM_VECTOR_LEN;
4929
+ wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
4930
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4931
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4932
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4933
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
4934
+ var ptr3 = r0;
4935
+ var len3 = r1;
4936
+ if (r3) {
4937
+ ptr3 = 0; len3 = 0;
4938
+ throw takeObject(r2);
4939
+ }
4940
+ deferred4_0 = ptr3;
4941
+ deferred4_1 = len3;
4942
+ return getStringFromWasm0(ptr3, len3);
4943
+ } finally {
4944
+ wasm.__wbindgen_add_to_stack_pointer(16);
4945
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
4946
+ }
4947
+ }
4948
+ exports.parseTxToJson = parseTxToJson;
4949
+
4688
4950
  function __wbg_get_imports() {
4689
4951
  const import0 = {
4690
4952
  __proto__: null,
Binary file
@@ -1,6 +1,57 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const __wbg_messagenamespace_free: (a: number, b: number) => void;
5
+ export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
6
+ export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
7
+ export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
8
+ export const wasmrootwalletkeys_backup_key: (a: number) => number;
9
+ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
10
+ export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
11
+ export const wasmrootwalletkeys_user_key: (a: number) => number;
12
+ export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
13
+ export const __wbg_addressnamespace_free: (a: number, b: number) => void;
14
+ export const __wbg_wasmecpair_free: (a: number, b: number) => void;
15
+ export const __wbg_wrappsbt_free: (a: number, b: number) => void;
16
+ export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
17
+ export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
18
+ export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
19
+ export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
20
+ export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
21
+ export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
22
+ export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
23
+ export const wasmecpair_private_key: (a: number) => number;
24
+ export const wasmecpair_public_key: (a: number) => number;
25
+ export const wasmecpair_to_wif: (a: number, b: number) => void;
26
+ export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
27
+ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
28
+ export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
29
+ export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
30
+ export const wrappsbt_clone: (a: number) => number;
31
+ export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
32
+ export const wrappsbt_extractTransaction: (a: number, b: number) => void;
33
+ export const wrappsbt_finalize: (a: number, b: number) => void;
34
+ export const wrappsbt_getInputs: (a: number, b: number) => void;
35
+ export const wrappsbt_getOutputs: (a: number, b: number) => void;
36
+ export const wrappsbt_getOutputsWithAddress: (a: number, b: number, c: number, d: number) => void;
37
+ export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
38
+ export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
39
+ export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
40
+ export const wrappsbt_inputCount: (a: number) => number;
41
+ export const wrappsbt_lockTime: (a: number) => number;
42
+ export const wrappsbt_new: (a: number, b: number) => number;
43
+ export const wrappsbt_outputCount: (a: number) => number;
44
+ export const wrappsbt_serialize: (a: number, b: number) => void;
45
+ export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
46
+ export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
47
+ export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
48
+ export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
49
+ export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
50
+ export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
51
+ export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
52
+ export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
53
+ export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
54
+ export const wrappsbt_version: (a: number) => number;
4
55
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
5
56
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
6
57
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
@@ -22,6 +73,9 @@ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => num
22
73
  export const wasmdimensions_has_segwit: (a: number) => number;
23
74
  export const wasmdimensions_plus: (a: number, b: number) => number;
24
75
  export const wasmdimensions_times: (a: number, b: number) => number;
76
+ export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
77
+ export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
78
+ export const wasmtransaction_create: () => number;
25
79
  export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
26
80
  export const wasmtransaction_get_txid: (a: number, b: number) => void;
27
81
  export const wasmtransaction_get_vsize: (a: number) => number;
@@ -45,7 +99,7 @@ export const bitgopsbt_add_input: (a: number, b: number, c: number, d: number, e
45
99
  export const bitgopsbt_add_output: (a: number, b: number, c: number, d: number, e: bigint) => void;
46
100
  export const bitgopsbt_add_output_with_address: (a: number, b: number, c: number, d: number, e: bigint) => void;
47
101
  export const bitgopsbt_add_paygo_attestation: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
48
- export const bitgopsbt_add_replay_protection_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number) => void;
102
+ export const bitgopsbt_add_replay_protection_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number, j: number) => void;
49
103
  export const bitgopsbt_add_wallet_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number) => void;
50
104
  export const bitgopsbt_add_wallet_output: (a: number, b: number, c: number, d: number, e: bigint, f: number) => void;
51
105
  export const bitgopsbt_combine_musig2_nonces: (a: number, b: number, c: number) => void;
@@ -93,9 +147,12 @@ export const fixedscriptwalletnamespace_chain_code_table: () => number;
93
147
  export const fixedscriptwalletnamespace_create_op_return_script: (a: number, b: number, c: number) => void;
94
148
  export const fixedscriptwalletnamespace_output_script: (a: number, b: number, c: number, d: number, e: number) => void;
95
149
  export const fixedscriptwalletnamespace_output_script_with_network_str: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
150
+ export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
96
151
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
97
152
  export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
98
153
  export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => void;
154
+ export const isInspectEnabled: () => number;
155
+ export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
99
156
  export const wasmbip32_chain_code: (a: number) => number;
100
157
  export const wasmbip32_depth: (a: number) => number;
101
158
  export const wasmbip32_derive: (a: number, b: number, c: number) => void;
@@ -125,60 +182,11 @@ export const wasmreplayprotection_from_addresses: (a: number, b: number, c: numb
125
182
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
126
183
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
127
184
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
185
+ export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
186
+ export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
128
187
  export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
129
188
  export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
130
189
  export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
131
- export const __wbg_messagenamespace_free: (a: number, b: number) => void;
132
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
133
- export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
134
- export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
135
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
136
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
137
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
138
- export const wasmrootwalletkeys_user_key: (a: number) => number;
139
- export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
140
- export const __wbg_addressnamespace_free: (a: number, b: number) => void;
141
- export const __wbg_wasmecpair_free: (a: number, b: number) => void;
142
- export const __wbg_wrappsbt_free: (a: number, b: number) => void;
143
- export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
144
- export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
145
- export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
146
- export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
147
- export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
148
- export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
149
- export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
150
- export const wasmecpair_private_key: (a: number) => number;
151
- export const wasmecpair_public_key: (a: number) => number;
152
- export const wasmecpair_to_wif: (a: number, b: number) => void;
153
- export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
154
- export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
155
- export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
156
- export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
157
- export const wrappsbt_clone: (a: number) => number;
158
- export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
159
- export const wrappsbt_extractTransaction: (a: number, b: number) => void;
160
- export const wrappsbt_finalize: (a: number, b: number) => void;
161
- export const wrappsbt_getInputs: (a: number, b: number) => void;
162
- export const wrappsbt_getOutputs: (a: number, b: number) => void;
163
- export const wrappsbt_getOutputsWithAddress: (a: number, b: number, c: number, d: number) => void;
164
- export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
165
- export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
166
- export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
167
- export const wrappsbt_inputCount: (a: number) => number;
168
- export const wrappsbt_lockTime: (a: number) => number;
169
- export const wrappsbt_new: (a: number, b: number) => number;
170
- export const wrappsbt_outputCount: (a: number) => number;
171
- export const wrappsbt_serialize: (a: number, b: number) => void;
172
- export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
173
- export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
174
- export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
175
- export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
176
- export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
177
- export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
178
- export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
179
- export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
180
- export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
181
- export const wrappsbt_version: (a: number) => number;
182
190
  export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
183
191
  export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
184
192
  export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
@@ -192,7 +192,7 @@ export class BitGoPsbt {
192
192
  */
193
193
  addReplayProtectionInput(inputOptions, key) {
194
194
  const ecpair = ECPair.from(key);
195
- 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, inputOptions.prevTx);
196
196
  }
197
197
  /**
198
198
  * Get the unsigned transaction ID
@@ -52,3 +52,10 @@ export declare function supportsScriptType(coin: CoinName, scriptType: ScriptTyp
52
52
  * ```
53
53
  */
54
54
  export declare function createOpReturnScript(data?: Uint8Array): Uint8Array;
55
+ /**
56
+ * Get the P2SH-P2PK output script for a compressed public key
57
+ *
58
+ * @param pubkey - The compressed public key bytes (33 bytes)
59
+ * @returns The P2SH-P2PK output script as a Uint8Array
60
+ */
61
+ export declare function p2shP2pkOutputScript(pubkey: Uint8Array): Uint8Array;
@@ -56,3 +56,12 @@ export function supportsScriptType(coin, scriptType) {
56
56
  export function createOpReturnScript(data) {
57
57
  return FixedScriptWalletNamespace.create_op_return_script(data);
58
58
  }
59
+ /**
60
+ * Get the P2SH-P2PK output script for a compressed public key
61
+ *
62
+ * @param pubkey - The compressed public key bytes (33 bytes)
63
+ * @returns The P2SH-P2PK output script as a Uint8Array
64
+ */
65
+ export function p2shP2pkOutputScript(pubkey) {
66
+ return FixedScriptWalletNamespace.p2sh_p2pk_output_script(pubkey);
67
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Inspect - TypeScript bindings for PSBT and Transaction parsing
3
+ *
4
+ * Provides typed wrappers around the WASM inspect functions that return
5
+ * hierarchical node structures suitable for display as collapsible trees.
6
+ *
7
+ * Import via: `import { ... } from "@bitgo/wasm-utxo/inspect"`
8
+ */
9
+ import type { CoinName } from "../coinName.js";
10
+ /** Re-export CoinName for convenience */
11
+ export type { CoinName };
12
+ /** All supported networks in order of parsing priority */
13
+ export declare const allNetworks: CoinName[];
14
+ /**
15
+ * Primitive value types that can appear in a Node.
16
+ * Buffer values are hex-encoded strings, Integer is a decimal string for BigInt support.
17
+ */
18
+ export type PrimitiveType = "String" | "Buffer" | "Integer" | "U8" | "U16" | "U32" | "U64" | "I8" | "I16" | "I32" | "I64" | "Boolean" | "None";
19
+ /**
20
+ * A tagged union representing primitive values in the parse tree.
21
+ */
22
+ export interface Primitive {
23
+ type: PrimitiveType;
24
+ value?: string | number | boolean;
25
+ }
26
+ /**
27
+ * A node in the parse tree representing a PSBT or transaction element.
28
+ */
29
+ export interface Node {
30
+ label: string;
31
+ value: Primitive;
32
+ children: Node[];
33
+ }
34
+ /**
35
+ * Parse a PSBT and return a typed node tree.
36
+ *
37
+ * @param psbtBytes - The raw PSBT bytes
38
+ * @param network - The network coin name (e.g., "btc", "ltc", "bch")
39
+ * @returns A Node tree representing the parsed PSBT structure
40
+ * @throws If the PSBT bytes are invalid or network is unknown
41
+ */
42
+ export declare function parsePsbtToNode(psbtBytes: Uint8Array, network: CoinName): Node;
43
+ /**
44
+ * Parse a transaction and return a typed node tree.
45
+ *
46
+ * @param txBytes - The raw transaction bytes
47
+ * @param network - The network coin name (e.g., "btc", "ltc", "bch")
48
+ * @returns A Node tree representing the parsed transaction structure
49
+ * @throws If the transaction bytes are invalid or network is unknown
50
+ */
51
+ export declare function parseTxToNode(txBytes: Uint8Array, network: CoinName): Node;
52
+ /**
53
+ * Try to parse a PSBT with all networks and return the first one that succeeds.
54
+ *
55
+ * @param psbtBytes - The raw PSBT bytes
56
+ * @param networks - Optional list of networks to try (defaults to all networks)
57
+ * @returns An object with the parsed Node and detected network, or null if all fail
58
+ */
59
+ export declare function tryParsePsbt(psbtBytes: Uint8Array, networks?: CoinName[]): {
60
+ node: Node;
61
+ network: CoinName;
62
+ } | null;
63
+ /**
64
+ * Try to parse a transaction with all networks and return the first one that succeeds.
65
+ *
66
+ * @param txBytes - The raw transaction bytes
67
+ * @param networks - Optional list of networks to try (defaults to all networks)
68
+ * @returns An object with the parsed Node and detected network, or null if all fail
69
+ */
70
+ export declare function tryParseTx(txBytes: Uint8Array, networks?: CoinName[]): {
71
+ node: Node;
72
+ network: CoinName;
73
+ } | null;
74
+ /**
75
+ * Parse a PSBT at the raw byte level and return a typed node tree.
76
+ *
77
+ * Unlike `parsePsbtToNode`, this function exposes the raw key-value pair
78
+ * structure as defined in BIP-174, showing:
79
+ * - Raw key type IDs and their human-readable names
80
+ * - Proprietary keys with their structured format
81
+ * - Unknown/unrecognized keys that standard parsers might skip
82
+ *
83
+ * @param psbtBytes - The raw PSBT bytes
84
+ * @param network - The network coin name (e.g., "btc", "ltc", "zec")
85
+ * @returns A Node tree representing the raw PSBT key-value structure
86
+ * @throws If the PSBT bytes are invalid or network is unknown
87
+ */
88
+ export declare function parsePsbtRawToNode(psbtBytes: Uint8Array, network: CoinName): Node;
89
+ /**
90
+ * Try to parse a raw PSBT with all networks and return the first one that succeeds.
91
+ *
92
+ * @param psbtBytes - The raw PSBT bytes
93
+ * @param networks - Optional list of networks to try (defaults to all networks)
94
+ * @returns An object with the parsed Node and detected network, or null if all fail
95
+ */
96
+ export declare function tryParsePsbtRaw(psbtBytes: Uint8Array, networks?: CoinName[]): {
97
+ node: Node;
98
+ network: CoinName;
99
+ } | null;
100
+ /**
101
+ * Check if the inspect feature is enabled in the WASM build.
102
+ *
103
+ * @returns true if the feature is enabled, false otherwise
104
+ */
105
+ export declare function isInspectEnabled(): boolean;