@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,2 +1,67 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coinNames = void 0;
4
+ exports.getMainnet = getMainnet;
5
+ exports.isMainnet = isMainnet;
6
+ exports.isTestnet = isTestnet;
7
+ exports.isCoinName = isCoinName;
8
+ // BitGo coin names (from Network::from_coin_name in src/networks.rs)
9
+ exports.coinNames = [
10
+ "btc",
11
+ "tbtc",
12
+ "tbtc4",
13
+ "tbtcsig",
14
+ "tbtcbgsig",
15
+ "bch",
16
+ "tbch",
17
+ "bcha",
18
+ "tbcha",
19
+ "btg",
20
+ "tbtg",
21
+ "bsv",
22
+ "tbsv",
23
+ "dash",
24
+ "tdash",
25
+ "doge",
26
+ "tdoge",
27
+ "ltc",
28
+ "tltc",
29
+ "zec",
30
+ "tzec",
31
+ ];
32
+ function getMainnet(name) {
33
+ switch (name) {
34
+ case "tbtc":
35
+ case "tbtc4":
36
+ case "tbtcsig":
37
+ case "tbtcbgsig":
38
+ return "btc";
39
+ case "tbch":
40
+ return "bch";
41
+ case "tbcha":
42
+ return "bcha";
43
+ case "tbtg":
44
+ return "btg";
45
+ case "tbsv":
46
+ return "bsv";
47
+ case "tdash":
48
+ return "dash";
49
+ case "tdoge":
50
+ return "doge";
51
+ case "tltc":
52
+ return "ltc";
53
+ case "tzec":
54
+ return "zec";
55
+ default:
56
+ return name;
57
+ }
58
+ }
59
+ function isMainnet(name) {
60
+ return getMainnet(name) === name;
61
+ }
62
+ function isTestnet(name) {
63
+ return getMainnet(name) !== name;
64
+ }
65
+ function isCoinName(v) {
66
+ return exports.coinNames.includes(v);
67
+ }
@@ -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
  */
@@ -36,12 +36,14 @@ class Dimensions {
36
36
  * Create dimensions for a single input
37
37
  *
38
38
  * @param params - Either `{ chain, signPath? }` or `{ scriptType }`
39
+ * @param options - Optional settings like `{ utxolibCompat: true }` for @bitgo/unspents-compatible sizing
39
40
  */
40
- static fromInput(params) {
41
+ static fromInput(params, options) {
42
+ const compat = options?.utxolibCompat;
41
43
  if ("scriptType" in params) {
42
- return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input_script_type(params.scriptType));
44
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input_script_type(params.scriptType, compat));
43
45
  }
44
- return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
46
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
45
47
  }
46
48
  static fromOutput(params, network) {
47
49
  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;
@@ -6,10 +6,19 @@ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
6
6
  const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
7
7
  /**
8
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
9
13
  */
10
14
  function outputScript(keys, chain, index, network) {
11
15
  const walletKeys = RootWalletKeys_js_1.RootWalletKeys.from(keys);
12
- return wasm_utxo_js_1.FixedScriptWalletNamespace.output_script(walletKeys.wasm, chain, index, network);
16
+ if (typeof network === "string") {
17
+ return wasm_utxo_js_1.FixedScriptWalletNamespace.output_script_with_network_str(walletKeys.wasm, chain, index, network);
18
+ }
19
+ else {
20
+ return wasm_utxo_js_1.FixedScriptWalletNamespace.output_script(walletKeys.wasm, chain, index, network);
21
+ }
13
22
  }
14
23
  /**
15
24
  * Create the address for a given wallet keys and chain and index and network.
@@ -17,7 +26,7 @@ function outputScript(keys, chain, index, network) {
17
26
  * @param keys - The wallet keys to use.
18
27
  * @param chain - The chain to use.
19
28
  * @param index - The index to use.
20
- * @param network - The network to use.
29
+ * @param network - The network to use. Can be a network name string (e.g., "btc", "bitcoin", "testnet") or a UtxolibNetwork object
21
30
  * @param addressFormat - The address format to use.
22
31
  * Only relevant for Bitcoin Cash and eCash networks, where:
23
32
  * - "default" means base58check,
@@ -25,5 +34,10 @@ function outputScript(keys, chain, index, network) {
25
34
  */
26
35
  function address(keys, chain, index, network, addressFormat) {
27
36
  const walletKeys = RootWalletKeys_js_1.RootWalletKeys.from(keys);
28
- return wasm_utxo_js_1.FixedScriptWalletNamespace.address(walletKeys.wasm, chain, index, network, addressFormat);
37
+ if (typeof network === "string") {
38
+ return wasm_utxo_js_1.FixedScriptWalletNamespace.address_with_network_str(walletKeys.wasm, chain, index, network, addressFormat);
39
+ }
40
+ else {
41
+ return wasm_utxo_js_1.FixedScriptWalletNamespace.address(walletKeys.wasm, chain, index, network, addressFormat);
42
+ }
29
43
  }
@@ -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
  }
