@scure/btc-signer 2.0.0 → 2.2.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.
package/payment.d.ts CHANGED
@@ -2,13 +2,20 @@ import { type Coder } from '@scure/base';
2
2
  import * as P from 'micro-packed';
3
3
  import { type TransactionInput } from './psbt.ts';
4
4
  import { type ScriptType } from './script.ts';
5
- import { type BTC_NETWORK, type Bytes } from './utils.ts';
5
+ import { type BTC_NETWORK, type Bytes, type TArg, type TRet } from './utils.ts';
6
+ /** Common shape returned by payment helper constructors. */
6
7
  export type P2Ret = {
8
+ /** Payment-script tag such as `pkh`, `wpkh`, or `tr`. */
7
9
  type: string;
10
+ /** Serialized output script for the payment descriptor. */
8
11
  script: Bytes;
12
+ /** Encoded address when the script has a standard address form. */
9
13
  address?: string;
14
+ /** Redeem script for wrapped script-hash descriptors. */
10
15
  redeemScript?: Bytes;
16
+ /** Witness script for SegWit script-hash descriptors. */
11
17
  witnessScript?: Bytes;
18
+ /** Hash committed by the output script when applicable. */
12
19
  hash?: Bytes;
13
20
  };
14
21
  type OutP2AType = {
@@ -19,6 +26,7 @@ type OutPKType = {
19
26
  type: 'pk';
20
27
  pubkey: Bytes;
21
28
  };
29
+ /** Optional parsed script result used by output-script coders. */
22
30
  export type OptScript = ScriptType | undefined;
23
31
  type OutPKHType = {
24
32
  type: 'pkh';
@@ -65,60 +73,208 @@ type FinalizeSignature = [{
65
73
  type CustomScriptOut = {
66
74
  type: string;
67
75
  } & Record<string, any>;
76
+ /** Custom taproot script coder/finalizer hook. */
68
77
  export type CustomScript = Coder<OptScript, CustomScriptOut | undefined> & {
69
78
  finalizeTaproot?: (script: Bytes, parsed: CustomScriptOut, signatures: FinalizeSignature[]) => Bytes[] | undefined;
70
79
  };
71
- export declare const OutScript: P.CoderType<NonNullable<OutP2AType | OutPKType | OutPKHType | OutSHType | OutWSHType | OutWPKHType | OutMSType | OutTRType | OutTRNSType | OutTRMSType | OutUnknownType | undefined>>;
80
+ /**
81
+ * Coder for recognized Bitcoin output scripts.
82
+ * @example
83
+ * Decode a serialized output script back into the tagged payment descriptor.
84
+ * ```ts
85
+ * import { OutScript, p2wpkh } from '@scure/btc-signer/payment.js';
86
+ * import { pubECDSA, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
87
+ * const pay = p2wpkh(pubECDSA(randomPrivateKeyBytes()));
88
+ * OutScript.decode(pay.script);
89
+ * ```
90
+ */
91
+ export declare const OutScript: TRet<P.CoderType<NonNullable<OutP2AType | OutPKType | OutPKHType | OutSHType | OutWSHType | OutWPKHType | OutMSType | OutTRType | OutTRNSType | OutTRMSType | OutUnknownType | undefined>>>;
92
+ /** Type of the output-script coder. */
72
93
  export type OutScriptType = typeof OutScript;
73
- export declare function checkScript(script?: Bytes, redeemScript?: Bytes, witnessScript?: Bytes): void;
94
+ type OutScriptValue = ReturnType<OutScriptType['decode']> | undefined;
95
+ /**
96
+ * Validates that nested redeem and witness scripts match their wrappers.
97
+ * @param script - top-level output script
98
+ * @param redeemScript - optional redeem script for P2SH wrappers
99
+ * @param witnessScript - optional witness script for P2WSH wrappers
100
+ * @throws If the script nesting is invalid or unsupported. {@link Error}
101
+ * @example
102
+ * Verify that wrapped scripts and hashes still match after custom edits.
103
+ * ```ts
104
+ * import { hex } from '@scure/base';
105
+ * import { checkScript, p2pkh, p2sh } from '@scure/btc-signer/payment.js';
106
+ * const wrapped = p2sh(
107
+ * p2pkh(hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'))
108
+ * );
109
+ * checkScript(wrapped.script, wrapped.redeemScript);
110
+ * ```
111
+ */
112
+ export declare function checkScript(script?: TArg<Bytes>, redeemScript?: TArg<Bytes>, witnessScript?: TArg<Bytes>): void;
74
113
  type Extends<T, U> = T extends U ? T : never;
114
+ /** Pay-to-public-key output descriptor. */
75
115
  export type P2PK = {
116
+ /** Payment-script tag for pay-to-public-key outputs. */
76
117
  type: 'pk';
77
- script: Bytes;
118
+ /** Serialized `pubkey CHECKSIG` script. */
119
+ script: TRet<Bytes>;
78
120
  };
79
- export declare const p2pk: (pubkey: Bytes, _network?: BTC_NETWORK) => Extends<P2PK, P2Ret>;
121
+ /**
122
+ * Builds a pay-to-public-key script.
123
+ * @param pubkey - compressed or uncompressed ECDSA public key
124
+ * @param _network - unused network placeholder for API consistency
125
+ * @returns P2PK descriptor.
126
+ * @throws If the public key cannot be encoded as a P2PK output. {@link Error}
127
+ * @example
128
+ * Build a bare pay-to-public-key output.
129
+ * ```ts
130
+ * import { hex } from '@scure/base';
131
+ * import { p2pk } from '@scure/btc-signer/payment.js';
132
+ * p2pk(hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'));
133
+ * ```
134
+ */
135
+ export declare const p2pk: (pubkey: TArg<Bytes>, _network?: BTC_NETWORK) => TRet<Extends<P2PK, P2Ret>>;
136
+ /** Pay-to-public-key-hash output descriptor. */
80
137
  export type P2PKH = {
138
+ /** Payment-script tag for pay-to-public-key-hash outputs. */
81
139
  type: 'pkh';
82
- script: Bytes;
140
+ /** Serialized P2PKH script. */
141
+ script: TRet<Bytes>;
142
+ /** Base58Check address for the descriptor. */
83
143
  address: string;
84
- hash: Bytes;
144
+ /** HASH160 committed by the script. */
145
+ hash: TRet<Bytes>;
85
146
  };
86
- export declare const p2pkh: (publicKey: Bytes, network?: BTC_NETWORK) => Extends<P2PKH, P2Ret>;
147
+ /**
148
+ * Builds a P2PKH output from a public key.
149
+ * @param publicKey - compressed or uncompressed ECDSA public key bytes; HASH160 commits to the exact encoding
150
+ * @param network - address network parameters
151
+ * @returns P2PKH descriptor.
152
+ * @throws If the public key cannot be encoded as a P2PKH output. {@link Error}
153
+ * @example
154
+ * Build a classic pay-to-public-key-hash output.
155
+ * ```ts
156
+ * import { hex } from '@scure/base';
157
+ * import { p2pkh } from '@scure/btc-signer/payment.js';
158
+ * p2pkh(hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'));
159
+ * ```
160
+ */
161
+ export declare const p2pkh: (publicKey: TArg<Bytes>, network?: BTC_NETWORK) => TRet<Extends<P2PKH, P2Ret>>;
162
+ /** Shared fields for pay-to-script-hash outputs. */
87
163
  export type P2SHBase = {
164
+ /** Payment-script tag for pay-to-script-hash outputs. */
88
165
  type: 'sh';
89
- redeemScript: Bytes;
90
- script: Bytes;
166
+ /** Child script wrapped by the P2SH output. */
167
+ redeemScript: TRet<Bytes>;
168
+ /** Serialized P2SH script. */
169
+ script: TRet<Bytes>;
170
+ /** Base58Check address for the descriptor. */
91
171
  address: string;
92
- hash: Bytes;
172
+ /** HASH160 committed by the script. */
173
+ hash: TRet<Bytes>;
93
174
  };
175
+ /** P2SH descriptor with an embedded witness script. */
94
176
  export type P2SHWithWitness = P2SHBase & {
95
- witnessScript: Bytes;
177
+ witnessScript: TRet<Bytes>;
96
178
  };
179
+ /** P2SH descriptor without an embedded witness script. */
97
180
  export type P2SHWithoutWitness = Omit<P2SHBase, 'witnessScript'>;
181
+ /** Conditional P2SH return type for wrapped scripts. */
98
182
  export type P2SHReturn<T extends P2Ret> = T extends {
99
183
  witnessScript: Bytes;
100
184
  } ? P2SHWithWitness : P2SHWithoutWitness;
101
- export declare const p2sh: <T extends P2Ret>(child: T, network?: BTC_NETWORK) => Extends<P2SHReturn<T>, P2Ret>;
185
+ /**
186
+ * Wraps a child script inside P2SH.
187
+ * @param child - child payment descriptor to wrap
188
+ * @param network - address network parameters
189
+ * @returns P2SH descriptor preserving witness metadata when present.
190
+ * @throws If the wrapped script combination is invalid or unsupported. {@link Error}
191
+ * @example
192
+ * Wrap a child script in P2SH so it gets a base58 address form.
193
+ * ```ts
194
+ * import { hex } from '@scure/base';
195
+ * import { p2pk, p2sh, p2wsh } from '@scure/btc-signer/payment.js';
196
+ * p2sh(p2wsh(p2pk(hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'))));
197
+ * ```
198
+ */
199
+ export declare const p2sh: <T extends P2Ret>(child: TArg<T>, network?: BTC_NETWORK) => TRet<Extends<P2SHReturn<T>, P2Ret>>;
200
+ /** Pay-to-witness-script-hash descriptor. */
102
201
  export type P2WSH = {
202
+ /** Payment-script tag for pay-to-witness-script-hash outputs. */
103
203
  type: 'wsh';
104
- witnessScript: Bytes;
105
- script: Bytes;
204
+ /** Child script committed by the witness program. */
205
+ witnessScript: TRet<Bytes>;
206
+ /** Serialized P2WSH script. */
207
+ script: TRet<Bytes>;
208
+ /** Bech32 address for the descriptor. */
106
209
  address: string;
107
- hash: Bytes;
210
+ /** SHA256 committed by the witness program. */
211
+ hash: TRet<Bytes>;
108
212
  };
109
- export declare const p2wsh: (child: P2Ret, network?: BTC_NETWORK) => Extends<P2WSH, P2Ret>;
213
+ /**
214
+ * Wraps a child script inside native SegWit P2WSH.
215
+ * @param child - child payment descriptor to wrap
216
+ * @param network - address network parameters
217
+ * @returns P2WSH descriptor.
218
+ * @throws If the wrapped script combination is invalid or unsupported. {@link Error}
219
+ * @example
220
+ * Wrap a child script in native SegWit P2WSH.
221
+ * ```ts
222
+ * import { hex } from '@scure/base';
223
+ * import { p2pk, p2wsh } from '@scure/btc-signer/payment.js';
224
+ * p2wsh(p2pk(hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')));
225
+ * ```
226
+ */
227
+ export declare const p2wsh: (child: TArg<P2Ret>, network?: BTC_NETWORK) => TRet<Extends<P2WSH, P2Ret>>;
228
+ /** Pay-to-witness-public-key-hash descriptor. */
110
229
  export type P2WPKH = {
230
+ /** Payment-script tag for pay-to-witness-public-key-hash outputs. */
111
231
  type: 'wpkh';
112
- script: Bytes;
232
+ /** Serialized P2WPKH script. */
233
+ script: TRet<Bytes>;
234
+ /** Bech32 address for the descriptor. */
113
235
  address: string;
114
- hash: Bytes;
236
+ /** HASH160 committed by the witness program. */
237
+ hash: TRet<Bytes>;
115
238
  };
116
- export declare const p2wpkh: (publicKey: Bytes, network?: BTC_NETWORK) => Extends<P2WPKH, P2Ret>;
239
+ /**
240
+ * Builds a native SegWit P2WPKH output from a public key.
241
+ * @param publicKey - compressed ECDSA public key
242
+ * @param network - address network parameters
243
+ * @returns P2WPKH descriptor.
244
+ * @throws If the public key cannot be encoded as a P2WPKH output. {@link Error}
245
+ * @example
246
+ * Build a native SegWit pay-to-public-key-hash output.
247
+ * ```ts
248
+ * import { hex } from '@scure/base';
249
+ * import { p2wpkh } from '@scure/btc-signer/payment.js';
250
+ * p2wpkh(hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'));
251
+ * ```
252
+ */
253
+ export declare const p2wpkh: (publicKey: TArg<Bytes>, network?: BTC_NETWORK) => TRet<Extends<P2WPKH, P2Ret>>;
254
+ /** Bare multisig output descriptor. */
117
255
  export type P2MS = {
256
+ /** Payment-script tag for bare multisig outputs. */
118
257
  type: 'ms';
119
- script: Bytes;
258
+ /** Serialized bare multisig script. */
259
+ script: TRet<Bytes>;
120
260
  };
121
- export declare const p2ms: (m: number, pubkeys: Bytes[], allowSamePubkeys?: boolean) => Extends<P2MS, P2Ret>;
261
+ /**
262
+ * Builds a bare multisig script.
263
+ * @param m - number of required signatures
264
+ * @param pubkeys - participating public keys
265
+ * @param allowSamePubkeys - whether duplicate keys are allowed
266
+ * @returns P2MS descriptor.
267
+ * @throws If the multisig parameters are invalid. {@link Error}
268
+ * @example
269
+ * Build a bare multisig output script.
270
+ * ```ts
271
+ * import { hex } from '@scure/base';
272
+ * import { p2ms } from '@scure/btc-signer/payment.js';
273
+ * p2ms(1, [hex.decode('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')], true);
274
+ * ```
275
+ */
276
+ export declare const p2ms: (m: number, pubkeys: TArg<Bytes[]>, allowSamePubkeys?: boolean) => TRet<Extends<P2MS, P2Ret>>;
277
+ /** Internal taproot hash tree without merkle paths. */
122
278
  export type HashedTree = {
123
279
  type: 'leaf';
124
280
  version?: number;
@@ -130,33 +286,66 @@ export type HashedTree = {
130
286
  right: HashedTree;
131
287
  hash: Bytes;
132
288
  };
289
+ /** Taproot key-path descriptor. */
133
290
  export type P2TR = {
291
+ /** Payment-script tag for taproot outputs. */
134
292
  type: 'tr';
293
+ /** Serialized v1 witness-program script. */
135
294
  script: Bytes;
295
+ /** Bech32m address for the descriptor. */
136
296
  address: string;
297
+ /** Tweaked x-only output key committed by the address and script. */
137
298
  tweakedPubkey: Bytes;
299
+ /** Internal x-only taproot key before tweaking. */
138
300
  tapInternalKey: Bytes;
139
301
  };
302
+ /** Taproot descriptor with a script tree attached. */
140
303
  export type P2TR_TREE = P2TR & {
141
304
  tapMerkleRoot: Bytes;
142
305
  tapLeafScript: TransactionInput['tapLeafScript'];
143
306
  leaves: TaprootLeaf[];
144
307
  };
308
+ /** Node accepted when constructing a taproot script tree. */
145
309
  export type TaprootNode = {
146
310
  script: Bytes | string;
147
311
  leafVersion?: number;
148
312
  weight?: number;
149
313
  } & Partial<P2TR_TREE>;
314
+ /** Recursive taproot tree input. */
150
315
  export type TaprootScriptTree = TaprootNode | TaprootScriptTree[];
316
+ /** Flat list of weighted taproot leaves. */
151
317
  export type TaprootScriptList = TaprootNode[];
152
- export declare function taprootListToTree(taprootList: TaprootScriptList): TaprootScriptTree;
318
+ /**
319
+ * Converts a flat list of weighted leaves into a binary taproot tree.
320
+ * @param taprootList - weighted leaves to arrange
321
+ * @returns Binary taproot script tree.
322
+ * @throws If the list is empty and cannot describe any tree. {@link Error}
323
+ * @example
324
+ * Start from a flat weighted list, then let the helper build the binary tree shape.
325
+ * ```ts
326
+ * import { hex } from '@scure/base';
327
+ * import { p2tr_pk, taprootListToTree } from '@scure/btc-signer/payment.js';
328
+ * taprootListToTree([
329
+ * p2tr_pk(hex.decode('f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9')),
330
+ * p2tr_pk(hex.decode('dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659')),
331
+ * ]);
332
+ * ```
333
+ */
334
+ export declare function taprootListToTree(taprootList: TArg<TaprootScriptList>): TRet<TaprootScriptTree>;
335
+ /** Taproot leaf with its merkle path. */
153
336
  export type TaprootLeaf = {
337
+ /** Leaf marker inside the annotated taproot tree. */
154
338
  type: 'leaf';
339
+ /** Tapleaf version committed by the merkle tree. */
155
340
  version?: number;
341
+ /** Serialized leaf script. */
156
342
  script: Bytes;
343
+ /** Tagged tapleaf hash for the script and version. */
157
344
  hash: Bytes;
345
+ /** Merkle path hashes required for script-path spending. */
158
346
  path: Bytes[];
159
347
  };
348
+ /** Internal taproot tree annotated with merkle paths. */
160
349
  export type HashedTreeWithPath = TaprootLeaf | {
161
350
  type: 'branch';
162
351
  left: HashedTreeWithPath;
@@ -164,37 +353,217 @@ export type HashedTreeWithPath = TaprootLeaf | {
164
353
  hash: Bytes;
165
354
  path: Bytes[];
166
355
  };
356
+ /** Default tapleaf version used by taproot script-path outputs before adding the parity bit. */
167
357
  export declare const TAP_LEAF_VERSION = 192;
168
- export declare const tapLeafHash: (script: Bytes, version?: number) => Bytes;
358
+ /**
359
+ * Computes the tagged hash of a tapleaf script.
360
+ * @param script - tapleaf script bytes
361
+ * @param version - base even tapleaf version byte (for tapscript, `0xc0`)
362
+ * @returns Tapleaf hash.
363
+ * @throws If the tapleaf version is not a valid even one-byte version.
364
+ * {@link Error}
365
+ * @example
366
+ * Hash a finalized tapscript leaf before placing it into a Merkle tree.
367
+ * ```ts
368
+ * tapLeafHash(new Uint8Array([0x51]));
369
+ * ```
370
+ */
371
+ export declare const tapLeafHash: (script: TArg<Bytes>, version?: number) => TRet<Bytes>;
372
+ /** Conditional taproot return type for key-only or tree-backed outputs. */
169
373
  export type P2TRRet<T> = T extends TaprootScriptTree ? P2TR_TREE : P2TR;
170
- export declare function p2tr(internalPubKey: Bytes | string, tree?: undefined, network?: BTC_NETWORK, allowUnknownOutputs?: boolean, customScripts?: CustomScript[]): Extends<P2TR, P2Ret>;
171
- export declare function p2tr(internalPubKey: Bytes | string, tree: TaprootScriptTree, network?: BTC_NETWORK, allowUnknownOutputs?: boolean, customScripts?: CustomScript[]): Extends<P2TR_TREE, P2Ret>;
374
+ /**
375
+ * Builds a taproot output from an internal key and optional script tree.
376
+ * @param internalPubKey - x-only internal public key, hex string, or `undefined` for script-only outputs
377
+ * @param tree - optional taproot script tree
378
+ * @param network - address network parameters
379
+ * @param allowUnknownOutputs - whether unknown leaf scripts are allowed
380
+ * @param customScripts - optional custom script codecs for taproot leaves
381
+ * @returns Taproot descriptor with optional script-path metadata.
382
+ * @throws If the internal key or taproot script tree is invalid. {@link Error}
383
+ * @example
384
+ * Combine script leaves into a final taproot output descriptor and address.
385
+ * ```ts
386
+ * import { hex } from '@scure/base';
387
+ * import { p2tr, p2tr_pk } from '@scure/btc-signer/payment.js';
388
+ * p2tr(
389
+ * undefined,
390
+ * [p2tr_pk(hex.decode('f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9'))]
391
+ * );
392
+ * ```
393
+ */
394
+ export declare function p2tr(internalPubKey: TArg<Bytes | string>, tree?: undefined, network?: BTC_NETWORK, allowUnknownOutputs?: boolean, customScripts?: TArg<CustomScript[]>): TRet<Extends<P2TR, P2Ret>>;
395
+ export declare function p2tr(internalPubKey: TArg<Bytes | string | undefined>, tree: TArg<TaprootScriptTree>, network?: BTC_NETWORK, allowUnknownOutputs?: boolean, customScripts?: TArg<CustomScript[]>): TRet<Extends<P2TR_TREE, P2Ret>>;
396
+ /**
397
+ * Returns all size-`m` combinations from a list.
398
+ * @param m - size of each combination
399
+ * @param list - input items to combine
400
+ * @returns Array of combinations.
401
+ * @throws If the combination size or input list is invalid. {@link Error}
402
+ * @example
403
+ * Enumerate all size-two subsets of a short list.
404
+ * ```ts
405
+ * combinations(2, [1, 2, 3]);
406
+ * ```
407
+ */
172
408
  export declare function combinations<T>(m: number, list: T[]): T[][];
173
409
  /**
174
410
  * M-of-N multi-leaf wallet via p2tr_ns. If m == n, single script is emitted.
175
411
  * Takes O(n^2) if m != n. 99-of-100 is ok, 5-of-100 is not.
412
+ * It materializes C(n, m) leaves, so middle-of-the-range thresholds blow up combinatorially.
176
413
  * `2-of-[A,B,C] => [A,B] | [A,C] | [B,C]`
177
414
  */
178
415
  export type P2TR_NS = {
416
+ /** Payment-script tag for taproot `CHECKSIGVERIFY` leaf scripts. */
179
417
  type: 'tr_ns';
180
- script: Bytes;
418
+ /** Serialized tapscript leaf. */
419
+ script: TRet<Bytes>;
181
420
  };
182
- export declare const p2tr_ns: (m: number, pubkeys: Bytes[], allowSamePubkeys?: boolean) => Extends<P2TR_NS, P2Ret>[];
421
+ /**
422
+ * Builds the leaf set for an M-of-N `CHECKSIGVERIFY` taproot policy.
423
+ * @param m - number of required signatures
424
+ * @param pubkeys - participating Schnorr public keys
425
+ * @param allowSamePubkeys - whether duplicate keys are allowed
426
+ * @returns Array of taproot leaf descriptors.
427
+ * @throws If the taproot multisig parameters are invalid. {@link Error}
428
+ * @example
429
+ * Build the leaf set for an M-of-N taproot `CHECKSIGVERIFY` policy.
430
+ * ```ts
431
+ * import { hex } from '@scure/base';
432
+ * import { p2tr_ns } from '@scure/btc-signer/payment.js';
433
+ * p2tr_ns(1, [hex.decode('f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9')], true);
434
+ * ```
435
+ */
436
+ export declare const p2tr_ns: (m: number, pubkeys: TArg<Bytes[]>, allowSamePubkeys?: boolean) => TRet<Extends<P2TR_NS, P2Ret>[]>;
437
+ /** Single-key taproot leaf descriptor. */
183
438
  export type P2TR_PK = P2TR_NS;
184
- export declare const p2tr_pk: (pubkey: Bytes) => Extends<P2TR_PK, P2Ret>;
439
+ /**
440
+ * Builds a single-key taproot leaf script.
441
+ * BIP 341 design guidance: if this is the most likely single-key spend path, prefer
442
+ * using that key as the `p2tr()` internal key instead of forcing it into a script leaf.
443
+ * @param pubkey - Schnorr public key
444
+ * @returns Taproot single-key leaf descriptor.
445
+ * @throws If the taproot single-key leaf cannot be encoded. {@link Error}
446
+ * @example
447
+ * Build a single-key tapscript leaf.
448
+ * ```ts
449
+ * import { hex } from '@scure/base';
450
+ * import { p2tr_pk } from '@scure/btc-signer/payment.js';
451
+ * p2tr_pk(hex.decode('f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9'));
452
+ * ```
453
+ */
454
+ export declare const p2tr_pk: (pubkey: TArg<Bytes>) => TRet<Extends<P2TR_PK, P2Ret>>;
455
+ /** Taproot `CHECKSIGADD` multisig leaf descriptor. */
185
456
  export type P2TR_MS = {
457
+ /** Payment-script tag for taproot `CHECKSIGADD` leaf scripts. */
186
458
  type: 'tr_ms';
187
- script: Bytes;
459
+ /** Serialized tapscript leaf. */
460
+ script: TRet<Bytes>;
188
461
  };
189
- export declare function p2tr_ms(m: number, pubkeys: Bytes[], allowSamePubkeys?: boolean): Extends<P2TR_MS, P2Ret>;
190
- export declare function getAddress(type: 'pkh' | 'wpkh' | 'tr', privKey: Bytes, network?: BTC_NETWORK): string | undefined;
191
- export declare const _sortPubkeys: (pubkeys: Bytes[]) => Bytes[];
192
- export declare function multisig(m: number, pubkeys: Bytes[], sorted?: boolean, witness?: boolean, network?: BTC_NETWORK): P2Ret;
193
- export declare function sortedMultisig(m: number, pubkeys: Bytes[], witness?: boolean, network?: BTC_NETWORK): P2Ret;
194
- export declare function WIF(network?: BTC_NETWORK): Coder<Bytes, string>;
462
+ /**
463
+ * Builds a `CHECKSIGADD` taproot multisig leaf.
464
+ * @param m - number of required signatures
465
+ * @param pubkeys - participating Schnorr public keys
466
+ * @param allowSamePubkeys - whether duplicate keys are allowed
467
+ * @returns Taproot multisig leaf descriptor.
468
+ * @throws If the taproot multisig parameters are invalid. {@link Error}
469
+ * @example
470
+ * Build a `CHECKSIGADD` taproot multisig leaf.
471
+ * ```ts
472
+ * import { hex } from '@scure/base';
473
+ * import { p2tr_ms } from '@scure/btc-signer/payment.js';
474
+ * p2tr_ms(1, [hex.decode('f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9')], true);
475
+ * ```
476
+ */
477
+ export declare function p2tr_ms(m: number, pubkeys: TArg<Bytes[]>, allowSamePubkeys?: boolean): TRet<Extends<P2TR_MS, P2Ret>>;
478
+ /**
479
+ * Derives a simple address from a private key.
480
+ * @param type - address type to derive
481
+ * @param privKey - private key bytes
482
+ * @param network - address network parameters
483
+ * @returns Encoded Bitcoin address.
484
+ * @throws If the requested address type is unknown. {@link Error}
485
+ * @example
486
+ * Pick the output type first, then derive the matching address from the private key.
487
+ * ```ts
488
+ * import { getAddress } from '@scure/btc-signer/payment.js';
489
+ * import { randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
490
+ * getAddress('wpkh', randomPrivateKeyBytes());
491
+ * ```
492
+ */
493
+ export declare function getAddress(type: 'pkh' | 'wpkh' | 'tr', privKey: TArg<Bytes>, network?: BTC_NETWORK): string;
494
+ export declare const _sortPubkeys: (pubkeys: TArg<Bytes[]>) => TRet<Bytes[]>;
495
+ /**
496
+ * Builds a classic M-of-N multisig output, wrapped in P2SH or P2WSH.
497
+ * @param m - number of required signatures
498
+ * @param pubkeys - participating public keys
499
+ * @param sorted - whether to sort the public keys first
500
+ * @param witness - whether to wrap the result as native SegWit
501
+ * @param network - address network parameters
502
+ * @returns Multisig payment descriptor.
503
+ * @throws If the multisig parameters or wrapped script are invalid. {@link Error}
504
+ * @example
505
+ * Wrap a classic 2-of-2 script into an addressable multisig output.
506
+ * ```ts
507
+ * import { multisig } from '@scure/btc-signer/payment.js';
508
+ * import { pubECDSA, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
509
+ * multisig(
510
+ * 2,
511
+ * [pubECDSA(randomPrivateKeyBytes()), pubECDSA(randomPrivateKeyBytes())],
512
+ * true,
513
+ * true
514
+ * );
515
+ * ```
516
+ */
517
+ export declare function multisig(m: number, pubkeys: TArg<Bytes[]>, sorted?: boolean, witness?: boolean, network?: BTC_NETWORK): TRet<P2Ret>;
518
+ /**
519
+ * Builds a multisig output after lexicographically sorting the keys.
520
+ * @param m - number of required signatures
521
+ * @param pubkeys - participating public keys
522
+ * @param witness - whether to wrap the result as native SegWit
523
+ * @param network - address network parameters
524
+ * @returns Sorted multisig payment descriptor.
525
+ * @throws If the multisig parameters or wrapped script are invalid. {@link Error}
526
+ * @example
527
+ * Sort public keys deterministically before constructing the multisig address.
528
+ * ```ts
529
+ * import { sortedMultisig } from '@scure/btc-signer/payment.js';
530
+ * import { pubECDSA, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
531
+ * sortedMultisig(
532
+ * 2,
533
+ * [pubECDSA(randomPrivateKeyBytes()), pubECDSA(randomPrivateKeyBytes())],
534
+ * true
535
+ * );
536
+ * ```
537
+ */
538
+ export declare function sortedMultisig(m: number, pubkeys: TArg<Bytes[]>, witness?: boolean, network?: BTC_NETWORK): TRet<P2Ret>;
539
+ /**
540
+ * Wallet-import-format coder for private keys.
541
+ * @param network - address network parameters
542
+ * @returns WIF coder.
543
+ * @example
544
+ * Encode or decode wallet-import-format private keys.
545
+ * ```ts
546
+ * const coder = WIF();
547
+ * coder.encode(new Uint8Array(32).fill(1));
548
+ * ```
549
+ */
550
+ export declare function WIF(network?: BTC_NETWORK): TRet<Coder<Bytes, string>>;
551
+ /**
552
+ * Address encoder/decoder for a specific Bitcoin network.
553
+ * @param network - address network parameters
554
+ * @returns Address coder backed by the provided network.
555
+ * @example
556
+ * Create a network-specific address coder and encode a payment descriptor.
557
+ * ```ts
558
+ * import { Address, p2wpkh } from '@scure/btc-signer/payment.js';
559
+ * import { pubECDSA, randomPrivateKeyBytes } from '@scure/btc-signer/utils.js';
560
+ * const coder = Address();
561
+ * coder.encode(p2wpkh(pubECDSA(randomPrivateKeyBytes())));
562
+ * ```
563
+ */
195
564
  export declare function Address(network?: BTC_NETWORK): {
196
- encode(from: P.UnwrapCoder<OutScriptType>): string;
197
- decode(address: string): P.UnwrapCoder<OutScriptType>;
565
+ encode(from: Exclude<OutScriptValue, undefined>): string;
566
+ decode(address: string): OutScriptValue;
198
567
  };
199
568
  export {};
200
569
  //# sourceMappingURL=payment.d.ts.map
package/payment.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["src/payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,KAAK,EAA0B,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAmB,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAW,MAAM,YAAY,CAAC;AAOnE,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAGF,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC;AAcjD,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AA0B/C,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAY/C,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAY7C,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAW/C,KAAK,W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