@bitcoinerlab/descriptors-core 3.1.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.
Files changed (76) hide show
  1. package/README.md +710 -0
  2. package/dist/adapters/applyPR2137.d.ts +2 -0
  3. package/dist/adapters/applyPR2137.js +150 -0
  4. package/dist/adapters/bitcoinjs.d.ts +8 -0
  5. package/dist/adapters/bitcoinjs.js +36 -0
  6. package/dist/adapters/scure/address.d.ts +2 -0
  7. package/dist/adapters/scure/address.js +50 -0
  8. package/dist/adapters/scure/bip32.d.ts +2 -0
  9. package/dist/adapters/scure/bip32.js +16 -0
  10. package/dist/adapters/scure/common.d.ts +14 -0
  11. package/dist/adapters/scure/common.js +36 -0
  12. package/dist/adapters/scure/ecpair.d.ts +2 -0
  13. package/dist/adapters/scure/ecpair.js +58 -0
  14. package/dist/adapters/scure/payments.d.ts +2 -0
  15. package/dist/adapters/scure/payments.js +216 -0
  16. package/dist/adapters/scure/psbt.d.ts +43 -0
  17. package/dist/adapters/scure/psbt.js +382 -0
  18. package/dist/adapters/scure/script.d.ts +20 -0
  19. package/dist/adapters/scure/script.js +163 -0
  20. package/dist/adapters/scure/transaction.d.ts +2 -0
  21. package/dist/adapters/scure/transaction.js +32 -0
  22. package/dist/adapters/scure.d.ts +6 -0
  23. package/dist/adapters/scure.js +37 -0
  24. package/dist/adapters/scureKeys.d.ts +4 -0
  25. package/dist/adapters/scureKeys.js +135 -0
  26. package/dist/bip174.d.ts +87 -0
  27. package/dist/bip174.js +12 -0
  28. package/dist/bitcoinLib.d.ts +385 -0
  29. package/dist/bitcoinLib.js +19 -0
  30. package/dist/bitcoinjs-lib-internals.d.ts +6 -0
  31. package/dist/bitcoinjs-lib-internals.js +60 -0
  32. package/dist/bitcoinjs.d.ts +12 -0
  33. package/dist/bitcoinjs.js +18 -0
  34. package/dist/checksum.d.ts +6 -0
  35. package/dist/checksum.js +58 -0
  36. package/dist/crypto.d.ts +3 -0
  37. package/dist/crypto.js +79 -0
  38. package/dist/descriptors.d.ts +481 -0
  39. package/dist/descriptors.js +1888 -0
  40. package/dist/index.d.ts +23 -0
  41. package/dist/index.js +87 -0
  42. package/dist/keyExpressions.d.ts +124 -0
  43. package/dist/keyExpressions.js +310 -0
  44. package/dist/keyInterfaces.d.ts +5 -0
  45. package/dist/keyInterfaces.js +50 -0
  46. package/dist/ledger.d.ts +183 -0
  47. package/dist/ledger.js +618 -0
  48. package/dist/miniscript.d.ts +125 -0
  49. package/dist/miniscript.js +310 -0
  50. package/dist/multipath.d.ts +13 -0
  51. package/dist/multipath.js +76 -0
  52. package/dist/networkUtils.d.ts +3 -0
  53. package/dist/networkUtils.js +16 -0
  54. package/dist/networks.d.ts +16 -0
  55. package/dist/networks.js +31 -0
  56. package/dist/parseUtils.d.ts +7 -0
  57. package/dist/parseUtils.js +46 -0
  58. package/dist/psbt.d.ts +40 -0
  59. package/dist/psbt.js +228 -0
  60. package/dist/re.d.ts +31 -0
  61. package/dist/re.js +79 -0
  62. package/dist/resourceLimits.d.ts +28 -0
  63. package/dist/resourceLimits.js +84 -0
  64. package/dist/scriptExpressions.d.ts +95 -0
  65. package/dist/scriptExpressions.js +98 -0
  66. package/dist/scure.d.ts +4 -0
  67. package/dist/scure.js +10 -0
  68. package/dist/signers.d.ts +161 -0
  69. package/dist/signers.js +324 -0
  70. package/dist/tapMiniscript.d.ts +231 -0
  71. package/dist/tapMiniscript.js +524 -0
  72. package/dist/tapTree.d.ts +91 -0
  73. package/dist/tapTree.js +166 -0
  74. package/dist/types.d.ts +296 -0
  75. package/dist/types.js +4 -0
  76. package/package.json +148 -0
