@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/README.md +196 -37
- package/index.d.ts +4 -4
- package/index.js +3 -4
- package/musig2.d.ts +28 -9
- package/musig2.js +46 -18
- package/net.d.ts +355 -0
- package/net.js +880 -0
- package/p2p.d.ts +0 -1
- package/p2p.js +23 -7
- package/package.json +18 -21
- package/payment.d.ts +18 -11
- package/payment.js +203 -58
- package/psbt.d.ts +680 -10
- package/psbt.js +204 -43
- package/script.d.ts +1 -2
- package/script.js +71 -59
- package/src/_type_test.ts +83 -0
- package/src/index.ts +4 -2
- package/src/musig2.ts +71 -19
- package/src/net.ts +1111 -0
- package/src/p2p.ts +22 -6
- package/src/payment.ts +233 -70
- package/src/psbt.ts +228 -39
- package/src/script.ts +57 -35
- package/src/transaction.ts +869 -168
- package/src/utils.ts +92 -4
- package/src/utxo.ts +223 -113
- package/transaction.d.ts +40 -7
- package/transaction.js +745 -151
- package/utils.d.ts +45 -2
- package/utils.js +80 -5
- package/utxo.d.ts +192 -2
- package/utxo.js +200 -99
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/musig2.d.ts.map +0 -1
- package/musig2.js.map +0 -1
- package/p2p.d.ts.map +0 -1
- package/p2p.js.map +0 -1
- package/payment.d.ts.map +0 -1
- package/payment.js.map +0 -1
- package/psbt.d.ts.map +0 -1
- package/psbt.js.map +0 -1
- package/script.d.ts.map +0 -1
- package/script.js.map +0 -1
- package/transaction.d.ts.map +0 -1
- package/transaction.js.map +0 -1
- package/utils.d.ts.map +0 -1
- package/utils.js.map +0 -1
- package/utxo.d.ts.map +0 -1
- package/utxo.js.map +0 -1
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
|
|
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
|
-
/**
|
|
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
|
|
204
|
-
* @param
|
|
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,
|
|
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
|