@scure/btc-signer 2.2.0 → 2.4.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/transaction.d.ts CHANGED
@@ -74,6 +74,8 @@ export declare const def: <T>(value: T | undefined, def: T) => T;
74
74
  * ```
75
75
  */
76
76
  export declare function cloneDeep<T>(obj: T): T;
77
+ /** PSBT unknown/proprietary-field handling policy. */
78
+ export type Unknowns = psbt.Unknowns;
77
79
  /** Transaction construction and parsing options. */
78
80
  export interface TxOpts {
79
81
  /** Transaction version to place into new transactions and imported PSBTs. */
@@ -98,17 +100,36 @@ export interface TxOpts {
98
100
  allowUnknowInput?: boolean;
99
101
  /** Allow signing and finalizing inputs with unknown script shapes. */
100
102
  allowUnknownInputs?: boolean;
101
- /** Skip redeem-script and witness-script consistency checks. */
103
+ /** Skip redeem/witness-script and Taproot commitment consistency checks. */
102
104
  disableScriptCheck?: boolean;
103
105
  /** Match the odd empty-output encoding used by `bip174js`. */
104
106
  bip174jsCompat?: boolean;
105
107
  /** Permit legacy inputs that only provide witness UTXO data. */
106
108
  allowLegacyWitnessUtxo?: boolean;
109
+ /**
110
+ * Before signing, require every input to provide a full previous transaction whose txid and
111
+ * selected output match the input. Use this for untrusted or multi-party PSBTs to prevent forged
112
+ * witness-UTXO amounts from hiding an excessive transaction fee.
113
+ */
114
+ strictPrevoutValidation?: boolean;
107
115
  /** Grind ECDSA signatures until they use a low-R encoding. */
108
116
  lowR?: boolean;
109
117
  /** UNSAFE: additional custom payment-script codecs and finalizers. */
110
118
  customScripts?: CustomScript[];
111
- /** Preserve unknown PSBT key/value pairs instead of stripping them. */
119
+ /** Unknown PSBT field policy. Defaults to `strip`. */
120
+ unknown?: Unknowns;
121
+ /** Proprietary PSBT field policy. Defaults to the resolved {@link unknown} policy. */
122
+ proprietary?: Unknowns;
123
+ /**
124
+ * Treat an absent PSBTv2 transaction-modifiable field as allowing input/output changes. Older
125
+ * scure versions emitted PSBTv2 without this field, so this opts out of strict BIP370 behavior
126
+ * when upgrading and editing their PSBTs.
127
+ */
128
+ allowMissingTxModifiable?: boolean;
129
+ /**
130
+ * Deprecated alias for {@link unknown}: true selects `ignore`, false selects `strip`.
131
+ * @deprecated Use `unknown`.
132
+ */
112
133
  allowUnknown?: boolean;
113
134
  }
114
135
  /**
@@ -200,9 +221,12 @@ export declare function getPrevOut(input: TArg<psbt.TransactionInput>): P.Unwrap
200
221
  * @param i - input update to normalize
201
222
  * @param cur - existing input value to merge with
202
223
  * @param allowedFields - fields that may still change on signed inputs
203
- * @param disableScriptCheck - whether to skip redeem/witness script sanity checks
204
- * @param allowUnknown - whether to keep unknown PSBT fields
224
+ * @param disableScriptCheck - whether to skip wrapper and Taproot commitment sanity checks
225
+ * @param unknown - handling policy for unknown PSBT fields
226
+ * @param proprietary - handling policy for proprietary PSBT fields
205
227
  * @returns Normalized PSBT input.
228
+ * @throws If the update conflicts with the existing input or its signatures. {@link Error}
229
+ * @throws If a numeric input field is outside its wire or protocol range. {@link RangeError}
206
230
  * @example
207
231
  * Accept hex txids from callers in the same display-order form used by `Transaction.id`, then
208
232
  * normalize them into the repo's internal `TransactionInput` shape.
@@ -216,7 +240,7 @@ export declare function getPrevOut(input: TArg<psbt.TransactionInput>): P.Unwrap
216
240
  * });
217
241
  * ```