@@ -1573,6 +1573,71 @@ class FixedScriptWalletNamespace {
1573
1573
  wasm.__wbindgen_add_to_stack_pointer(16);
1574
1574
  }
1575
1575
  }
1576
+ /**
1577
+ * @param {WasmRootWalletKeys} keys
1578
+ * @param {number} chain
1579
+ * @param {number} index
1580
+ * @param {string} network
1581
+ * @param {string | null} [address_format]
1582
+ * @returns {string}
1583
+ */
1584
+ static address_with_network_str(keys, chain, index, network, address_format) {
1585
+ let deferred4_0;
1586
+ let deferred4_1;
1587
+ try {
1588
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1589
+ _assertClass(keys, WasmRootWalletKeys);
1590
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1591
+ const len0 = WASM_VECTOR_LEN;
1592
+ var ptr1 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1593
+ var len1 = WASM_VECTOR_LEN;
1594
+ wasm.fixedscriptwalletnamespace_address_with_network_str(retptr, keys.__wbg_ptr, chain, index, ptr0, len0, ptr1, len1);
1595
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1596
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1597
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1598
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1599
+ var ptr3 = r0;
1600
+ var len3 = r1;
1601
+ if (r3) {
1602
+ ptr3 = 0; len3 = 0;
1603
+ throw takeObject(r2);
1604
+ }
1605
+ deferred4_0 = ptr3;
1606
+ deferred4_1 = len3;
1607
+ return getStringFromWasm0(ptr3, len3);
1608
+ } finally {
1609
+ wasm.__wbindgen_add_to_stack_pointer(16);
1610
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
1611
+ }
1612
+ }
1613
+ /**
1614
+ * @param {WasmRootWalletKeys} keys
1615
+ * @param {number} chain
1616
+ * @param {number} index
1617
+ * @param {string} network
1618
+ * @returns {Uint8Array}
1619
+ */
1620
+ static output_script_with_network_str(keys, chain, index, network) {
1621
+ try {
1622
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1623
+ _assertClass(keys, WasmRootWalletKeys);
1624
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1625
+ const len0 = WASM_VECTOR_LEN;
1626
+ wasm.fixedscriptwalletnamespace_output_script_with_network_str(retptr, keys.__wbg_ptr, chain, index, ptr0, len0);
1627
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1628
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1629
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1630
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1631
+ if (r3) {
1632
+ throw takeObject(r2);
1633
+ }
1634
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1635
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1636
+ return v2;
1637
+ } finally {
1638
+ wasm.__wbindgen_add_to_stack_pointer(16);
1639
+ }
1640
+ }
1576
1641
  /**
1577
1642
  * @param {WasmRootWalletKeys} keys
1578
1643
  * @param {number} chain
@@ -2256,19 +2321,21 @@ class WasmDimensions {
2256
2321
  * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
2257
2322
  * * `signer` - Optional signer key ("user", "backup", "bitgo")
2258
2323
  * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
2324
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
2259
2325
  * @param {number} chain
2260
2326
  * @param {string | null} [signer]
2261
2327
  * @param {string | null} [cosigner]
2328
+ * @param {boolean | null} [compat]
2262
2329
  * @returns {WasmDimensions}
2263
2330
  */
