@bitgo/wasm-utxo 1.23.0 → 1.25.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,5 +1,6 @@
1
1
  import type { BitGoPsbt, InputScriptType, SignPath } from "./BitGoPsbt.js";
2
2
  import type { CoinName } from "../coinName.js";
3
+ import type { OutputScriptType } from "./scriptType.js";
3
4
  type FromInputParams = {
4
5
  chain: number;
5
6
  signPath?: SignPath;
@@ -43,6 +44,18 @@ export declare class Dimensions {
43
44
  * Create dimensions for a single output from an address
44
45
  */
45
46
  static fromOutput(address: string, network: CoinName): Dimensions;
47
+ /**
48
+ * Create dimensions for a single output from script length only
49
+ */
50
+ static fromOutput(params: {
51
+ length: number;
52
+ }): Dimensions;
53
+ /**
54
+ * Create dimensions for a single output from script type
55
+ */
56
+ static fromOutput(params: {
57
+ scriptType: OutputScriptType;
58
+ }): Dimensions;
46
59
  /**
47
60
  * Combine with another Dimensions instance
48
61
  */
@@ -43,15 +43,19 @@ class Dimensions {
43
43
  }
44
44
  return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
45
45
  }
46
- static fromOutput(scriptOrAddress, network) {
47
- if (typeof scriptOrAddress === "string") {
46
+ static fromOutput(params, network) {
47
+ if (typeof params === "string") {
48
48
  if (network === undefined) {
49
49
  throw new Error("network is required when passing an address string");
50
50
  }
51
- const script = (0, address_js_1.toOutputScriptWithCoin)(scriptOrAddress, network);
52
- return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script(script));
51
+ const script = (0, address_js_1.toOutputScriptWithCoin)(params, network);
52
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(script.length));
53
53
  }
54
- return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script(scriptOrAddress));
54
+ if (typeof params === "object" && "scriptType" in params) {
55
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_type(params.scriptType));
56
+ }
57
+ // Both Uint8Array and { length: number } have .length
58
+ return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(params.length));
55
59
  }
