@bitgo/wasm-utxo 1.25.0 → 1.27.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.
@@ -1 +1,6 @@
1
- export type CoinName = "btc" | "tbtc" | "tbtc4" | "tbtcsig" | "tbtcbgsig" | "bch" | "tbch" | "bcha" | "tbcha" | "btg" | "tbtg" | "bsv" | "tbsv" | "dash" | "tdash" | "doge" | "tdoge" | "ltc" | "tltc" | "zec" | "tzec";
1
+ export declare const coinNames: readonly ["btc", "tbtc", "tbtc4", "tbtcsig", "tbtcbgsig", "bch", "tbch", "bcha", "tbcha", "btg", "tbtg", "bsv", "tbsv", "dash", "tdash", "doge", "tdoge", "ltc", "tltc", "zec", "tzec"];
2
+ export type CoinName = (typeof coinNames)[number];
3
+ export declare function getMainnet(name: CoinName): CoinName;
4
+ export declare function isMainnet(name: CoinName): boolean;
5
+ export declare function isTestnet(name: CoinName): boolean;
6
+ export declare function isCoinName(v: string): v is CoinName;
@@ -1 +1,60 @@
1
- export {};
1
+ // BitGo coin names (from Network::from_coin_name in src/networks.rs)
2
+ export const coinNames = [
3
+ "btc",
4
+ "tbtc",
5
+ "tbtc4",
6
+ "tbtcsig",
7
+ "tbtcbgsig",
8
+ "bch",
9
+ "tbch",
10
+ "bcha",
11
+ "tbcha",
12
+ "btg",
13
+ "tbtg",
14
+ "bsv",
15
+ "tbsv",
16
+ "dash",
17
+ "tdash",
18
+ "doge",
19
+ "tdoge",
20
+ "ltc",
21
+ "tltc",
22
+ "zec",
23
+ "tzec",
24
+ ];
25
+ export function getMainnet(name) {
26
+ switch (name) {
27
+ case "tbtc":
28
+ case "tbtc4":
29
+ case "tbtcsig":
30
+ case "tbtcbgsig":
31
+ return "btc";
32
+ case "tbch":
33
+ return "bch";
34
+ case "tbcha":
35
+ return "bcha";
36
+ case "tbtg":
37
+ return "btg";
38
+ case "tbsv":
39
+ return "bsv";
40
+ case "tdash":
41
+ return "dash";
42
+ case "tdoge":
43
+ return "doge";
44
+ case "tltc":
45
+ return "ltc";
46
+ case "tzec":
47
+ return "zec";
48
+ default:
49
+ return name;
50
+ }
51
+ }
52
+ export function isMainnet(name) {
53
+ return getMainnet(name) === name;
54
+ }
55
+ export function isTestnet(name) {
56
+ return getMainnet(name) !== name;
57
+ }
58
+ export function isCoinName(v) {
59
+ return coinNames.includes(v);
60
+ }
@@ -7,6 +7,16 @@ type FromInputParams = {
7
7
  } | {
8
8
  scriptType: InputScriptType;
9
9
  };
10
+ /**
11
+ * Options for input dimension calculation
12
+ */
13
+ export type FromInputOptions = {
14
+ /**
15
+ * When true, use @bitgo/unspents-compatible signature sizes (72 bytes)
16
+ * for the "max" calculation instead of true maximum (73 bytes).
17
+ */
18
+ utxolibCompat?: boolean;
19
+ };
10
20
  /**
11
21
  * Dimensions class for estimating transaction virtual size.
12
22
  *
@@ -34,8 +44,9 @@ export declare class Dimensions {
34
44
  * Create dimensions for a single input
35
45
  *
36
46
  * @param params - Either `{ chain, signPath? }` or `{ scriptType }`
47
+ * @param options - Optional settings like `{ utxolibCompat: true }` for @bitgo/unspents-compatible sizing
37
48
  */
38
- static fromInput(params: FromInputParams): Dimensions;
49
+ static fromInput(params: FromInputParams, options?: FromInputOptions): Dimensions;
39
50
  /**
40
51
  * Create dimensions for a single output from script bytes
41
52
  */