@@ -0,0 +1,481 @@
1
+ import type { Payment, BitcoinLib, ECPairAPI, BIP32API, PsbtLike, ScureTransactionLike } from './bitcoinLib';
2
+ import type { PartialSig } from './bip174';
3
+ import type { TinySecp256k1Interface, Preimage, Expansion, ExpansionMap, KeyExpressionParser } from './types';
4
+ import { type Network } from './networks';
5
+ import type { TapTreeInfoNode, TapTreeNode } from './tapTree';
6
+ import type { TaprootLeafSatisfaction } from './tapMiniscript';
7
+ /**
8
+ * Constructs the necessary functions and classes for working with descriptors,
9
+ * using either an external elliptic curve (`ecc`) library or a core Bitcoin
10
+ * library (e.g.
11
+ * [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib) or
12
+ * [@scure/btc-signer](https://github.com/paulmillr/scure-btc-signer)).
13
+ *
14
+ * Note:
15
+ * Most users do not need to call `DescriptorsFactory(...)` directly.
16
+ * - `@bitcoinerlab/descriptors` already provides the bitcoinjs-ready defaults.
17
+ * - `@bitcoinerlab/descriptors-scure` already provides the scure-ready defaults.
18
+ *
19
+ * This factory is mainly useful for:
20
+ * - backwards compatibility with pre-`3.1.x` bitcoinjs usage, and
21
+ * - advanced `@bitcoinerlab/descriptors-core` use cases where you want to bind
22
+ * a specific `TinySecp256k1Interface` or a custom `BitcoinLib`.
23
+ *
24
+ * In the default bitcoinjs package, the implicit `TinySecp256k1Interface` is
25
+ * `@bitcoinerlab/secp256k1`.
26
+ *
27
+ * Notably, it returns the {@link _Internal_.Output | `Output`} class, which
28
+ * provides methods to create, sign, and finalize transactions from descriptor
29
+ * expressions.
30
+ *
31
+ * The factory also returns utility methods like `expand` (detailed below)
32
+ * and `parseKeyExpression` (see {@link KeyExpressionParser}).
33
+ *
34
+ * Additionally, for convenience, the factory returns
35
+ * {@link https://github.com/bitcoinjs/bip32 | `BIP32`} and
36
+ * {@link https://github.com/bitcoinjs/ecpair | `ECPair`}.
37
+ * In bitcoinjs mode, these are the already initialized bitcoinjs factories,
38
+ * equivalent to `BIP32 = BIP32Factory(ecc)` and `ECPair = ECPairFactory(ecc)`.
39
+ * When using scure, prefer scure-native key types
40
+ * ({@link https://github.com/paulmillr/scure-bip32 | `HDKey`} and
41
+ * `Uint8Array` for private keys), which do not require key-factory initialization.
42
+ *
43
+ * @param {TinySecp256k1Interface | BitcoinLib} eccOrBitcoinLib - The core
44
+ * Bitcoin library input used by the factory.
45
+ *
46
+ * You can pass this parameter in three common ways:
47
+ *
48
+ * ```ts
49
+ * import { DescriptorsFactory } from '@bitcoinerlab/descriptors-core';
50
+ * import { createScureLib } from '@bitcoinerlab/descriptors-core/scure';
51
+ *
52
+ * const { Output } = DescriptorsFactory(createScureLib());
53
+ * ```
54
+ *
55
+ * ```ts
56
+ * import * as ecc from '@bitcoinerlab/secp256k1';
57
+ * import { DescriptorsFactory } from '@bitcoinerlab/descriptors-core';
58
+ * import { createBitcoinjsLib } from '@bitcoinerlab/descriptors-core/bitcoinjs';
59
+ *
60
+ * const { Output } = DescriptorsFactory(createBitcoinjsLib(ecc));
61
+ * ```
62
+ *
63
+ * ```ts
64
+ * import * as ecc from '@bitcoinerlab/secp256k1';
65
+ * import { DescriptorsFactory } from '@bitcoinerlab/descriptors';
66
+ *
67
+ * // Equivalent to `DescriptorsFactory(createBitcoinjsLib(ecc))`, but implicit.
68
+ * const { Output } = DescriptorsFactory(ecc);
69
+ * ```
70
+ */
71
+ export declare function DescriptorsFactory(eccOrBitcoinLib: TinySecp256k1Interface | BitcoinLib): {
72
+ Output: {
73
+ new ({ descriptor, index, change, checksumRequired, allowMiniscriptInP2SH, network, preimages, signersPubKeys, taprootSpendPath, tapLeaf }: {
74
+ /**
75
+ * The descriptor string in ASCII format. It may include a "*" to denote an arbitrary index (aka ranged descriptors).
76
+ */
77
+ descriptor: string;
78
+ /**
79
+ * The descriptor's index in the case of a range descriptor (must be an integer >=0).
80
+ *
81
+ * This `Output` class always models a concrete spendable output.
82
+ * If the descriptor contains any wildcard (`*`), an `index` is required.
83
+ */
84
+ index?: number;
85
+ /**
86
+ * Multipath branch selector for key-path tuples like `/<0;1>/*`.
87
+ *
88
+ * The value passed in `change` must be one of the numbers present in the
89
+ * tuple.
90
+ *
91
+ * Examples:
92
+ * - `/<0;1>/*` accepts `change: 0` (typically receive) or `change: 1`
93
+ * (typically change).
94
+ * - `/<0;1;2>/*` accepts `change: 0`, `1` or `2`.
95
+ *
96
+ * This parameter is independent from `index`: `change` resolves
97
+ * multipath tuples, while `index` resolves the final wildcard `*`.
98
+ */
99
+ change?: number;
100
+ /**
101
+ * An optional flag indicating whether the descriptor is required to include a checksum.
102
+ * @defaultValue false
103
+ */
104
+ checksumRequired?: boolean;
105
+ /**
106
+ * A flag indicating whether this instance can parse and generate script satisfactions for sh(miniscript) top-level expressions of miniscripts. This is not recommended.
107
+ * @defaultValue false
108
+ */
109
+ allowMiniscriptInP2SH?: boolean;
110
+ /**
111
+ * One of bitcoinjs-lib [`networks`](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/networks.js) (or another one following the same interface).
112
+ * @defaultValue networks.bitcoin
113
+ */
114
+ network?: Network;
115
+ /**
116
+ * An array of preimages if the miniscript-based descriptor uses them.
117
+ *
118
+ * This info is necessary to finalize Psbts. Leave it `undefined` if your
119
+ * miniscript-based descriptor does not use preimages or you don't know
120
+ * or don't wanto use them.
121
+ *
122
+ * You can also leave it `undefined` if only need to generate the
123
+ * `scriptPubKey` or `address` for a descriptor.
124
+ *
125
+ * @defaultValue `[]`
126
+ */
127
+ preimages?: Preimage[];
128
+ /**
129
+ * An array of the public keys used for signing the transaction when
130
+ * spending the previous output associated with this descriptor.
131
+ *
132
+ * This parameter is only used if the descriptor object is being used to
133
+ * finalize a transaction. It is necessary to specify the spending path
134
+ * when working with miniscript-based expressions that have multiple
135
+ * spending paths.
136
+ *
137
+ * Set this parameter to an array containing the public
138
+ * keys involved in the desired spending path. Leave it `undefined` if you
139
+ * only need to generate the `scriptPubKey` or `address` for a descriptor,
140
+ * or if all the public keys involved in the descriptor will sign the
141
+ * transaction. In the latter case, the satisfier will automatically
142
+ * choose the most optimal spending path (if more than one is available).
143
+ * If omitted, this library assumes that all keys in the miniscript can
144
+ * sign. For taproot script-path spends, keys are inferred per leaf.
145
+ *
146
+ * For more details on using this parameter, refer to [this Stack Exchange
147
+ * answer](https://bitcoin.stackexchange.com/a/118036/89665).
148
+ */
149
+ signersPubKeys?: Uint8Array[];
150
+ /**
151
+ * Taproot spend path policy. Use `key` to force key-path estimation,
152
+ * or `script` to estimate script-path spends.
153
+ *
154
+ * This setting only applies to `tr(KEY,TREE)` descriptors.
155
+ * For `tr(KEY)` descriptors, only key-path is available.
156
+ *
157
+ * When `script` is selected:
158
+ * - if `tapLeaf` is provided, that leaf is used.
159
+ * - if `tapLeaf` is omitted, the satisfier auto-selects the leaf with the
160
+ * smallest witness among satisfiable candidates.
161
+ *
162
+ * Default policy is `script` for `tr(KEY,TREE)` and `key` for key-only
163
+ * taproot descriptors (`tr(KEY)` and `addr(TR_ADDRESS)`).
164
+ */
165
+ taprootSpendPath?: "key" | "script";
166
+ /**
167
+ * Optional taproot leaf selector (tapleaf hash or miniscript string).
168
+ * Only used when taprootSpendPath is `script` and descriptor is
169
+ * `tr(KEY,TREE)`. If omitted, the smallest satisfiable leaf is selected.
170
+ */
171
+ tapLeaf?: Uint8Array | string;
172
+ }): {
173
+ readonly "__#private@#payment": Payment;
174
+ readonly "__#private@#preimages": Preimage[];
175
+ readonly "__#private@#signersPubKeys"?: Uint8Array[];
176
+ readonly "__#private@#miniscript"?: string;
177
+ readonly "__#private@#witnessScript"?: Uint8Array;
178
+ readonly "__#private@#redeemScript"?: Uint8Array;
179
+ readonly "__#private@#isSegwit"?: boolean;
180
+ readonly "__#private@#isTaproot"?: boolean;
181
+ readonly "__#private@#expandedExpression"?: string;
182
+ readonly "__#private@#expandedMiniscript"?: string;
183
+ readonly "__#private@#tapTreeExpression"?: string;
184
+ readonly "__#private@#tapTree"?: TapTreeNode;
185
+ readonly "__#private@#tapTreeInfo"?: TapTreeInfoNode;
186
+ readonly "__#private@#taprootSpendPath": "key" | "script";
187
+ readonly "__#private@#tapLeaf"?: Uint8Array | string;
188
+ readonly "__#private@#expansionMap"?: ExpansionMap;
189
+ readonly "__#private@#network": Network;
190
+ "__#private@#resolveMiniscriptSignersPubKeys"(): Uint8Array[];
191
+ "__#private@#assertMiniscriptSatisfactionResourceLimits"(scriptSatisfaction: Uint8Array): void;
192
+ /**
193
+ * Returns the compiled Script Satisfaction for a miniscript-based Output.
194
+ * The satisfaction is the unlocking script, derived by the Satisfier
195
+ * algorithm (https://bitcoin.sipa.be/miniscript/).
196
+ *
197
+ * This method uses a two-pass flow:
198
+ * 1) Planning: constraints (nLockTime/nSequence) are computed using fake
199
+ * signatures. This is done since the final solution may not need all the
200
+ * signatures in signersPubKeys. And we may avoid the user do extra
201
+ * signing (tedious op with HWW).
202
+ * 2) Signing: the provided signatures are used to build the final
203
+ * satisfaction, while enforcing the planned constraints so the same
204
+ * solution is selected. Not all the signatures of signersPubKeys may
205
+ * be required.
206
+ *
207
+ * The return value includes the satisfaction script and the constraints.
208
+ */
209
+ getScriptSatisfaction(signatures: PartialSig[]): {
210
+ scriptSatisfaction: Uint8Array;
211
+ nLockTime: number | undefined;
212
+ nSequence: number | undefined;
213
+ };
214
+ "__#private@#resolveTapTreeSignersPubKeys"(): Uint8Array[];
215
+ /**
216
+ * Returns the taproot script‑path satisfaction for a tap miniscript
217
+ * descriptor. This mirrors {@link getScriptSatisfaction} and uses the same
218
+ * two‑pass plan/sign flow.
219
+ *
220
+ * In addition to nLockTime/nSequence, it returns the selected tapLeafHash
221
+ * (the leaf chosen during planning) and the leaf’s tapscript.
222
+ */
223
+ getTapScriptSatisfaction(signatures: PartialSig[]): TaprootLeafSatisfaction;
224
+ /**
225
+ * Gets the planning constraints (nSequence and nLockTime) derived from the
226
+ * descriptor, just using the expression, signersPubKeys and preimages
227
+ * (using fake signatures).
228
+ * For taproot script-path spends, it also returns the selected tapLeafHash.
229
+ *
230
+ * We just need to know which will be the signatures that will be
231
+ * used (signersPubKeys) but final signatures are not necessary for
232
+ * obtaning nLockTime and nSequence.
233
+ *
234
+ * Remember: nSequence and nLockTime are part of the hash that is signed.
235
+ * Thus, they must not change after computing the signatures.
236
+ * When running miniscript satisfactions with final signatures,
237
+ * satisfyMiniscript verifies that the time constraints did not change.
238
+ */
239
+ "__#private@#getConstraints"(): {
240
+ nLockTime: number | undefined;
241
+ nSequence: number | undefined;
242
+ tapLeafHash: Uint8Array | undefined;
243
+ } | undefined;
244
+ /**
245
+ * Creates and returns an instance of bitcoinjs-lib
246
+ * [`Payment`](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/ts_src/payments/index.ts)'s interface with the `scriptPubKey` of this `Output`.
247
+ */
248
+ getPayment(): Payment;
249
+ /**
250
+ * Returns the Bitcoin Address of this `Output`.
251
+ */
252
+ getAddress(): string;
253
+ /**
254
+ * Returns this `Output`'s scriptPubKey.
255
+ */
256
+ getScriptPubKey(): Uint8Array;
257
+ /**
258
+ * Gets the nSequence required to fulfill this `Output`.
259
+ */
260
+ getSequence(): number | undefined;
261
+ /**
262
+ * Gets the nLockTime required to fulfill this `Output`.
263
+ */
264
+ getLockTime(): number | undefined;
265
+ /**
266
+ * Returns the tapleaf hash selected during planning for taproot script-path
267
+ * spends. If signersPubKeys are provided, selection is optimized for those
268
+ * pubkeys. If a specific tapLeaf selector is used in spending calls, this
269
+ * reflects that selection.
270
+ */
271
+ getTapLeafHash(): Uint8Array | undefined;
272
+ /**
273
+ * Gets the witnessScript required to fulfill this `Output`. Only applies to
274
+ * Segwit outputs.
275
+ */
276
+ getWitnessScript(): Uint8Array | undefined;
277
+ /**
278
+ * Gets the redeemScript required to fullfill this `Output`. Only applies to
279
+ * SH outputs: sh(wpkh), sh(wsh), sh(lockingScript).
280
+ */
281
+ getRedeemScript(): Uint8Array | undefined;
282
+ /**
283
+ * Gets the bitcoinjs-lib [`network`](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/ts_src/networks.ts) used to create this `Output`.
284
+ */
285
+ getNetwork(): Network;
286
+ /**
287
+ * Whether this `Output` is Segwit.
288
+ *
289
+ * *NOTE:* When the descriptor in an input is `addr(address)`, it is assumed
290
+ * that any `addr(SH_TYPE_ADDRESS)` is in fact a Segwit `SH_WPKH`
291
+ * (Script Hash-Witness Public Key Hash).
292
+ * For inputs using arbitrary scripts (not standard addresses),
293
+ * use a descriptor in the format `sh(MINISCRIPT)`.
294
+ *
295
+ */
296
+ isSegwit(): boolean | undefined;
297
+ /**
298
+ * Whether this `Output` is Taproot.
299
+ */
300
+ isTaproot(): boolean | undefined;
301
+ /**
302
+ * Attempts to determine the type of output script by testing it against
303
+ * various payment types.
304
+ *
305
+ * This method tries to identify if the output is one of the following types:
306
+ * - P2SH (Pay to Script Hash)
307
+ * - P2WSH (Pay to Witness Script Hash)
308
+ * - P2WPKH (Pay to Witness Public Key Hash)
309
+ * - P2PKH (Pay to Public Key Hash)
310
+ * - P2TR (Pay to Taproot)
311
+ *
312
+ * @returns An object { isPKH: boolean; isWPKH: boolean; isSH: boolean; isWSH: boolean; isTR: boolean;}
313
+ * with boolean properties indicating the detected output type
314
+ */
315
+ guessOutput(): {
316
+ isPKH: boolean;
317
+ isWPKH: boolean;
318
+ isSH: boolean;
319
+ isWSH: boolean;
320
+ isTR: boolean;
321
+ };
322
+ /**
323
+ * Computes the Weight Unit contributions of this Output as if it were the
324
+ * input in a tx.
325
+ *
326
+ * *NOTE:* When the descriptor in an input is `addr(address)`, it is assumed
327
+ * that any `addr(SH_TYPE_ADDRESS)` is in fact a Segwit `SH_WPKH`
328
+ * (Script Hash-Witness Public Key Hash).
329
+ *, Also any `addr(SINGLE_KEY_ADDRESS)` * is assumed to be a single key Taproot
330
+ * address (like those defined in BIP86).
331
+ * For inputs using arbitrary scripts (not standard addresses),
332
+ * use a descriptor in the format `sh(MINISCRIPT)`, `wsh(MINISCRIPT)` or
333
+ * `tr(KEY,TREE)` for taproot script-path expressions.
334
+ */
335
+ inputWeight(isSegwitTx: boolean, signatures: PartialSig[] | "DANGEROUSLY_USE_FAKE_SIGNATURES", options?: {
336
+ taprootSighash?: "SIGHASH_DEFAULT" | "non-SIGHASH_DEFAULT";
337
+ }): number;
338
+ /**
339
+ * Computes the Weight Unit contributions of this Output as if it were the
340
+ * output in a tx.
341
+ */
342
+ outputWeight(): number;
343
+ /**
344
+ * Sets this output as an input of the provided `psbt` and updates the
345
+ * `psbt` locktime if required by the descriptor.
346
+ *
347
+ * `psbt` and `vout` are mandatory. Include `txHex` as well. The pair
348
+ * `vout` and `txHex` define the transaction and output number this instance
349
+ * pertains to.
350
+ *
351
+ * Though not advised, for Segwit inputs you can pass `txId` and `value`
352
+ * in lieu of `txHex`. If doing so, ensure `value` accuracy to avoid
353
+ * potential fee attacks -
354
+ * [See this issue](https://github.com/bitcoinjs/bitcoinjs-lib/issues/1625).
355
+ *
356
+ * Note: Hardware wallets need the [full `txHex` for Segwit](https://blog.trezor.io/details-of-firmware-updates-for-trezor-one-version-1-9-1-and-trezor-model-t-version-2-3-1-1eba8f60f2dd).
357
+ *
358
+ * When unsure, always use `txHex`, and skip `txId` and `value` for safety.
359
+ *
360
+ * Use `rbf` to mark whether this tx can be replaced with another with
361
+ * higher fee while being in the mempool. Note that a tx will automatically
362
+ * be marked as replacable if a single input requests it.
363
+ * Note that any transaction using a relative timelock (nSequence < 0x80000000)
364
+ * also falls within the RBF range (nSequence < 0xFFFFFFFE), making it
365
+ * inherently replaceable. So don't set `rbf` to false if this is tx uses
366
+ * relative time locks.
367
+ *
368
+ * @returns A finalizer function to be used after signing the `psbt`.
369
+ * This function ensures that this input is properly finalized.
370
+ * The finalizer completes the PSBT input by adding the unlocking script
371
+ * (`scriptWitness` or `scriptSig`) that satisfies this `Output`'s spending
372
+ * conditions. Because these scripts include signatures, you should finish
373
+ * all signing operations before calling the finalizer.
374
+ * The finalizer has this signature:
375
+ *
376
+ * `( { psbt, validate = true } : { psbt: PsbtLike | ScureTransactionLike; validate: boolean | undefined } ) => void`
377
+ *
378
+ * where `psbt` can be either a
379
+ * {@link https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/ts_src/psbt.ts | bitcoinjs-lib `Psbt`}
380
+ * or a {@link https://github.com/paulmillr/scure-btc-signer | `@scure/btc-signer` `Transaction`}.
381
+ *
382
+ */
383
+ updatePsbtAsInput({ psbt, txHex, txId, value, vout, rbf }: {
384
+ psbt: PsbtLike | ScureTransactionLike;
385
+ txHex?: string;
386
+ txId?: string;
387
+ value?: bigint;
388
+ vout: number;
389
+ rbf?: boolean;
390
+ }): ({ psbt, validate }: {
391
+ psbt: PsbtLike | ScureTransactionLike;
392
+ /** Runs further test on the validity of the signatures.
393
+ * It speeds down the finalization process but makes sure the psbt will
394
+ * be valid.
395
+ * @default true */
396
+ validate?: boolean | undefined;
397
+ }) => void;
398
+ /**
399
+ * Adds this output as an output of the provided `psbt` with the given
400
+ * value.
401
+ * @param params - The parameters for the method.
402
+ * @param params.psbt - Either a
403
+ * {@link https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/ts_src/psbt.ts | bitcoinjs-lib `Psbt`}
404
+ * or a {@link https://github.com/paulmillr/scure-btc-signer | `@scure/btc-signer` `Transaction`}.
405
+ * @param params.value - The value for the output in satoshis.
406
+ */
407
+ updatePsbtAsOutput({ psbt, value }: {
408
+ psbt: PsbtLike | ScureTransactionLike;
409
+ value: bigint;
410
+ }): void;
411
+ "__#private@#assertPsbtInput"({ psbt, index }: {
412
+ psbt: PsbtLike | ScureTransactionLike;
413
+ index: number;
414
+ }): void;
415
+ /**
416
+ * Decomposes the descriptor used to form this `Output` into its elemental
417
+ * parts. See {@link ExpansionMap ExpansionMap} for a detailed explanation.
418
+ */
419
+ expand(): {
420
+ expansionMap?: ExpansionMap;
421
+ tapTreeInfo?: TapTreeInfoNode;
422
+ tapTree?: TapTreeNode;
423
+ tapTreeExpression?: string;
424
+ expandedMiniscript?: string;
425
+ miniscript?: string;
426
+ expandedExpression?: string;
427
+ };
428
+ };
429
+ };
430
+ parseKeyExpression: KeyExpressionParser;
431
+ expand: (params: {
432
+ /**
433
+ * The descriptor expression to be expanded.
434
+ */
435
+ descriptor: string;
436
+ /**
437
+ * The descriptor index, if ranged.
438
+ */
439
+ index?: number;
440
+ /**
441
+ * Multipath branch selector used for descriptor key-path tuples like
442
+ * `/<0;1>/*` (and shorthand `/**`).
443
+ *
444
+ * The value passed in `change` must be one of the numbers present in the
445
+ * tuple. For example:
446
+ * - `/<0;1>/*` accepts `change: 0` or `change: 1`
447
+ * - `/<0;1;2>/*` accepts `change: 0`, `1` or `2`
448
+ */
449
+ change?: number;
450
+ /**
451
+ * A flag indicating whether the descriptor is required to include a checksum.
452
+ * @defaultValue false
453
+ */
454
+ checksumRequired?: boolean;
455
+ /**
456
+ * The Bitcoin network to use.
457
+ * @defaultValue `networks.bitcoin`
458
+ */
459
+ network?: Network;
460
+ /**
461
+ * Flag to allow miniscript in P2SH.
462
+ * @defaultValue false
463
+ */
464
+ allowMiniscriptInP2SH?: boolean;
465
+ }) => Expansion;
466
+ ECPair: ECPairAPI;
467
+ BIP32: BIP32API;
468
+ };
469
+ type OutputConstructor = ReturnType<typeof DescriptorsFactory>['Output'];
470
+ /**
471
+ * The {@link DescriptorsFactory | `DescriptorsFactory`} function internally
472
+ * creates and returns the {@link _Internal_.Output | `Output`} class.
473
+ * This class is specialized for the provided `TinySecp256k1Interface`.
474
+ * Use `OutputInstance` to declare instances for this class:
475
+ * `const output: OutputInstance = new Output();`
476
+ *
477
+ * See the {@link _Internal_.Output | documentation for the internal `Output`
478
+ * class} for a complete list of available methods.
479
+ */
480
+ type OutputInstance = InstanceType<OutputConstructor>;
481
+ export { OutputInstance, OutputConstructor };