56
60
  /**
57
61
  * Combine with another Dimensions instance
@@ -1,6 +1,7 @@
1
1
  export * as address from "./address.js";
2
2
  export * as ast from "./ast/index.js";
3
3
  export * as bip322 from "./bip322/index.js";
4
+ export * as inscriptions from "./inscriptions.js";
4
5
  export * as utxolibCompat from "./utxolibCompat.js";
5
6
  export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
6
7
  export * as bip32 from "./bip32.js";
@@ -11,6 +12,7 @@ export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
11
12
  export type { CoinName } from "./coinName.js";
12
13
  export type { Triple } from "./triple.js";
13
14
  export type { AddressFormat } from "./address.js";
15
+ export type { TapLeafScript, PreparedInscriptionRevealData } from "./inscriptions.js";
14
16
  export type DescriptorPkType = "derivable" | "definite" | "string";
15
17
  export type ScriptContext = "tap" | "segwitv0" | "legacy";
16
18
  export type SignPsbtResult = {
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.bip322 = exports.ast = exports.address = void 0;
36
+ exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.inscriptions = exports.bip322 = exports.ast = exports.address = void 0;
37
37
  const wasm = __importStar(require("./wasm/wasm_utxo.js"));
38
38
  // we need to access the wasm module here, otherwise webpack gets all weird
39
39
  // and forgets to include it in the bundle
@@ -43,6 +43,7 @@ void wasm;
43
43
  exports.address = __importStar(require("./address.js"));
44
44
  exports.ast = __importStar(require("./ast/index.js"));
45
45
  exports.bip322 = __importStar(require("./bip322/index.js"));
46
+ exports.inscriptions = __importStar(require("./inscriptions.js"));
46
47
  exports.utxolibCompat = __importStar(require("./utxolibCompat.js"));
47
48
  exports.fixedScriptWallet = __importStar(require("./fixedScriptWallet/index.js"));
48
49
  exports.bip32 = __importStar(require("./bip32.js"));
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Inscription support for Bitcoin Ordinals
3
+ *
4
+ * This module provides functionality for creating and signing inscription
5
+ * reveal transactions following the Ordinals protocol.
6
+ *
7
+ * @see https://docs.ordinals.com/inscriptions.html
8
+ */
9
+ import { Transaction } from "./transaction.js";
10
+ import { type ECPairArg } from "./ecpair.js";
11
+ /**
12
+ * Taproot leaf script data needed for spending
13
+ */
14
+ export type TapLeafScript = {
15
+ /** Leaf version (typically 0xc0 for TapScript) */
16
+ leafVersion: number;
17
+ /** The compiled script bytes */
18
+ script: Uint8Array;
19
+ /** Control block for script path spending */
20
+ controlBlock: Uint8Array;
21
+ };
22
+ /**
23
+ * Prepared data for an inscription reveal transaction
24
+ */
25
+ export type PreparedInscriptionRevealData = {
26
+ /** The commit output script (P2TR, network-agnostic) */
27
+ outputScript: Uint8Array;
28
+ /** Estimated virtual size of the reveal transaction */
29
+ revealTransactionVSize: number;
30
+ /** Tap leaf script for spending the commit output */
31
+ tapLeafScript: TapLeafScript;
32
+ };
33
+ /**
34
+ * Create inscription reveal data including the commit output script and tap leaf script
35
+ *
36
+ * This function creates all the data needed to perform an inscription:
37
+ * 1. A P2TR output script for the commit transaction (network-agnostic)
38
+ * 2. The tap leaf script needed to spend from that output
39
+ * 3. An estimate of the reveal transaction's virtual size for fee calculation
40
+ *
41
+ * @param key - The key pair (ECPairArg: Uint8Array, ECPair, or WasmECPair). The x-only public key will be extracted.
42
+ * @param contentType - MIME type of the inscription (e.g., "text/plain", "image/png")
43
+ * @param inscriptionData - The inscription data bytes
44
+ * @returns PreparedInscriptionRevealData containing output script, vsize estimate, and tap leaf script
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const revealData = createInscriptionRevealData(
49
+ * ecpair,
50
+ * "text/plain",
51
+ * new TextEncoder().encode("Hello, Ordinals!"),
52
+ * );
53
+ * // Use address.fromOutputScriptWithCoin() to get address for a specific network
54
+ * console.log(`Estimated reveal vsize: ${revealData.revealTransactionVSize}`);
55
+ * ```
56
+ */
57
+ export declare function createInscriptionRevealData(key: ECPairArg, contentType: string, inscriptionData: Uint8Array): PreparedInscriptionRevealData;
58
+ /**
59
+ * Sign a reveal transaction
60
+ *
61
+ * Creates and signs the reveal transaction that spends from the commit output
62
+ * and sends the inscription to the recipient.
63
+ *
64
+ * @param key - The private key (ECPairArg: Uint8Array, ECPair, or WasmECPair)
65
+ * @param tapLeafScript - The tap leaf script from createInscriptionRevealData
66
+ * @param commitTx - The commit transaction
67
+ * @param commitOutputScript - The commit output script (P2TR)
68
+ * @param recipientOutputScript - Where to send the inscription (output script)
69
+ * @param outputValueSats - Value in satoshis for the inscription output
70
+ * @returns The signed transaction as bytes (ready to broadcast)
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const txBytes = signRevealTransaction(
75
+ * privateKey,
76
+ * revealData.tapLeafScript,
77
+ * commitTx,
78
+ * revealData.outputScript,
79
+ * recipientOutputScript,
80
+ * 10000n, // 10,000 sats
81
+ * );
82
+ * ```
83
+ */
84
+ export declare function signRevealTransaction(key: ECPairArg, tapLeafScript: TapLeafScript, commitTx: Transaction, commitOutputScript: Uint8Array, recipientOutputScript: Uint8Array, outputValueSats: bigint): Uint8Array;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /**
3
+ * Inscription support for Bitcoin Ordinals
4
+ *
5
+ * This module provides functionality for creating and signing inscription
6
+ * reveal transactions following the Ordinals protocol.
7
+ *
8
+ * @see https://docs.ordinals.com/inscriptions.html
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.createInscriptionRevealData = createInscriptionRevealData;
12
+ exports.signRevealTransaction = signRevealTransaction;
13
+ const wasm_utxo_js_1 = require("./wasm/wasm_utxo.js");
14
+ const ecpair_js_1 = require("./ecpair.js");
15
+ /**
16
+ * Create inscription reveal data including the commit output script and tap leaf script
17
+ *
18
+ * This function creates all the data needed to perform an inscription:
19
+ * 1. A P2TR output script for the commit transaction (network-agnostic)
20
+ * 2. The tap leaf script needed to spend from that output
21
+ * 3. An estimate of the reveal transaction's virtual size for fee calculation
22
+ *
23
+ * @param key - The key pair (ECPairArg: Uint8Array, ECPair, or WasmECPair). The x-only public key will be extracted.
24
+ * @param contentType - MIME type of the inscription (e.g., "text/plain", "image/png")
25
+ * @param inscriptionData - The inscription data bytes
26
+ * @returns PreparedInscriptionRevealData containing output script, vsize estimate, and tap leaf script
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const revealData = createInscriptionRevealData(
31
+ * ecpair,
32
+ * "text/plain",
33
+ * new TextEncoder().encode("Hello, Ordinals!"),
34
+ * );
35
+ * // Use address.fromOutputScriptWithCoin() to get address for a specific network
36
+ * console.log(`Estimated reveal vsize: ${revealData.revealTransactionVSize}`);
37
+ * ```
38
+ */
39
+ function createInscriptionRevealData(key, contentType, inscriptionData) {
40
+ // Convert to ECPair and extract x-only public key (strip parity byte from compressed pubkey)
41
+ const ecpair = ecpair_js_1.ECPair.from(key);
42
+ const compressedPubkey = ecpair.publicKey;
43
+ const xOnlyPubkey = compressedPubkey.slice(1); // Remove first byte (parity)
44
+ // Call snake_case WASM method (traits output camelCase)
45
+ return wasm_utxo_js_1.InscriptionsNamespace.create_inscription_reveal_data(xOnlyPubkey, contentType, inscriptionData);
46
+ }
47
+ /**
48
+ * Sign a reveal transaction
49
+ *
50
+ * Creates and signs the reveal transaction that spends from the commit output
51
+ * and sends the inscription to the recipient.
52
+ *
53
+ * @param key - The private key (ECPairArg: Uint8Array, ECPair, or WasmECPair)
54
+ * @param tapLeafScript - The tap leaf script from createInscriptionRevealData
55
+ * @param commitTx - The commit transaction
56
+ * @param commitOutputScript - The commit output script (P2TR)
57
+ * @param recipientOutputScript - Where to send the inscription (output script)
58
+ * @param outputValueSats - Value in satoshis for the inscription output
59
+ * @returns The signed transaction as bytes (ready to broadcast)
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const txBytes = signRevealTransaction(
64
+ * privateKey,
65
+ * revealData.tapLeafScript,
66
+ * commitTx,
67
+ * revealData.outputScript,
68
+ * recipientOutputScript,
69
+ * 10000n, // 10,000 sats
70
+ * );
71
+ * ```
72
+ */
73
+ function signRevealTransaction(key, tapLeafScript, commitTx, commitOutputScript, recipientOutputScript, outputValueSats) {
74
+ // Convert to ECPair to get private key bytes
75
+ const ecpair = ecpair_js_1.ECPair.from(key);
76
+ const privateKey = ecpair.privateKey;
77
+ if (!privateKey) {
78
+ throw new Error("ECPair must have a private key for signing");
79
+ }
80
+ // Call snake_case WASM method
81
+ return wasm_utxo_js_1.InscriptionsNamespace.sign_reveal_transaction(privateKey, tapLeafScript, commitTx.wasm, commitOutputScript, recipientOutputScript, outputValueSats);
82
+ }
@@ -507,6 +507,42 @@ export class FixedScriptWalletNamespace {
507
507
  static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
508
508
  }
509
509
 