218
242
  */
219
- export declare function normalizeInput(i: TArg<psbt.TransactionInputUpdate>, cur?: TArg<PSBTInputs>, allowedFields?: TArg<readonly (keyof PSBTInputs)[]>, disableScriptCheck?: boolean, allowUnknown?: boolean): TRet<PSBTInputs>;
243
+ export declare function normalizeInput(i: TArg<psbt.TransactionInputUpdate>, cur?: TArg<PSBTInputs>, allowedFields?: TArg<readonly (keyof PSBTInputs)[]>, disableScriptCheck?: boolean, unknown?: Unknowns | boolean, proprietary?: Unknowns | boolean): TRet<PSBTInputs>;
220
244
  /**
221
245
  * Determines how an input should be signed and finalized.
222
246
  * Wrapper consistency is expected to be validated earlier by {@link normalizeInput}
@@ -305,13 +329,21 @@ export declare class Transaction {
305
329
  private outputs;
306
330
  readonly opts: ReturnType<typeof validateOpts>;
307
331
  constructor(opts?: TxOpts);
332
+ private isPSBTv2;
333
+ private requireTxModifiable;
334
+ private txModifiablePolicy;
335
+ private modifiable;
336
+ private get txModifiable();
308
337
  static fromRaw(raw: Bytes, opts?: TxOpts): Transaction;
309
338
  static fromPSBT(psbt_: Bytes, opts?: TxOpts): Transaction;
310
339
  toPSBT(PSBTVersion?: number | undefined): Uint8Array;
311
340
  get lockTime(): number;
312
341
  get version(): number;
313
342
  private inputStatus;
343
+ private cleanFinalInput;
314
344
  private inputSighash;
345
+ private signatures;
346
+ private signedInputKeys;
315
347
  private signStatus;
316
348
  get isFinal(): boolean;
317
349
  get hasWitnesses(): boolean;
@@ -323,6 +355,7 @@ export declare class Transaction {
323
355
  get hash(): string;
324
356
  get id(): string;
325
357
  private checkInputIdx;
358
+ private validatePrevoutsForSigning;
326
359
  getInput(idx: number): psbt.TransactionInput;
327
360
  get inputsLength(): number;
328
361
  addInput(input: TArg<psbt.TransactionInputUpdate>, _ignoreSignStatus?: boolean): number;
@@ -350,6 +383,7 @@ export declare class Transaction {
350
383
  /**
351
384
  * Merges multiple PSBT blobs into one.
352
385
  * @param psbts - PSBT byte arrays to combine
386
+ * @param opts - Transaction parsing, combination, and serialization options. See {@link TxOpts}.
353
387
  * @returns Combined PSBT bytes.
354
388
  * @throws If the PSBT list is empty or the partial transactions cannot be combined. {@link Error}
355
389
  * @example
@@ -360,7 +394,7 @@ export declare class Transaction {
360
394
  * PSBTCombine([psbt, psbt]);
361
395
  * ```
362
396
  */
363
- export declare function PSBTCombine(psbts: TArg<Bytes[]>): TRet<Bytes>;
397
+ export declare function PSBTCombine(psbts: TArg<Bytes[]>, opts?: TArg<TxOpts>): TRet<Bytes>;
364
398
  /**
365
399
  * Parses a BIP32 path string into child indices.
366
400
  * @param path - derivation path such as `m/0'/1`
@@ -374,4 +408,3 @@ export declare function PSBTCombine(psbts: TArg<Bytes[]>): TRet<Bytes>;
374
408
  */
375
409
  export declare function bip32Path(path: string): number[];
376
410
  export {};
377
- //# sourceMappingURL=transaction.d.ts.map