2264
- static from_input(chain, signer, cosigner) {
2331
+ static from_input(chain, signer, cosigner, compat) {
2265
2332
  try {
2266
2333
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2267
2334
  var ptr0 = isLikeNone(signer) ? 0 : passStringToWasm0(signer, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2268
2335
  var len0 = WASM_VECTOR_LEN;
2269
2336
  var ptr1 = isLikeNone(cosigner) ? 0 : passStringToWasm0(cosigner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2270
2337
  var len1 = WASM_VECTOR_LEN;
2271
- wasm.wasmdimensions_from_input(retptr, chain, ptr0, len0, ptr1, len1);
2338
+ wasm.wasmdimensions_from_input(retptr, chain, ptr0, len0, ptr1, len1, isLikeNone(compat) ? 0xFFFFFF : compat ? 1 : 0);
2272
2339
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2273
2340
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2274
2341
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2352,15 +2419,17 @@ class WasmDimensions {
2352
2419
  * # Arguments
2353
2420
  * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
2354
2421
  * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
2422
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
2355
2423
  * @param {string} script_type
2424
+ * @param {boolean | null} [compat]
2356
2425
  * @returns {WasmDimensions}
2357
2426
  */
2358
- static from_input_script_type(script_type) {
2427
+ static from_input_script_type(script_type, compat) {
2359
2428
  try {
2360
2429
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2361
2430
  const ptr0 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2362
2431
  const len0 = WASM_VECTOR_LEN;
2363
- wasm.wasmdimensions_from_input_script_type(retptr, ptr0, len0);
2432
+ wasm.wasmdimensions_from_input_script_type(retptr, ptr0, len0, isLikeNone(compat) ? 0xFFFFFF : compat ? 1 : 0);
2364
2433
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2365
2434
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2366
2435
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -3550,6 +3619,25 @@ class WrapPsbt {
3550
3619
  const ptr = this.__destroy_into_raw();
3551
3620
  wasm.__wbg_wrappsbt_free(ptr, 0);
3552
3621
  }
3622
+ /**
3623
+ * Add an output to the PSBT
3624
+ *
3625
+ * # Arguments
3626
+ * * `script` - The output script (scriptPubKey)
3627
+ * * `value` - Value in satoshis
3628
+ *
3629
+ * # Returns
3630
+ * The index of the newly added output
3631
+ * @param {Uint8Array} script
3632
+ * @param {bigint} value
3633
+ * @returns {number}
3634
+ */
3635
+ addOutput(script, value) {
3636
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export);
3637
+ const len0 = WASM_VECTOR_LEN;
3638
+ const ret = wasm.wrappsbt_addOutput(this.__wbg_ptr, ptr0, len0, value);
3639
+ return ret >>> 0;
3640
+ }
3553
3641
  /**
3554
3642
  * @param {Uint8Array} psbt
3555
3643
  * @returns {WrapPsbt}
@@ -3626,6 +3714,26 @@ class WrapPsbt {
3626
3714
  wasm.__wbindgen_add_to_stack_pointer(16);
3627
3715
  }
3628
3716
  }
3717
+ /**
3718
+ * Get the unsigned transaction bytes
3719
+ *
3720
+ * # Returns
3721
+ * The serialized unsigned transaction
3722
+ * @returns {Uint8Array}
3723
+ */
3724
+ getUnsignedTx() {
3725
+ try {
3726
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3727
+ wasm.wrappsbt_getUnsignedTx(retptr, this.__wbg_ptr);
3728
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3729
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3730
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3731
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
3732
+ return v1;
3733
+ } finally {
3734
+ wasm.__wbindgen_add_to_stack_pointer(16);
3735
+ }
3736
+ }
3629
3737
  /**
3630
3738
  * @param {number} input_index
3631
3739
  * @param {WrapDescriptor} descriptor
@@ -3662,6 +3770,21 @@ class WrapPsbt {
3662
3770
  wasm.__wbindgen_add_to_stack_pointer(16);
3663
3771
  }
3664
3772
  }
3773
+ /**
3774
+ * Create an empty PSBT
3775
+ *
3776
+ * # Arguments
3777
+ * * `version` - Transaction version (default: 2)
3778
+ * * `lock_time` - Transaction lock time (default: 0)
3779
+ * @param {number | null} [version]
3780
+ * @param {number | null} [lock_time]
3781
+ */
3782
+ constructor(version, lock_time) {
3783
+ const ret = wasm.wrappsbt_new(isLikeNone(version) ? 0x100000001 : (version) >> 0, isLikeNone(lock_time) ? 0x100000001 : (lock_time) >>> 0);
3784
+ this.__wbg_ptr = ret >>> 0;
3785
+ WrapPsbtFinalization.register(this, this.__wbg_ptr, this);
3786
+ return this;
3787
+ }
3665
3788
  /**
3666
3789
  * @returns {WrapPsbt}
3667
3790
  */
@@ -3669,6 +3792,44 @@ class WrapPsbt {
3669
3792
  const ret = wasm.wrappsbt_clone(this.__wbg_ptr);
3670
3793
  return WrapPsbt.__wrap(ret);
3671
3794
  }
3795
+ /**
3796
+ * Add an input to the PSBT
3797
+ *
3798
+ * # Arguments
3799
+ * * `txid` - Transaction ID (hex string, 32 bytes reversed)
3800
+ * * `vout` - Output index being spent
3801
+ * * `value` - Value in satoshis of the output being spent
3802
+ * * `script` - The scriptPubKey of the output being spent
3803
+ * * `sequence` - Sequence number (default: 0xFFFFFFFE for RBF)
3804
+ *
3805
+ * # Returns
3806
+ * The index of the newly added input
3807
+ * @param {string} txid
3808
+ * @param {number} vout
3809
+ * @param {bigint} value
3810
+ * @param {Uint8Array} script
3811
+ * @param {number | null} [sequence]
3812
+ * @returns {number}
3813
+ */
3814
+ addInput(txid, vout, value, script, sequence) {
3815
+ try {
3816
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3817
+ const ptr0 = passStringToWasm0(txid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
3818
+ const len0 = WASM_VECTOR_LEN;
3819
+ const ptr1 = passArray8ToWasm0(script, wasm.__wbindgen_export);
3820
+ const len1 = WASM_VECTOR_LEN;
3821
+ wasm.wrappsbt_addInput(retptr, this.__wbg_ptr, ptr0, len0, vout, value, ptr1, len1, isLikeNone(sequence) ? 0x100000001 : (sequence) >>> 0);
3822
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3823
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3824
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3825
+ if (r2) {
3826
+ throw takeObject(r1);
3827
+ }
3828
+ return r0 >>> 0;
3829
+ } finally {
3830
+ wasm.__wbindgen_add_to_stack_pointer(16);
3831
+ }
3832
+ }
3672
3833
  /**
3673
3834
  * @returns {Uint8Array}
3674
3835
  */
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;