510
+ export class InscriptionsNamespace {
511
+ private constructor();
512
+ free(): void;
513
+ [Symbol.dispose](): void;
514
+ /**
515
+ * Sign a reveal transaction
516
+ *
517
+ * # Arguments
518
+ * * `private_key` - The private key (32 bytes)
519
+ * * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
520
+ * * `commit_tx` - The commit transaction
521
+ * * `commit_output_script` - The commit output script (P2TR)
522
+ * * `recipient_output_script` - Where to send the inscription (output script)
523
+ * * `output_value_sats` - Value in satoshis for the inscription output
524
+ *
525
+ * # Returns
526
+ * The signed PSBT as bytes
527
+ */
528
+ static sign_reveal_transaction(private_key: Uint8Array, tap_leaf_script: any, commit_tx: WasmTransaction, commit_output_script: Uint8Array, recipient_output_script: Uint8Array, output_value_sats: bigint): Uint8Array;
529
+ /**
530
+ * Create inscription reveal data including the commit output script and tap leaf script
531
+ *
532
+ * # Arguments
533
+ * * `x_only_pubkey` - The x-only public key (32 bytes)
534
+ * * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
535
+ * * `inscription_data` - The inscription data bytes
536
+ *
537
+ * # Returns
538
+ * An object containing:
539
+ * - `output_script`: The commit output script (P2TR, network-agnostic)
540
+ * - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
541
+ * - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
542
+ */
543
+ static create_inscription_reveal_data(x_only_pubkey: Uint8Array, content_type: string, inscription_data: Uint8Array): any;
544
+ }
545
+
510
546
  export class UtxolibCompatNamespace {
511
547
  private constructor();
512
548
  free(): void;
@@ -684,10 +720,6 @@ export class WasmDimensions {
684
720
  * Get output weight
685
721
  */
686
722
  get_output_weight(): number;
687
- /**
688
- * Create dimensions for a single output from script bytes
689
- */
690
- static from_output_script(script: Uint8Array): WasmDimensions;
691
723
  /**
692
724
  * Create dimensions for a single input from script type string
693
725
  *
@@ -696,6 +728,17 @@ export class WasmDimensions {
696
728
  * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
697
729
  */
698
730
  static from_input_script_type(script_type: string): WasmDimensions;
731
+ /**
732
+ * Create dimensions for a single output from script type string
733
+ *
734
+ * # Arguments
735
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
736
+ */
737
+ static from_output_script_type(script_type: string): WasmDimensions;
738
+ /**
739
+ * Create dimensions for a single output from script length
740
+ */
741
+ static from_output_script_length(length: number): WasmDimensions;
699
742
  /**
700
743
  * Combine with another Dimensions instance
701
744
  */
@@ -196,6 +196,10 @@ const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry ===
196
196
  ? { register: () => {}, unregister: () => {} }
197
197
  : new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
198
198
 
199
+ const InscriptionsNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
200
+ ? { register: () => {}, unregister: () => {} }
201
+ : new FinalizationRegistry(ptr => wasm.__wbg_inscriptionsnamespace_free(ptr >>> 0, 1));
202
+
199
203
  const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
200
204
  ? { register: () => {}, unregister: () => {} }
201
205
  : new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
@@ -1608,6 +1612,109 @@ class FixedScriptWalletNamespace {
1608
1612
  if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
1609
1613
  exports.FixedScriptWalletNamespace = FixedScriptWalletNamespace;
1610
1614
 
1615
+ /**
1616
+ * Namespace for inscription-related functions
1617
+ */
1618
+ class InscriptionsNamespace {
1619
+ __destroy_into_raw() {
1620
+ const ptr = this.__wbg_ptr;
1621
+ this.__wbg_ptr = 0;
1622
+ InscriptionsNamespaceFinalization.unregister(this);
1623
+ return ptr;
1624
+ }
1625
+ free() {
1626
+ const ptr = this.__destroy_into_raw();
1627
+ wasm.__wbg_inscriptionsnamespace_free(ptr, 0);
1628
+ }
1629
+ /**
1630
+ * Sign a reveal transaction
1631
+ *
1632
+ * # Arguments
1633
+ * * `private_key` - The private key (32 bytes)
1634
+ * * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
1635
+ * * `commit_tx` - The commit transaction
1636
+ * * `commit_output_script` - The commit output script (P2TR)
1637
+ * * `recipient_output_script` - Where to send the inscription (output script)
1638
+ * * `output_value_sats` - Value in satoshis for the inscription output
1639
+ *
1640
+ * # Returns
1641
+ * The signed PSBT as bytes
1642
+ * @param {Uint8Array} private_key
1643
+ * @param {any} tap_leaf_script
1644
+ * @param {WasmTransaction} commit_tx
1645
+ * @param {Uint8Array} commit_output_script
1646
+ * @param {Uint8Array} recipient_output_script
1647
+ * @param {bigint} output_value_sats
1648
+ * @returns {Uint8Array}
1649
+ */
1650
+ static sign_reveal_transaction(private_key, tap_leaf_script, commit_tx, commit_output_script, recipient_output_script, output_value_sats) {
1651
+ try {
1652
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1653
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_export);
1654
+ const len0 = WASM_VECTOR_LEN;
1655
+ _assertClass(commit_tx, WasmTransaction);
1656
+ const ptr1 = passArray8ToWasm0(commit_output_script, wasm.__wbindgen_export);
1657
+ const len1 = WASM_VECTOR_LEN;
1658
+ const ptr2 = passArray8ToWasm0(recipient_output_script, wasm.__wbindgen_export);
1659
+ const len2 = WASM_VECTOR_LEN;
1660
+ wasm.inscriptionsnamespace_sign_reveal_transaction(retptr, ptr0, len0, addHeapObject(tap_leaf_script), commit_tx.__wbg_ptr, ptr1, len1, ptr2, len2, output_value_sats);
1661
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1662
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1663
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1664
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1665
+ if (r3) {
1666
+ throw takeObject(r2);
1667
+ }
1668
+ var v4 = getArrayU8FromWasm0(r0, r1).slice();
1669
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1670
+ return v4;
1671
+ } finally {
1672
+ wasm.__wbindgen_add_to_stack_pointer(16);
1673
+ }
1674
+ }
1675
+ /**
1676
+ * Create inscription reveal data including the commit output script and tap leaf script
1677
+ *
1678
+ * # Arguments
1679
+ * * `x_only_pubkey` - The x-only public key (32 bytes)
1680
+ * * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
1681
+ * * `inscription_data` - The inscription data bytes
1682
+ *
1683
+ * # Returns
1684
+ * An object containing:
1685
+ * - `output_script`: The commit output script (P2TR, network-agnostic)
1686
+ * - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
1687
+ * - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
1688
+ * @param {Uint8Array} x_only_pubkey
1689
+ * @param {string} content_type
1690
+ * @param {Uint8Array} inscription_data
1691
+ * @returns {any}
1692
+ */
1693
+ static create_inscription_reveal_data(x_only_pubkey, content_type, inscription_data) {
1694
+ try {
1695
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1696
+ const ptr0 = passArray8ToWasm0(x_only_pubkey, wasm.__wbindgen_export);
1697
+ const len0 = WASM_VECTOR_LEN;
1698
+ const ptr1 = passStringToWasm0(content_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1699
+ const len1 = WASM_VECTOR_LEN;
1700
+ const ptr2 = passArray8ToWasm0(inscription_data, wasm.__wbindgen_export);
1701
+ const len2 = WASM_VECTOR_LEN;
1702
+ wasm.inscriptionsnamespace_create_inscription_reveal_data(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1703
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1704
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1705
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1706
+ if (r2) {
1707
+ throw takeObject(r1);
1708
+ }
1709
+ return takeObject(r0);
1710
+ } finally {
1711
+ wasm.__wbindgen_add_to_stack_pointer(16);
1712
+ }
1713
+ }
1714
+ }
1715
+ if (Symbol.dispose) InscriptionsNamespace.prototype[Symbol.dispose] = InscriptionsNamespace.prototype.free;
1716
+ exports.InscriptionsNamespace = InscriptionsNamespace;
1717
+
1611
1718
  class UtxolibCompatNamespace {
1612
1719
  __destroy_into_raw() {
1613
1720
  const ptr = this.__wbg_ptr;
@@ -2239,17 +2346,6 @@ class WasmDimensions {
2239
2346
  const ret = wasm.wasmdimensions_get_output_weight(this.__wbg_ptr);
2240
2347
  return ret >>> 0;
2241
2348
  }
2242
- /**
2243
- * Create dimensions for a single output from script bytes
2244
- * @param {Uint8Array} script
2245
- * @returns {WasmDimensions}
2246
- */
2247
- static from_output_script(script) {
2248
- const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export);
2249
- const len0 = WASM_VECTOR_LEN;
2250
- const ret = wasm.wasmdimensions_from_output_script(ptr0, len0);
2251
- return WasmDimensions.__wrap(ret);
2252
- }
2253
2349
  /**
2254
2350
  * Create dimensions for a single input from script type string
2255
2351
  *
@@ -2276,6 +2372,40 @@ class WasmDimensions {
2276
2372
  wasm.__wbindgen_add_to_stack_pointer(16);
2277
2373
  }
2278
2374
  }
2375
+ /**
2376
+ * Create dimensions for a single output from script type string
2377
+ *
2378
+ * # Arguments
2379
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
2380
+ * @param {string} script_type
2381
+ * @returns {WasmDimensions}
2382
+ */
2383
+ static from_output_script_type(script_type) {
2384
+ try {
2385
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2386
+ const ptr0 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2387
+ const len0 = WASM_VECTOR_LEN;
2388
+ wasm.wasmdimensions_from_output_script_type(retptr, ptr0, len0);
2389
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2390
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2391
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2392
+ if (r2) {
2393
+ throw takeObject(r1);
2394
+ }
2395
+ return WasmDimensions.__wrap(r0);
2396
+ } finally {
2397
+ wasm.__wbindgen_add_to_stack_pointer(16);
2398
+ }
2399
+ }
2400
+ /**
2401
+ * Create dimensions for a single output from script length
2402
+ * @param {number} length
2403
+ * @returns {WasmDimensions}
2404
+ */
2405
+ static from_output_script_length(length) {
2406
+ const ret = wasm.wasmdimensions_from_output_script_length(length);
2407
+ return WasmDimensions.__wrap(ret);
2408
+ }
2279
2409
  /**
2280
2410
  * Combine with another Dimensions instance
2281
2411
  * @param {WasmDimensions} other
Binary file
@@ -1,11 +1,23 @@
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;
4
7
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
5
8
  export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
6
9
  export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
7
10
  export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
8
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;
9
21
  export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
10
22
  export const wasmtransaction_get_vsize: (a: number) => number;
11
23
  export const wasmtransaction_to_bytes: (a: number, b: number) => void;
@@ -42,11 +54,9 @@ export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
42
54
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
43
55
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
44
56
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
45
- export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
46
57
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
47
58
  export const __wbg_wasmecpair_free: (a: number, b: number) => void;
48
59
  export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
49
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
50
60
  export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
51
61
  export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
52
62
  export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
@@ -109,12 +119,11 @@ export const wasmbip32_private_key: (a: number) => number;
109
119
  export const wasmbip32_public_key: (a: number) => number;
110
120
  export const wasmbip32_to_base58: (a: number, b: number) => void;
111
121
  export const wasmbip32_to_wif: (a: number, b: number) => void;
112
- export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
113
- export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
114
122
  export const wasmdimensions_empty: () => number;
115
123
  export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
116
124
  export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number) => void;
117
- export const wasmdimensions_from_output_script: (a: number, b: number) => number;
125
+ export const wasmdimensions_from_output_script_length: (a: number) => number;
126
+ export const wasmdimensions_from_output_script_type: (a: number, b: number, c: number) => void;
118
127
  export const wasmdimensions_from_psbt: (a: number, b: number) => void;
119
128
  export const wasmdimensions_get_input_vsize: (a: number, b: number, c: number) => number;
120
129
  export const wasmdimensions_get_input_weight: (a: number, b: number, c: number) => number;
@@ -138,11 +147,6 @@ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
138
147
  export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
139
148
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
140
149
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
141
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
142
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
143
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
144
- export const wasmrootwalletkeys_user_key: (a: number) => number;
145
- 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;
146
150
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
147
151
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
148
152
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
@@ -1,5 +1,6 @@
1
1
  import type { BitGoPsbt, InputScriptType, SignPath } from "./BitGoPsbt.js";
2
2
  import type { CoinName } from "../coinName.js";
3
+ import type { OutputScriptType } from "./scriptType.js";
3
4
  type FromInputParams = {
4
5
  chain: number;
5
6
  signPath?: SignPath;
@@ -43,6 +44,18 @@ export declare class Dimensions {
43
44
  * Create dimensions for a single output from an address
44
45
  */
45
46
  static fromOutput(address: string, network: CoinName): Dimensions;
47
+ /**
48
+ * Create dimensions for a single output from script length only
49
+ */
50
+ static fromOutput(params: {
51
+ length: number;
52
+ }): Dimensions;
53
+ /**
54
+ * Create dimensions for a single output from script type
55
+ */
56
+ static fromOutput(params: {
57
+ scriptType: OutputScriptType;
58
+ }): Dimensions;
46
59
  /**
47
60
  * Combine with another Dimensions instance
48
61
  */
@@ -40,15 +40,19 @@ export class Dimensions {
40
40
  }
41
41
  return new Dimensions(WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner));
42
42
  }
43
- static fromOutput(scriptOrAddress, network) {
44
- if (typeof scriptOrAddress === "string") {
43
+ static fromOutput(params, network) {
44
+ if (typeof params === "string") {
45
45
  if (network === undefined) {
46
46
  throw new Error("network is required when passing an address string");
47
47
  }
48
- const script = toOutputScriptWithCoin(scriptOrAddress, network);
49
- return new Dimensions(WasmDimensions.from_output_script(script));
48
+ const script = toOutputScriptWithCoin(params, network);
49
+ return new Dimensions(WasmDimensions.from_output_script_length(script.length));
50
50
  }
51
- return new Dimensions(WasmDimensions.from_output_script(scriptOrAddress));
51
+ if (typeof params === "object" && "scriptType" in params) {
52
+ return new Dimensions(WasmDimensions.from_output_script_type(params.scriptType));
53
+ }
54
+ // Both Uint8Array and { length: number } have .length
55
+ return new Dimensions(WasmDimensions.from_output_script_length(params.length));
52
56
  }
53
57
  /**
54
58
  * Combine with another Dimensions instance
@@ -1,6 +1,7 @@
1
1
  export * as address from "./address.js";
2
2
  export * as ast from "./ast/index.js";
3
3
  export * as bip322 from "./bip322/index.js";
4
+ export * as inscriptions from "./inscriptions.js";
4
5
  export * as utxolibCompat from "./utxolibCompat.js";
5
6
  export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
6
7
  export * as bip32 from "./bip32.js";
@@ -11,6 +12,7 @@ export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
11
12
  export type { CoinName } from "./coinName.js";
12
13
  export type { Triple } from "./triple.js";
13
14
  export type { AddressFormat } from "./address.js";
15
+ export type { TapLeafScript, PreparedInscriptionRevealData } from "./inscriptions.js";
14
16
  export type DescriptorPkType = "derivable" | "definite" | "string";
15
17
  export type ScriptContext = "tap" | "segwitv0" | "legacy";
16
18
  export type SignPsbtResult = {
@@ -7,6 +7,7 @@ void wasm;
7
7
  export * as address from "./address.js";
8
8
  export * as ast from "./ast/index.js";
9
9
  export * as bip322 from "./bip322/index.js";
10
+ export * as inscriptions from "./inscriptions.js";
10
11
  export * as utxolibCompat from "./utxolibCompat.js";
11
12
  export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
12
13
  export * as bip32 from "./bip32.js";
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Inscription support for Bitcoin Ordinals
3
+ *
4
+ * This module provides functionality for creating and signing inscription
5
+ * reveal transactions following the Ordinals protocol.
6
+ *
7
+ * @see https://docs.ordinals.com/inscriptions.html
8
+ */
9
+ import { Transaction } from "./transaction.js";
10
+ import { type ECPairArg } from "./ecpair.js";
11
+ /**
12
+ * Taproot leaf script data needed for spending
13
+ */
14
+ export type TapLeafScript = {
15
+ /** Leaf version (typically 0xc0 for TapScript) */
16
+ leafVersion: number;
17
+ /** The compiled script bytes */
18
+ script: Uint8Array;
19
+ /** Control block for script path spending */
20
+ controlBlock: Uint8Array;
21
+ };
22
+ /**
23
+ * Prepared data for an inscription reveal transaction
24
+ */
25
+ export type PreparedInscriptionRevealData = {
26
+ /** The commit output script (P2TR, network-agnostic) */
27
+ outputScript: Uint8Array;
28
+ /** Estimated virtual size of the reveal transaction */
29
+ revealTransactionVSize: number;
30
+ /** Tap leaf script for spending the commit output */
31
+ tapLeafScript: TapLeafScript;
32
+ };
33
+ /**
34
+ * Create inscription reveal data including the commit output script and tap leaf script
35
+ *
36
+ * This function creates all the data needed to perform an inscription:
37
+ * 1. A P2TR output script for the commit transaction (network-agnostic)
38
+ * 2. The tap leaf script needed to spend from that output
39
+ * 3. An estimate of the reveal transaction's virtual size for fee calculation
40
+ *
41
+ * @param key - The key pair (ECPairArg: Uint8Array, ECPair, or WasmECPair). The x-only public key will be extracted.
42
+ * @param contentType - MIME type of the inscription (e.g., "text/plain", "image/png")
43
+ * @param inscriptionData - The inscription data bytes
44
+ * @returns PreparedInscriptionRevealData containing output script, vsize estimate, and tap leaf script
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const revealData = createInscriptionRevealData(
49
+ * ecpair,
50
+ * "text/plain",
51
+ * new TextEncoder().encode("Hello, Ordinals!"),
52
+ * );
53
+ * // Use address.fromOutputScriptWithCoin() to get address for a specific network
54
+ * console.log(`Estimated reveal vsize: ${revealData.revealTransactionVSize}`);
55
+ * ```
56
+ */
57
+ export declare function createInscriptionRevealData(key: ECPairArg, contentType: string, inscriptionData: Uint8Array): PreparedInscriptionRevealData;
58
+ /**
59
+ * Sign a reveal transaction
60
+ *
61
+ * Creates and signs the reveal transaction that spends from the commit output
62
+ * and sends the inscription to the recipient.
63
+ *
64
+ * @param key - The private key (ECPairArg: Uint8Array, ECPair, or WasmECPair)
65
+ * @param tapLeafScript - The tap leaf script from createInscriptionRevealData
66
+ * @param commitTx - The commit transaction
67
+ * @param commitOutputScript - The commit output script (P2TR)
68
+ * @param recipientOutputScript - Where to send the inscription (output script)
69
+ * @param outputValueSats - Value in satoshis for the inscription output
70
+ * @returns The signed transaction as bytes (ready to broadcast)
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const txBytes = signRevealTransaction(
75
+ * privateKey,
76
+ * revealData.tapLeafScript,
77
+ * commitTx,
78
+ * revealData.outputScript,
79
+ * recipientOutputScript,
80
+ * 10000n, // 10,000 sats
81
+ * );
82
+ * ```
83
+ */
84
+ export declare function signRevealTransaction(key: ECPairArg, tapLeafScript: TapLeafScript, commitTx: Transaction, commitOutputScript: Uint8Array, recipientOutputScript: Uint8Array, outputValueSats: bigint): Uint8Array;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Inscription support for Bitcoin Ordinals
3
+ *
4
+ * This module provides functionality for creating and signing inscription
5
+ * reveal transactions following the Ordinals protocol.
6
+ *
7
+ * @see https://docs.ordinals.com/inscriptions.html
8
+ */
9
+ import { InscriptionsNamespace } from "./wasm/wasm_utxo.js";
10
+ import { ECPair } from "./ecpair.js";
11
+ /**
12
+ * Create inscription reveal data including the commit output script and tap leaf script
13
+ *
14
+ * This function creates all the data needed to perform an inscription:
15
+ * 1. A P2TR output script for the commit transaction (network-agnostic)
16
+ * 2. The tap leaf script needed to spend from that output
17
+ * 3. An estimate of the reveal transaction's virtual size for fee calculation
18
+ *
19
+ * @param key - The key pair (ECPairArg: Uint8Array, ECPair, or WasmECPair). The x-only public key will be extracted.
20
+ * @param contentType - MIME type of the inscription (e.g., "text/plain", "image/png")
21
+ * @param inscriptionData - The inscription data bytes
22
+ * @returns PreparedInscriptionRevealData containing output script, vsize estimate, and tap leaf script
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const revealData = createInscriptionRevealData(
27
+ * ecpair,
28
+ * "text/plain",
29
+ * new TextEncoder().encode("Hello, Ordinals!"),
30
+ * );
31
+ * // Use address.fromOutputScriptWithCoin() to get address for a specific network
32
+ * console.log(`Estimated reveal vsize: ${revealData.revealTransactionVSize}`);
33
+ * ```
34
+ */
35
+ export function createInscriptionRevealData(key, contentType, inscriptionData) {
36
+ // Convert to ECPair and extract x-only public key (strip parity byte from compressed pubkey)
37
+ const ecpair = ECPair.from(key);
38
+ const compressedPubkey = ecpair.publicKey;
39
+ const xOnlyPubkey = compressedPubkey.slice(1); // Remove first byte (parity)
40
+ // Call snake_case WASM method (traits output camelCase)
41
+ return InscriptionsNamespace.create_inscription_reveal_data(xOnlyPubkey, contentType, inscriptionData);
42
+ }
43
+ /**
44
+ * Sign a reveal transaction
45
+ *
46
+ * Creates and signs the reveal transaction that spends from the commit output
47
+ * and sends the inscription to the recipient.
48
+ *
49
+ * @param key - The private key (ECPairArg: Uint8Array, ECPair, or WasmECPair)
50
+ * @param tapLeafScript - The tap leaf script from createInscriptionRevealData
51
+ * @param commitTx - The commit transaction
52
+ * @param commitOutputScript - The commit output script (P2TR)
53
+ * @param recipientOutputScript - Where to send the inscription (output script)
54
+ * @param outputValueSats - Value in satoshis for the inscription output
55
+ * @returns The signed transaction as bytes (ready to broadcast)
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const txBytes = signRevealTransaction(
60
+ * privateKey,
61
+ * revealData.tapLeafScript,
62
+ * commitTx,
63
+ * revealData.outputScript,
64
+ * recipientOutputScript,
65
+ * 10000n, // 10,000 sats
66
+ * );
67
+ * ```
68
+ */
69
+ export function signRevealTransaction(key, tapLeafScript, commitTx, commitOutputScript, recipientOutputScript, outputValueSats) {
70
+ // Convert to ECPair to get private key bytes
71
+ const ecpair = ECPair.from(key);
72
+ const privateKey = ecpair.privateKey;
73
+ if (!privateKey) {
74
+ throw new Error("ECPair must have a private key for signing");
75
+ }
76
+ // Call snake_case WASM method
77
+ return InscriptionsNamespace.sign_reveal_transaction(privateKey, tapLeafScript, commitTx.wasm, commitOutputScript, recipientOutputScript, outputValueSats);
78
+ }
@@ -507,6 +507,42 @@ export class FixedScriptWalletNamespace {
507
507
  static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
508
508
  }
509
509
 
510
+ export class InscriptionsNamespace {
511
+ private constructor();
512
+ free(): void;
513
+ [Symbol.dispose](): void;
514
+ /**
515
+ * Sign a reveal transaction
516
+ *
517
+ * # Arguments
518
+ * * `private_key` - The private key (32 bytes)
519
+ * * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
520
+ * * `commit_tx` - The commit transaction
521
+ * * `commit_output_script` - The commit output script (P2TR)
522
+ * * `recipient_output_script` - Where to send the inscription (output script)
523
+ * * `output_value_sats` - Value in satoshis for the inscription output
524
+ *
525
+ * # Returns
526
+ * The signed PSBT as bytes
527
+ */
528
+ static sign_reveal_transaction(private_key: Uint8Array, tap_leaf_script: any, commit_tx: WasmTransaction, commit_output_script: Uint8Array, recipient_output_script: Uint8Array, output_value_sats: bigint): Uint8Array;
529
+ /**
530
+ * Create inscription reveal data including the commit output script and tap leaf script
531
+ *
532
+ * # Arguments
533
+ * * `x_only_pubkey` - The x-only public key (32 bytes)
534
+ * * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
535
+ * * `inscription_data` - The inscription data bytes
536
+ *
537
+ * # Returns
538
+ * An object containing:
539
+ * - `output_script`: The commit output script (P2TR, network-agnostic)
540
+ * - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
541
+ * - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
542
+ */
543
+ static create_inscription_reveal_data(x_only_pubkey: Uint8Array, content_type: string, inscription_data: Uint8Array): any;
544
+ }
545
+
510
546
  export class UtxolibCompatNamespace {
511
547
  private constructor();
512
548
  free(): void;
@@ -684,10 +720,6 @@ export class WasmDimensions {
684
720
  * Get output weight
685
721
  */
686
722
  get_output_weight(): number;
687
- /**
688
- * Create dimensions for a single output from script bytes
689
- */
690
- static from_output_script(script: Uint8Array): WasmDimensions;
691
723
  /**
692
724
  * Create dimensions for a single input from script type string
693
725
  *
@@ -696,6 +728,17 @@ export class WasmDimensions {
696
728
  * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
697
729
  */
698
730
  static from_input_script_type(script_type: string): WasmDimensions;
731
+ /**
732
+ * Create dimensions for a single output from script type string
733
+ *
734
+ * # Arguments
735
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
736
+ */
737
+ static from_output_script_type(script_type: string): WasmDimensions;
738
+ /**
739
+ * Create dimensions for a single output from script length
740
+ */
741
+ static from_output_script_length(length: number): WasmDimensions;
699
742
  /**
700
743
  * Combine with another Dimensions instance
701
744
  */
@@ -205,6 +205,10 @@ const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry ===
205
205
  ? { register: () => {}, unregister: () => {} }
206
206
  : new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
207
207
 
208
+ const InscriptionsNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
209
+ ? { register: () => {}, unregister: () => {} }
210
+ : new FinalizationRegistry(ptr => wasm.__wbg_inscriptionsnamespace_free(ptr >>> 0, 1));
211
+
208
212
  const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
209
213
  ? { register: () => {}, unregister: () => {} }
210
214
  : new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
@@ -1613,6 +1617,108 @@ export class FixedScriptWalletNamespace {
1613
1617
  }
1614
1618
  if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
1615
1619
 
1620
+ /**
1621
+ * Namespace for inscription-related functions
1622
+ */
1623
+ export class InscriptionsNamespace {
1624
+ __destroy_into_raw() {
1625
+ const ptr = this.__wbg_ptr;
1626
+ this.__wbg_ptr = 0;
1627
+ InscriptionsNamespaceFinalization.unregister(this);
1628
+ return ptr;
1629
+ }
1630
+ free() {
1631
+ const ptr = this.__destroy_into_raw();
1632
+ wasm.__wbg_inscriptionsnamespace_free(ptr, 0);
1633
+ }
1634
+ /**
1635
+ * Sign a reveal transaction
1636
+ *
1637
+ * # Arguments
1638
+ * * `private_key` - The private key (32 bytes)
1639
+ * * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
1640
+ * * `commit_tx` - The commit transaction
1641
+ * * `commit_output_script` - The commit output script (P2TR)
1642
+ * * `recipient_output_script` - Where to send the inscription (output script)
1643
+ * * `output_value_sats` - Value in satoshis for the inscription output
1644
+ *
1645
+ * # Returns
1646
+ * The signed PSBT as bytes
1647
+ * @param {Uint8Array} private_key
1648
+ * @param {any} tap_leaf_script
1649
+ * @param {WasmTransaction} commit_tx
1650
+ * @param {Uint8Array} commit_output_script
1651
+ * @param {Uint8Array} recipient_output_script
1652
+ * @param {bigint} output_value_sats
1653
+ * @returns {Uint8Array}
1654
+ */
1655
+ static sign_reveal_transaction(private_key, tap_leaf_script, commit_tx, commit_output_script, recipient_output_script, output_value_sats) {
1656
+ try {
1657
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1658
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_export);
1659
+ const len0 = WASM_VECTOR_LEN;
1660
+ _assertClass(commit_tx, WasmTransaction);
1661
+ const ptr1 = passArray8ToWasm0(commit_output_script, wasm.__wbindgen_export);
1662
+ const len1 = WASM_VECTOR_LEN;
1663
+ const ptr2 = passArray8ToWasm0(recipient_output_script, wasm.__wbindgen_export);
1664
+ const len2 = WASM_VECTOR_LEN;
1665
+ wasm.inscriptionsnamespace_sign_reveal_transaction(retptr, ptr0, len0, addHeapObject(tap_leaf_script), commit_tx.__wbg_ptr, ptr1, len1, ptr2, len2, output_value_sats);
1666
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1667
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1668
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1669
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1670
+ if (r3) {
1671
+ throw takeObject(r2);
1672
+ }
1673
+ var v4 = getArrayU8FromWasm0(r0, r1).slice();
1674
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1675
+ return v4;
1676
+ } finally {
1677
+ wasm.__wbindgen_add_to_stack_pointer(16);
1678
+ }
1679
+ }
1680
+ /**
1681
+ * Create inscription reveal data including the commit output script and tap leaf script
1682
+ *
1683
+ * # Arguments
1684
+ * * `x_only_pubkey` - The x-only public key (32 bytes)
1685
+ * * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
1686
+ * * `inscription_data` - The inscription data bytes
1687
+ *
1688
+ * # Returns
1689
+ * An object containing:
1690
+ * - `output_script`: The commit output script (P2TR, network-agnostic)
1691
+ * - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
1692
+ * - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
1693
+ * @param {Uint8Array} x_only_pubkey
1694
+ * @param {string} content_type
1695
+ * @param {Uint8Array} inscription_data
1696
+ * @returns {any}
1697
+ */
1698
+ static create_inscription_reveal_data(x_only_pubkey, content_type, inscription_data) {
1699
+ try {
1700
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1701
+ const ptr0 = passArray8ToWasm0(x_only_pubkey, wasm.__wbindgen_export);
1702
+ const len0 = WASM_VECTOR_LEN;
1703
+ const ptr1 = passStringToWasm0(content_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1704
+ const len1 = WASM_VECTOR_LEN;
1705
+ const ptr2 = passArray8ToWasm0(inscription_data, wasm.__wbindgen_export);
1706
+ const len2 = WASM_VECTOR_LEN;
1707
+ wasm.inscriptionsnamespace_create_inscription_reveal_data(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1708
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1709
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1710
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1711
+ if (r2) {
1712
+ throw takeObject(r1);
1713
+ }
1714
+ return takeObject(r0);
1715
+ } finally {
1716
+ wasm.__wbindgen_add_to_stack_pointer(16);
1717
+ }
1718
+ }
1719
+ }
1720
+ if (Symbol.dispose) InscriptionsNamespace.prototype[Symbol.dispose] = InscriptionsNamespace.prototype.free;
1721
+
1616
1722
  export class UtxolibCompatNamespace {
1617
1723
  __destroy_into_raw() {
1618
1724
  const ptr = this.__wbg_ptr;
@@ -2241,17 +2347,6 @@ export class WasmDimensions {
2241
2347
  const ret = wasm.wasmdimensions_get_output_weight(this.__wbg_ptr);
2242
2348
  return ret >>> 0;
2243
2349
  }
2244
- /**
2245
- * Create dimensions for a single output from script bytes
2246
- * @param {Uint8Array} script
2247
- * @returns {WasmDimensions}
2248
- */
2249
- static from_output_script(script) {
2250
- const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export);
2251
- const len0 = WASM_VECTOR_LEN;
2252
- const ret = wasm.wasmdimensions_from_output_script(ptr0, len0);
2253
- return WasmDimensions.__wrap(ret);
2254
- }
2255
2350
  /**
2256
2351
  * Create dimensions for a single input from script type string
2257
2352
  *
@@ -2278,6 +2373,40 @@ export class WasmDimensions {
2278
2373
  wasm.__wbindgen_add_to_stack_pointer(16);
2279
2374
  }
2280
2375
  }
2376
+ /**
2377
+ * Create dimensions for a single output from script type string
2378
+ *
2379
+ * # Arguments
2380
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
2381
+ * @param {string} script_type
2382
+ * @returns {WasmDimensions}
2383
+ */
2384
+ static from_output_script_type(script_type) {
2385
+ try {
2386
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2387
+ const ptr0 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2388
+ const len0 = WASM_VECTOR_LEN;
2389
+ wasm.wasmdimensions_from_output_script_type(retptr, ptr0, len0);
2390
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2391
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2392
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2393
+ if (r2) {
2394
+ throw takeObject(r1);
2395
+ }
2396
+ return WasmDimensions.__wrap(r0);
2397
+ } finally {
2398
+ wasm.__wbindgen_add_to_stack_pointer(16);
2399
+ }
2400
+ }
2401
+ /**
2402
+ * Create dimensions for a single output from script length
2403
+ * @param {number} length
2404
+ * @returns {WasmDimensions}
2405
+ */
2406
+ static from_output_script_length(length) {
2407
+ const ret = wasm.wasmdimensions_from_output_script_length(length);
2408
+ return WasmDimensions.__wrap(ret);
2409
+ }
2281
2410
  /**
2282
2411
  * Combine with another Dimensions instance
2283
2412
  * @param {WasmDimensions} other
Binary file
@@ -1,11 +1,23 @@
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;
4
7
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
5
8
  export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
6
9
  export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
7
10
  export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
8
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;
9
21
  export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
10
22
  export const wasmtransaction_get_vsize: (a: number) => number;
11
23
  export const wasmtransaction_to_bytes: (a: number, b: number) => void;
@@ -42,11 +54,9 @@ export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
42
54
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
43
55
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
44
56
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
45
- export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
46
57
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
47
58
  export const __wbg_wasmecpair_free: (a: number, b: number) => void;
48
59
  export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
49
- export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
50
60
  export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
51
61
  export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
52
62
  export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
@@ -109,12 +119,11 @@ export const wasmbip32_private_key: (a: number) => number;
109
119
  export const wasmbip32_public_key: (a: number) => number;
110
120
  export const wasmbip32_to_base58: (a: number, b: number) => void;
111
121
  export const wasmbip32_to_wif: (a: number, b: number) => void;
112
- export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
113
- export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
114
122
  export const wasmdimensions_empty: () => number;
115
123
  export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
116
124
  export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number) => void;
117
- export const wasmdimensions_from_output_script: (a: number, b: number) => number;
125
+ export const wasmdimensions_from_output_script_length: (a: number) => number;
126
+ export const wasmdimensions_from_output_script_type: (a: number, b: number, c: number) => void;
118
127
  export const wasmdimensions_from_psbt: (a: number, b: number) => void;
119
128
  export const wasmdimensions_get_input_vsize: (a: number, b: number, c: number) => number;
120
129
  export const wasmdimensions_get_input_weight: (a: number, b: number, c: number) => number;
@@ -138,11 +147,6 @@ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
138
147
  export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
139
148
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
140
149
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
141
- export const wasmrootwalletkeys_backup_key: (a: number) => number;
142
- export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
143
- export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
144
- export const wasmrootwalletkeys_user_key: (a: number) => number;
145
- 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;
146
150
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
147
151
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
148
152
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitgo/wasm-utxo",
3
3
  "description": "WebAssembly wrapper for rust-bitcoin (beta)",
4
- "version": "1.23.0",
4
+ "version": "1.25.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",