@bitgo/wasm-utxo 1.22.0 → 1.24.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,10 +44,26 @@ 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
  */
49
62
  plus(other: Dimensions): Dimensions;
63
+ /**
64
+ * Multiply dimensions by a scalar
65
+ */
66
+ times(n: number): Dimensions;
50
67
  /**
51
68
  * Whether any inputs are segwit (affects overhead calculation)
52
69
  */
@@ -61,5 +78,23 @@ export declare class Dimensions {
61
78
  * @param size - "min" or "max", defaults to "max"
62
79
  */
63
80
  getVSize(size?: "min" | "max"): number;
81
+ /**
82
+ * Get input weight only (min or max)
83
+ * @param size - "min" or "max", defaults to "max"
84
+ */
85
+ getInputWeight(size?: "min" | "max"): number;
86
+ /**
87
+ * Get input virtual size (min or max)
88
+ * @param size - "min" or "max", defaults to "max"
89
+ */
90
+ getInputVSize(size?: "min" | "max"): number;
91
+ /**
92
+ * Get output weight
93
+ */
94
+ getOutputWeight(): number;
95
+ /**
96
+ * Get output virtual size
97
+ */
98
+ getOutputVSize(): number;
64
99
  }
65
100
  export {};
@@ -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
@@ -59,6 +63,12 @@ class Dimensions {
59
63
  plus(other) {
60
64
  return new Dimensions(this._wasm.plus(other._wasm));
61
65
  }
66
+ /**
67
+ * Multiply dimensions by a scalar
68
+ */
69
+ times(n) {
70
+ return new Dimensions(this._wasm.times(n));
71
+ }
62
72
  /**
63
73
  * Whether any inputs are segwit (affects overhead calculation)
64
74
  */
@@ -79,5 +89,31 @@ class Dimensions {
79
89
  getVSize(size = "max") {
80
90
  return this._wasm.get_vsize(size);
81
91
  }
92
+ /**
93
+ * Get input weight only (min or max)
94
+ * @param size - "min" or "max", defaults to "max"
95
+ */
96
+ getInputWeight(size = "max") {
97
+ return this._wasm.get_input_weight(size);
98
+ }
99
+ /**
100
+ * Get input virtual size (min or max)
101
+ * @param size - "min" or "max", defaults to "max"
102
+ */
103
+ getInputVSize(size = "max") {
104
+ return this._wasm.get_input_vsize(size);
105
+ }
106
+ /**
107
+ * Get output weight
108
+ */
109
+ getOutputWeight() {
110
+ return this._wasm.get_output_weight();
111
+ }
112
+ /**
113
+ * Get output virtual size
114
+ */
115
+ getOutputVSize() {
116
+ return this._wasm.get_output_vsize();
117
+ }
82
118
  }
83
119
  exports.Dimensions = Dimensions;
@@ -0,0 +1,56 @@
1
+ import type { OutputScriptType } from "./scriptType.js";
2
+ /** All valid chain codes as a const tuple */
3
+ export declare const chainCodes: readonly [0, 1, 10, 11, 20, 21, 30, 31, 40, 41];
4
+ /** A valid chain code value */
5
+ export type ChainCode = (typeof chainCodes)[number];
6
+ /** Whether a chain is for receiving (external) or change (internal) addresses */
7
+ export type Scope = "internal" | "external";
8
+ /**
9
+ * ChainCode namespace with utility functions for working with chain codes.
10
+ */
11
+ export declare const ChainCode: {
12
+ /**
13
+ * Check if a value is a valid chain code.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * if (ChainCode.is(maybeChain)) {
18
+ * // maybeChain is now typed as ChainCode
19
+ * const scope = ChainCode.scope(maybeChain);
20
+ * }
21
+ * ```
22
+ */
23
+ is(n: unknown): n is ChainCode;
24
+ /**
25
+ * Get the chain code for a script type and scope.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const externalP2wsh = ChainCode.value("p2wsh", "external"); // 20
30
+ * const internalP2tr = ChainCode.value("p2trLegacy", "internal"); // 31
31
+ * ```
32
+ */
33
+ value(scriptType: OutputScriptType | "p2tr", scope: Scope): ChainCode;
34
+ /**
35
+ * Get the scope (external/internal) for a chain code.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * ChainCode.scope(0); // "external"
40
+ * ChainCode.scope(1); // "internal"
41
+ * ChainCode.scope(20); // "external"
42
+ * ```
43
+ */
44
+ scope(chainCode: ChainCode): Scope;
45
+ /**
46
+ * Get the script type for a chain code.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * ChainCode.scriptType(0); // "p2sh"
51
+ * ChainCode.scriptType(20); // "p2wsh"
52
+ * ChainCode.scriptType(40); // "p2trMusig2"
53
+ * ```
54
+ */
55
+ scriptType(chainCode: ChainCode): OutputScriptType;
56
+ };
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChainCode = exports.chainCodes = void 0;
4
+ /**
5
+ * Chain code utilities for BitGo fixed-script wallets.
6
+ *
7
+ * Chain codes define the derivation path component for different script types
8
+ * and scopes (external/internal) in the format `m/0/0/{chain}/{index}`.
9
+ */
10
+ const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
11
+ /** All valid chain codes as a const tuple */
12
+ exports.chainCodes = [0, 1, 10, 11, 20, 21, 30, 31, 40, 41];
13
+ // Build static lookup tables once at module load time
14
+ const chainCodeSet = new Set(exports.chainCodes);
15
+ const chainToMeta = new Map();
16
+ const scriptTypeToChain = new Map();
17
+ // Initialize from WASM (called once at load time)
18
+ function assertChainCode(n) {
19
+ if (!chainCodeSet.has(n)) {
20
+ throw new Error(`Invalid chain code from WASM: ${n}`);
21
+ }
22
+ return n;
23
+ }
24
+ function assertScope(s) {
25
+ if (s !== "internal" && s !== "external") {
26
+ throw new Error(`Invalid scope from WASM: ${s}`);
27
+ }
28
+ return s;
29
+ }
30
+ for (const tuple of wasm_utxo_js_1.FixedScriptWalletNamespace.chain_code_table()) {
31
+ if (!Array.isArray(tuple) || tuple.length !== 3) {
32
+ throw new Error(`Invalid chain_code_table entry: expected [number, string, string]`);
33
+ }
34
+ const [rawCode, rawScriptType, rawScope] = tuple;
35
+ if (typeof rawCode !== "number") {
36
+ throw new Error(`Invalid chain code type: ${typeof rawCode}`);
37
+ }
38
+ if (typeof rawScriptType !== "string") {
39
+ throw new Error(`Invalid scriptType type: ${typeof rawScriptType}`);
40
+ }
41
+ if (typeof rawScope !== "string") {
42
+ throw new Error(`Invalid scope type: ${typeof rawScope}`);
43
+ }
44
+ const code = assertChainCode(rawCode);
45
+ const scriptType = rawScriptType;
46
+ const scope = assertScope(rawScope);
47
+ chainToMeta.set(code, { scope, scriptType });
48
+ let entry = scriptTypeToChain.get(scriptType);
49
+ if (!entry) {
50
+ entry = {};
51
+ scriptTypeToChain.set(scriptType, entry);
52
+ }
53
+ entry[scope] = code;
54
+ }
55
+ /**
56
+ * ChainCode namespace with utility functions for working with chain codes.
57
+ */
58
+ exports.ChainCode = {
59
+ /**
60
+ * Check if a value is a valid chain code.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * if (ChainCode.is(maybeChain)) {
65
+ * // maybeChain is now typed as ChainCode
66
+ * const scope = ChainCode.scope(maybeChain);
67
+ * }
68
+ * ```
69
+ */
70
+ is(n) {
71
+ return typeof n === "number" && chainCodeSet.has(n);
72
+ },
73
+ /**
74
+ * Get the chain code for a script type and scope.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const externalP2wsh = ChainCode.value("p2wsh", "external"); // 20
79
+ * const internalP2tr = ChainCode.value("p2trLegacy", "internal"); // 31
80
+ * ```
81
+ */
82
+ value(scriptType, scope) {
83
+ // legacy alias for p2trLegacy
84
+ if (scriptType === "p2tr") {
85
+ scriptType = "p2trLegacy";
86
+ }
87
+ const entry = scriptTypeToChain.get(scriptType);
88
+ if (!entry) {
89
+ throw new Error(`Invalid scriptType: ${scriptType}`);
90
+ }
91
+ return entry[scope];
92
+ },
93
+ /**
94
+ * Get the scope (external/internal) for a chain code.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * ChainCode.scope(0); // "external"
99
+ * ChainCode.scope(1); // "internal"
100
+ * ChainCode.scope(20); // "external"
101
+ * ```
102
+ */
103
+ scope(chainCode) {
104
+ const meta = chainToMeta.get(chainCode);
105
+ if (!meta)
106
+ throw new Error(`Invalid chainCode: ${chainCode}`);
107
+ return meta.scope;
108
+ },
109
+ /**
110
+ * Get the script type for a chain code.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * ChainCode.scriptType(0); // "p2sh"
115
+ * ChainCode.scriptType(20); // "p2wsh"
116
+ * ChainCode.scriptType(40); // "p2trMusig2"
117
+ * ```
118
+ */
119
+ scriptType(chainCode) {
120
+ const meta = chainToMeta.get(chainCode);
121
+ if (!meta)
122
+ throw new Error(`Invalid chainCode: ${chainCode}`);
123
+ return meta.scriptType;
124
+ },
125
+ };
@@ -4,6 +4,7 @@ export { ReplayProtection, type ReplayProtectionArg } from "./ReplayProtection.j
4
4
  export { outputScript, address } from "./address.js";
5
5
  export { Dimensions } from "./Dimensions.js";
6
6
  export { type OutputScriptType, type InputScriptType, type ScriptType } from "./scriptType.js";
7
+ export { ChainCode, chainCodes, type Scope } from "./chains.js";
7
8
  export { BitGoPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, } from "./BitGoPsbt.js";
8
9
  export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
9
10
  import type { ScriptType } from "./scriptType.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
3
+ exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.chainCodes = exports.ChainCode = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
4
4
  exports.supportsScriptType = supportsScriptType;
5
5
  const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
6
6
  var RootWalletKeys_js_1 = require("./RootWalletKeys.js");
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "outputScript", { enumerable: true, get: function
12
12
  Object.defineProperty(exports, "address", { enumerable: true, get: function () { return address_js_1.address; } });
13
13
  var Dimensions_js_1 = require("./Dimensions.js");
14
14
  Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
15
+ var chains_js_1 = require("./chains.js");
16
+ Object.defineProperty(exports, "ChainCode", { enumerable: true, get: function () { return chains_js_1.ChainCode; } });
17
+ Object.defineProperty(exports, "chainCodes", { enumerable: true, get: function () { return chains_js_1.chainCodes; } });
15
18
  // Bitcoin-like PSBT (for all non-Zcash networks)
16
19
  var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
17
20
  Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
@@ -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 PSBT as bytes
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const psbtBytes = 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 PSBT as bytes
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const psbtBytes = 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
+ }
@@ -479,6 +479,15 @@ export class FixedScriptWalletNamespace {
479
479
  free(): void;
480
480
  [Symbol.dispose](): void;
481
481
  static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
482
+ /**
483
+ * Get all chain code metadata for building TypeScript lookup tables
484
+ *
485
+ * Returns an array of [chainCode, scriptType, scope] tuples where:
486
+ * - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
487
+ * - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
488
+ * - scope: string ("external" or "internal")
489
+ */
490
+ static chain_code_table(): any;
482
491
  /**
483
492
  * Check if a network supports a given fixed-script wallet script type
484
493
  *
@@ -498,6 +507,42 @@ export class FixedScriptWalletNamespace {
498
507
  static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
499
508
  }
500
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
+
501
546
  export class UtxolibCompatNamespace {
502
547
  private constructor();
503
548
  free(): void;
@@ -654,9 +699,27 @@ export class WasmDimensions {
654
699
  */
655
700
  has_segwit(): boolean;
656
701
  /**
657
- * Create dimensions for a single output from script bytes
702
+ * Get input virtual size (min or max)
703
+ *
704
+ * # Arguments
705
+ * * `size` - "min" or "max", defaults to "max"
706
+ */
707
+ get_input_vsize(size?: string | null): number;
708
+ /**
709
+ * Get input weight only (min or max)
710
+ *
711
+ * # Arguments
712
+ * * `size` - "min" or "max", defaults to "max"
713
+ */
714
+ get_input_weight(size?: string | null): number;
715
+ /**
716
+ * Get output virtual size
658
717
  */
659
- static from_output_script(script: Uint8Array): WasmDimensions;
718
+ get_output_vsize(): number;
719
+ /**
720
+ * Get output weight
721
+ */
722
+ get_output_weight(): number;
660
723
  /**
661
724
  * Create dimensions for a single input from script type string
662
725
  *
@@ -665,6 +728,17 @@ export class WasmDimensions {
665
728
  * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
666
729
  */
667
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;
668
742
  /**
669
743
  * Combine with another Dimensions instance
670
744
  */
@@ -673,6 +747,10 @@ export class WasmDimensions {
673
747
  * Create empty dimensions (zero weight)
674
748
  */
675
749
  static empty(): WasmDimensions;
750
+ /**
751
+ * Multiply dimensions by a scalar
752
+ */
753
+ times(n: number): WasmDimensions;
676
754
  /**
677
755
  * Create dimensions from a BitGoPsbt
678
756
  *