@@ -33,12 +33,14 @@ export class Dimensions {
33
33
  * Create dimensions for a single input
34
34
  *
35
35
  * @param params - Either `{ chain, signPath? }` or `{ scriptType }`
36
+ * @param options - Optional settings like `{ utxolibCompat: true }` for @bitgo/unspents-compatible sizing
36
37
  */
37
- static fromInput(params) {
38
+ static fromInput(params, options) {
39
+ const compat = options?.utxolibCompat;
38
40
  if ("scriptType" in params) {
39
- return new Dimensions(WasmDimensions.from_input_script_type(params.scriptType));
41
+ return new Dimensions(WasmDimensions.from_input_script_type(params.scriptType, compat));
40
42
  }
41
- return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
43
+ return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
42
44
  }
43
45
  static fromOutput(params, network) {
44
46
  if (typeof params === "string") {
@@ -1,20 +1,27 @@
1
1
  import { type WalletKeysArg } from "./RootWalletKeys.js";
2
2
  import type { UtxolibNetwork } from "../utxolibCompat.js";
3
+ import type { UtxolibName } from "../utxolibCompat.js";
4
+ import type { CoinName } from "../coinName.js";
3
5
  import { AddressFormat } from "../address.js";
6
+ export type NetworkName = UtxolibName | CoinName;
4
7
  /**
5
8
  * Create the output script for a given wallet keys and chain and index
9
+ * @param keys - The wallet keys to use
10
+ * @param chain - The chain to use
11
+ * @param index - The index to use
12
+ * @param network - The network to use. Can be a network name string (e.g., "btc", "bitcoin", "testnet") or a UtxolibNetwork object
6
13
  */
7
- export declare function outputScript(keys: WalletKeysArg, chain: number, index: number, network: UtxolibNetwork): Uint8Array;
14
+ export declare function outputScript(keys: WalletKeysArg, chain: number, index: number, network: NetworkName | UtxolibNetwork): Uint8Array;
8
15
  /**
9
16
  * Create the address for a given wallet keys and chain and index and network.
10
17
  * Wrapper for outputScript that also encodes the script to an address.
11
18
  * @param keys - The wallet keys to use.
12
19
  * @param chain - The chain to use.
13
20
  * @param index - The index to use.
14
- * @param network - The network to use.
21
+ * @param network - The network to use. Can be a network name string (e.g., "btc", "bitcoin", "testnet") or a UtxolibNetwork object
15
22
  * @param addressFormat - The address format to use.
16
23
  * Only relevant for Bitcoin Cash and eCash networks, where:
17
24
  * - "default" means base58check,
18
25
  * - "cashaddr" means cashaddr.
19
26
  */
20
- export declare function address(keys: WalletKeysArg, chain: number, index: number, network: UtxolibNetwork, addressFormat?: AddressFormat): string;
27
+ export declare function address(keys: WalletKeysArg, chain: number, index: number, network: NetworkName | UtxolibNetwork, addressFormat?: AddressFormat): string;
@@ -2,10 +2,19 @@ import { FixedScriptWalletNamespace } from "../wasm/wasm_utxo.js";
2
2
  import { RootWalletKeys } from "./RootWalletKeys.js";
3
3
  /**
4
4
  * Create the output script for a given wallet keys and chain and index
5
+ * @param keys - The wallet keys to use
6
+ * @param chain - The chain to use
7
+ * @param index - The index to use
8
+ * @param network - The network to use. Can be a network name string (e.g., "btc", "bitcoin", "testnet") or a UtxolibNetwork object
5
9
  */
6
10
  export function outputScript(keys, chain, index, network) {
7
11
  const walletKeys = RootWalletKeys.from(keys);
8
- return FixedScriptWalletNamespace.output_script(walletKeys.wasm, chain, index, network);
12
+ if (typeof network === "string") {
13
+ return FixedScriptWalletNamespace.output_script_with_network_str(walletKeys.wasm, chain, index, network);
14
+ }
15
+ else {
16
+ return FixedScriptWalletNamespace.output_script(walletKeys.wasm, chain, index, network);
17
+ }
9
18
  }
10
19
  /**
11
20
  * Create the address for a given wallet keys and chain and index and network.
@@ -13,7 +22,7 @@ export function outputScript(keys, chain, index, network) {
13
22
  * @param keys - The wallet keys to use.
14
23
  * @param chain - The chain to use.
15
24
  * @param index - The index to use.
16
- * @param network - The network to use.
25
+ * @param network - The network to use. Can be a network name string (e.g., "btc", "bitcoin", "testnet") or a UtxolibNetwork object
17
26
  * @param addressFormat - The address format to use.
18
27
  * Only relevant for Bitcoin Cash and eCash networks, where:
19
28
  * - "default" means base58check,
@@ -21,5 +30,10 @@ export function outputScript(keys, chain, index, network) {
21
30
  */
22
31
  export function address(keys, chain, index, network, addressFormat) {
23
32
  const walletKeys = RootWalletKeys.from(keys);
24
- return FixedScriptWalletNamespace.address(walletKeys.wasm, chain, index, network, addressFormat);
33
+ if (typeof network === "string") {
34
+ return FixedScriptWalletNamespace.address_with_network_str(walletKeys.wasm, chain, index, network, addressFormat);
35
+ }
36
+ else {
37
+ return FixedScriptWalletNamespace.address(walletKeys.wasm, chain, index, network, addressFormat);
38
+ }
25
39
  }
@@ -504,6 +504,8 @@ export class FixedScriptWalletNamespace {
504
504
  * - Dogecoin only supports legacy scripts (p2sh)
505
505
  */
506
506
  static supports_script_type(coin: string, script_type: string): boolean;
507
+ static address_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string, address_format?: string | null): string;
508
+ static output_script_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string): Uint8Array;
507
509
  static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
508
510
  }
509
511
 
@@ -685,8 +687,9 @@ export class WasmDimensions {
685
687
  * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
686
688
  * * `signer` - Optional signer key ("user", "backup", "bitgo")
687
689
  * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
690
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
688
691
  */
689
- static from_input(chain: number, signer?: string | null, cosigner?: string | null): WasmDimensions;
692
+ static from_input(chain: number, signer?: string | null, cosigner?: string | null, compat?: boolean | null): WasmDimensions;
690
693
  /**
691
694
  * Get total weight (min or max)
692
695
  *
@@ -726,8 +729,9 @@ export class WasmDimensions {
726
729
  * # Arguments
727
730
  * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
728
731
  * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
732
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
729
733
  */
730
- static from_input_script_type(script_type: string): WasmDimensions;
734
+ static from_input_script_type(script_type: string, compat?: boolean | null): WasmDimensions;
731
735
  /**
732
736
  * Create dimensions for a single output from script type string
733
737
  *
@@ -959,15 +963,54 @@ export class WrapMiniscript {
959
963
  }
960
964
 
961
965
  export class WrapPsbt {
962
- private constructor();
963
966
  free(): void;
964
967
  [Symbol.dispose](): void;
968
+ /**
969
+ * Add an output to the PSBT
970
+ *
971
+ * # Arguments
972
+ * * `script` - The output script (scriptPubKey)
973
+ * * `value` - Value in satoshis
974
+ *
975
+ * # Returns
976
+ * The index of the newly added output
977
+ */
978
+ addOutput(script: Uint8Array, value: bigint): number;
965
979
  static deserialize(psbt: Uint8Array): WrapPsbt;
966
980
  finalize(): void;
967
981
  signWithPrv(prv: Uint8Array): any;
968
982
  signWithXprv(xprv: string): any;
983
+ /**
984
+ * Get the unsigned transaction bytes
985
+ *
986
+ * # Returns
987
+ * The serialized unsigned transaction
988
+ */
989
+ getUnsignedTx(): Uint8Array;
969
990
  updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
970
991
  updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
992
+ /**
993
+ * Create an empty PSBT
994
+ *
995
+ * # Arguments
996
+ * * `version` - Transaction version (default: 2)
997
+ * * `lock_time` - Transaction lock time (default: 0)
998
+ */
999
+ constructor(version?: number | null, lock_time?: number | null);
971
1000
  clone(): WrapPsbt;
1001
+ /**
1002
+ * Add an input to the PSBT
1003
+ *
1004
+ * # Arguments
1005
+ * * `txid` - Transaction ID (hex string, 32 bytes reversed)
1006
+ * * `vout` - Output index being spent
1007
+ * * `value` - Value in satoshis of the output being spent
1008
+ * * `script` - The scriptPubKey of the output being spent
1009
+ * * `sequence` - Sequence number (default: 0xFFFFFFFE for RBF)
1010
+ *
1011
+ * # Returns
1012
+ * The index of the newly added input
1013
+ */
1014
+ addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
972
1015
  serialize(): Uint8Array;
973
1016
  }
@@ -1579,6 +1579,71 @@ export class FixedScriptWalletNamespace {
1579
1579
  wasm.__wbindgen_add_to_stack_pointer(16);
1580
1580
  }
1581
1581
  }
1582
+ /**
1583
+ * @param {WasmRootWalletKeys} keys
1584
+ * @param {number} chain
1585
+ * @param {number} index
1586
+ * @param {string} network
1587
+ * @param {string | null} [address_format]
1588
+ * @returns {string}
1589
+ */
1590
+ static address_with_network_str(keys, chain, index, network, address_format) {
1591
+ let deferred4_0;
1592
+ let deferred4_1;
1593
+ try {
1594
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1595
+ _assertClass(keys, WasmRootWalletKeys);
1596
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1597
+ const len0 = WASM_VECTOR_LEN;
1598
+ var ptr1 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1599
+ var len1 = WASM_VECTOR_LEN;
1600
+ wasm.fixedscriptwalletnamespace_address_with_network_str(retptr, keys.__wbg_ptr, chain, index, ptr0, len0, ptr1, len1);
1601
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1602
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1603
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1604
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1605
+ var ptr3 = r0;
1606
+ var len3 = r1;
1607
+ if (r3) {
1608
+ ptr3 = 0; len3 = 0;
1609
+ throw takeObject(r2);
1610
+ }
1611
+ deferred4_0 = ptr3;
1612
+ deferred4_1 = len3;
1613
+ return getStringFromWasm0(ptr3, len3);
1614
+ } finally {
1615
+ wasm.__wbindgen_add_to_stack_pointer(16);
1616
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
1617
+ }
1618
+ }
1619
+ /**
1620
+ * @param {WasmRootWalletKeys} keys
1621
+ * @param {number} chain
1622
+ * @param {number} index
1623
+ * @param {string} network
1624
+ * @returns {Uint8Array}
1625
+ */
1626
+ static output_script_with_network_str(keys, chain, index, network) {
1627
+ try {
1628
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1629
+ _assertClass(keys, WasmRootWalletKeys);
1630
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1631
+ const len0 = WASM_VECTOR_LEN;
1632
+ wasm.fixedscriptwalletnamespace_output_script_with_network_str(retptr, keys.__wbg_ptr, chain, index, ptr0, len0);
1633
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1634
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1635
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1636
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1637
+ if (r3) {
1638
+ throw takeObject(r2);
1639
+ }
1640
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1641
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1642
+ return v2;
1643
+ } finally {
1644
+ wasm.__wbindgen_add_to_stack_pointer(16);
1645
+ }
1646
+ }
1582
1647
  /**
1583
1648
  * @param {WasmRootWalletKeys} keys
1584
1649
  * @param {number} chain
@@ -2257,19 +2322,21 @@ export class WasmDimensions {
2257
2322
  * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
2258
2323
  * * `signer` - Optional signer key ("user", "backup", "bitgo")
2259
2324
  * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
2325
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
2260
2326
  * @param {number} chain
2261
2327
  * @param {string | null} [signer]
2262
2328
  * @param {string | null} [cosigner]
2329
+ * @param {boolean | null} [compat]
2263
2330
  * @returns {WasmDimensions}
2264
2331
  */
2265
- static from_input(chain, signer, cosigner) {
2332
+ static from_input(chain, signer, cosigner, compat) {
2266
2333
  try {
2267
2334
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2268
2335
  var ptr0 = isLikeNone(signer) ? 0 : passStringToWasm0(signer, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2269
2336
  var len0 = WASM_VECTOR_LEN;
2270
2337
  var ptr1 = isLikeNone(cosigner) ? 0 : passStringToWasm0(cosigner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2271
2338
  var len1 = WASM_VECTOR_LEN;
2272
- wasm.wasmdimensions_from_input(retptr, chain, ptr0, len0, ptr1, len1);
2339
+ wasm.wasmdimensions_from_input(retptr, chain, ptr0, len0, ptr1, len1, isLikeNone(compat) ? 0xFFFFFF : compat ? 1 : 0);
2273
2340
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2274
2341
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2275
2342
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2353,15 +2420,17 @@ export class WasmDimensions {
2353
2420
  * # Arguments
2354
2421
  * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
2355
2422
  * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
2423
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
2356
2424
  * @param {string} script_type
2425
+ * @param {boolean | null} [compat]
2357
2426
  * @returns {WasmDimensions}
2358
2427
  */
2359
- static from_input_script_type(script_type) {
2428
+ static from_input_script_type(script_type, compat) {
2360
2429
  try {
2361
2430
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2362
2431
  const ptr0 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2363
2432
  const len0 = WASM_VECTOR_LEN;
2364
- wasm.wasmdimensions_from_input_script_type(retptr, ptr0, len0);
2433
+ wasm.wasmdimensions_from_input_script_type(retptr, ptr0, len0, isLikeNone(compat) ? 0xFFFFFF : compat ? 1 : 0);
2365
2434
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2366
2435
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2367
2436
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -3543,6 +3612,25 @@ export class WrapPsbt {
3543
3612
  const ptr = this.__destroy_into_raw();
3544
3613
  wasm.__wbg_wrappsbt_free(ptr, 0);
3545
3614
  }
3615
+ /**
3616
+ * Add an output to the PSBT
3617
+ *
3618
+ * # Arguments
3619
+ * * `script` - The output script (scriptPubKey)
3620
+ * * `value` - Value in satoshis
3621
+ *
3622
+ * # Returns
3623
+ * The index of the newly added output
3624
+ * @param {Uint8Array} script
3625
+ * @param {bigint} value
3626
+ * @returns {number}
3627
+ */
3628
+ addOutput(script, value) {
3629
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export);
3630
+ const len0 = WASM_VECTOR_LEN;
3631
+ const ret = wasm.wrappsbt_addOutput(this.__wbg_ptr, ptr0, len0, value);
3632
+ return ret >>> 0;
3633
+ }
3546
3634
  /**
3547
3635
  * @param {Uint8Array} psbt
3548
3636
  * @returns {WrapPsbt}
@@ -3619,6 +3707,26 @@ export class WrapPsbt {
3619
3707
  wasm.__wbindgen_add_to_stack_pointer(16);
3620
3708
  }
3621
3709
  }
3710
+ /**
3711
+ * Get the unsigned transaction bytes
3712
+ *
3713
+ * # Returns
3714
+ * The serialized unsigned transaction
3715
+ * @returns {Uint8Array}
3716
+ */
3717
+ getUnsignedTx() {
3718
+ try {
3719
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3720
+ wasm.wrappsbt_getUnsignedTx(retptr, this.__wbg_ptr);
3721
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3722
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3723
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3724
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3725
+ return v1;
3726
+ } finally {
3727
+ wasm.__wbindgen_add_to_stack_pointer(16);
3728
+ }
3729
+ }
3622
3730
  /**
3623
3731
  * @param {number} input_index
3624
3732
  * @param {WrapDescriptor} descriptor
@@ -3655,6 +3763,21 @@ export class WrapPsbt {
3655
3763
  wasm.__wbindgen_add_to_stack_pointer(16);
3656
3764
  }
3657
3765
  }
3766
+ /**
3767
+ * Create an empty PSBT
3768
+ *
3769
+ * # Arguments
3770
+ * * `version` - Transaction version (default: 2)
3771
+ * * `lock_time` - Transaction lock time (default: 0)
3772
+ * @param {number | null} [version]
3773
+ * @param {number | null} [lock_time]
3774
+ */
3775
+ constructor(version, lock_time) {
3776
+ const ret = wasm.wrappsbt_new(isLikeNone(version) ? 0x100000001 : (version) >> 0, isLikeNone(lock_time) ? 0x100000001 : (lock_time) >>> 0);
3777
+ this.__wbg_ptr = ret >>> 0;
3778
+ WrapPsbtFinalization.register(this, this.__wbg_ptr, this);
3779
+ return this;
3780
+ }
3658
3781
  /**
3659
3782
  * @returns {WrapPsbt}
3660
3783
  */
@@ -3662,6 +3785,44 @@ export class WrapPsbt {
3662
3785
  const ret = wasm.wrappsbt_clone(this.__wbg_ptr);
3663
3786
  return WrapPsbt.__wrap(ret);
3664
3787
  }
3788
+ /**
3789
+ * Add an input to the PSBT
3790
+ *
3791
+ * # Arguments
3792
+ * * `txid` - Transaction ID (hex string, 32 bytes reversed)
3793
+ * * `vout` - Output index being spent
3794
+ * * `value` - Value in satoshis of the output being spent
3795
+ * * `script` - The scriptPubKey of the output being spent
3796
+ * * `sequence` - Sequence number (default: 0xFFFFFFFE for RBF)
3797
+ *
3798
+ * # Returns
3799
+ * The index of the newly added input
3800
+ * @param {string} txid
3801
+ * @param {number} vout
3802
+ * @param {bigint} value
3803
+ * @param {Uint8Array} script
3804
+ * @param {number | null} [sequence]
3805
+ * @returns {number}
3806
+ */
3807
+ addInput(txid, vout, value, script, sequence) {
3808
+ try {
3809
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3810
+ const ptr0 = passStringToWasm0(txid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3811
+ const len0 = WASM_VECTOR_LEN;
3812
+ const ptr1 = passArray8ToWasm0(script, wasm.__wbindgen_export);
3813
+ const len1 = WASM_VECTOR_LEN;
3814
+ wasm.wrappsbt_addInput(retptr, this.__wbg_ptr, ptr0, len0, vout, value, ptr1, len1, isLikeNone(sequence) ? 0x100000001 : (sequence) >>> 0);
3815
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3816
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3817
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3818
+ if (r2) {
3819
+ throw takeObject(r1);
3820
+ }
3821
+ return r0 >>> 0;
3822
+ } finally {
3823
+ wasm.__wbindgen_add_to_stack_pointer(16);
3824
+ }
3825
+ }
3665
3826
  /**
3666
3827
  * @returns {Uint8Array}
3667
3828
  */
Binary file
@@ -1,53 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
5
- export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
6
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
7
- export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
8
- export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
9
- export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
10
- export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
11
- export const __wbg_wrappsbt_free: (a: number, b: number) => void;
12
- export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
13
- 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;
14
- export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
15
- export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
16
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
17
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
18
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
19
- export const wasmrootwalletkeys_user_key: (a: number) => number;
20
- 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;
21
- export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
22
- export const wasmtransaction_get_vsize: (a: number) => number;
23
- export const wasmtransaction_to_bytes: (a: number, b: number) => void;
24
- export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
25
- export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
26
- export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
27
- export const wrapdescriptor_descType: (a: number, b: number) => void;
28
- export const wrapdescriptor_encode: (a: number, b: number) => void;
29
- export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
30
- export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
31
- export const wrapdescriptor_hasWildcard: (a: number) => number;
32
- export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
33
- export const wrapdescriptor_node: (a: number, b: number) => void;
34
- export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
35
- export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
36
- export const wrapdescriptor_toString: (a: number, b: number) => void;
37
- export const wrapminiscript_encode: (a: number, b: number) => void;
38
- export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
39
- export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
40
- export const wrapminiscript_node: (a: number, b: number) => void;
41
- export const wrapminiscript_toAsmString: (a: number, b: number) => void;
42
- export const wrapminiscript_toString: (a: number, b: number) => void;
43
- export const wrappsbt_clone: (a: number) => number;
44
- export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
45
- export const wrappsbt_finalize: (a: number, b: number) => void;
46
- export const wrappsbt_serialize: (a: number, b: 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_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
50
- export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
51
4
  export const __wbg_addressnamespace_free: (a: number, b: number) => void;
52
5
  export const __wbg_bip322namespace_free: (a: number, b: number) => void;
53
6
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
@@ -94,8 +47,10 @@ export const bitgopsbt_verify_signature_with_xpub: (a: number, b: number, c: num
94
47
  export const bitgopsbt_version: (a: number) => number;
95
48
  export const bitgopsbt_version_group_id: (a: number) => number;
96
49
  export const fixedscriptwalletnamespace_address: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
50
+ export const fixedscriptwalletnamespace_address_with_network_str: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
97
51
  export const fixedscriptwalletnamespace_chain_code_table: () => number;
98
52
  export const fixedscriptwalletnamespace_output_script: (a: number, b: number, c: number, d: number, e: number) => void;
53
+ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
99
54
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
100
55
  export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
101
56
  export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
@@ -120,8 +75,8 @@ export const wasmbip32_public_key: (a: number) => number;
120
75
  export const wasmbip32_to_base58: (a: number, b: number) => void;
121
76
  export const wasmbip32_to_wif: (a: number, b: number) => void;
122
77
  export const wasmdimensions_empty: () => number;
123
- export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
124
- export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number) => void;
78
+ export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
79
+ export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number, d: number) => void;
125
80
  export const wasmdimensions_from_output_script_length: (a: number) => number;
126
81
  export const wasmdimensions_from_output_script_type: (a: number, b: number, c: number) => void;
127
82
  export const wasmdimensions_from_psbt: (a: number, b: number) => void;
@@ -148,6 +103,57 @@ export const wasmreplayprotection_from_addresses: (a: number, b: number, c: numb
148
103
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
149
104
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
150
105
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
106
+ export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
107
+ export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
108
+ export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
109
+ export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
110
+ export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
111
+ export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
112
+ export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
113
+ export const __wbg_wrappsbt_free: (a: number, b: number) => void;
114
+ export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
115
+ 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;
116
+ export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
117
+ export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
118
+ export const wasmrootwalletkeys_backup_key: (a: number) => number;
119
+ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
120
+ export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
121
+ export const wasmrootwalletkeys_user_key: (a: number) => number;
122
+ 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;
123
+ export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
124
+ export const wasmtransaction_get_vsize: (a: number) => number;
125
+ export const wasmtransaction_to_bytes: (a: number, b: number) => void;
126
+ export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
127
+ export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
128
+ export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
129
+ export const wrapdescriptor_descType: (a: number, b: number) => void;
130
+ export const wrapdescriptor_encode: (a: number, b: number) => void;
131
+ export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
132
+ export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
133
+ export const wrapdescriptor_hasWildcard: (a: number) => number;
134
+ export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
135
+ export const wrapdescriptor_node: (a: number, b: number) => void;
136
+ export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
137
+ export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
138
+ export const wrapdescriptor_toString: (a: number, b: number) => void;
139
+ export const wrapminiscript_encode: (a: number, b: number) => void;
140
+ export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
141
+ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
142
+ export const wrapminiscript_node: (a: number, b: number) => void;
143
+ export const wrapminiscript_toAsmString: (a: number, b: number) => void;
144
+ export const wrapminiscript_toString: (a: number, b: number) => void;
145
+ export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
146
+ export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
147
+ export const wrappsbt_clone: (a: number) => number;
148
+ export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
149
+ export const wrappsbt_finalize: (a: number, b: number) => void;
150
+ export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
151
+ export const wrappsbt_new: (a: number, b: number) => number;
152
+ export const wrappsbt_serialize: (a: number, b: number) => void;
153
+ export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
154
+ export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
155
+ export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
156
+ export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
151
157
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
152
158
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
153
159
  export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;