@bitcoinerlab/descriptors 2.0.1 → 2.0.3
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 +2 -2
- package/dist/descriptors.d.ts +25 -13
- package/dist/descriptors.js +22 -1
- package/dist/types.d.ts +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,11 +73,11 @@ const wpkhOutput = new Output({
|
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
For miniscript-based descriptors, the `signersPubKeys` parameter in the constuctor becomes particularly important. It specifies the spending path of a previous output with multiple spending paths. Detailed information about the constructor parameters, including `signersPubKeys`, can be found in [the API documentation](https://bitcoinerlab.com/modules/descriptors/api/classes/_Internal_.Output.html#constructor) and in [this Stack Exchange answer](https://bitcoin.stackexchange.com/a/118036/89665).
|
|
77
77
|
|
|
78
78
|
The `Output` class [offers various helpful methods](https://bitcoinerlab.com/modules/descriptors/api/classes/_Internal_.Output.html), including `getAddress()`, which returns the address associated with the descriptor, `getScriptPubKey()`, which returns the `scriptPubKey` for the descriptor, `expand()`, which decomposes a descriptor into its elemental parts, `updatePsbtAsInput()` and `updatePsbtAsOutput()`.
|
|
79
79
|
|
|
80
|
-
The `updatePsbtAsInput()` method is an essential part of the library, responsible for adding an input to the PSBT corresponding to the UTXO described by the descriptor. Additionally, when the descriptor expresses an absolute time-spending condition, such as "This UTXO can only be spent after block N,
|
|
80
|
+
The `updatePsbtAsInput()` method is an essential part of the library, responsible for adding an input to the PSBT corresponding to the UTXO described by the descriptor. Additionally, when the descriptor expresses an absolute time-spending condition, such as "This UTXO can only be spent after block N", `updatePsbtAsInput()` adds timelock information to the PSBT.
|
|
81
81
|
|
|
82
82
|
To call `updatePsbtAsInput()`, use the following syntax:
|
|
83
83
|
|
package/dist/descriptors.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export declare function DescriptorsFactory(ecc: TinySecp256k1Interface): {
|
|
|
90
90
|
* Important: As mentioned above, note that this function only applies to
|
|
91
91
|
* miniscript descriptors.
|
|
92
92
|
*/
|
|
93
|
-
getScriptSatisfaction(signatures: PartialSig[]): Buffer;
|
|
93
|
+
getScriptSatisfaction(signatures: PartialSig[] | 'DANGEROUSLY_USE_FAKE_SIGNATURES'): Buffer;
|
|
94
94
|
/**
|
|
95
95
|
* Gets the nSequence required to fulfill this `Output`.
|
|
96
96
|
*/
|
|
@@ -257,22 +257,34 @@ export declare function DescriptorsFactory(ecc: TinySecp256k1Interface): {
|
|
|
257
257
|
*/
|
|
258
258
|
network?: Network;
|
|
259
259
|
/**
|
|
260
|
-
* An array of preimages
|
|
260
|
+
* An array of preimages if the miniscript-based descriptor uses them.
|
|
261
|
+
*
|
|
262
|
+
* This info is necessary to finalize Psbts. Leave it `undefined` if your
|
|
263
|
+
* miniscript-based descriptor does not use preimages or you don't know
|
|
264
|
+
* or don't wanto use them.
|
|
265
|
+
*
|
|
266
|
+
* You can also leave it `undefined` if only need to generate the
|
|
267
|
+
* `scriptPubKey` or `address` for a descriptor.
|
|
268
|
+
*
|
|
261
269
|
* @defaultValue `[]`
|
|
262
270
|
*/
|
|
263
271
|
preimages?: Preimage[];
|
|
264
272
|
/**
|
|
265
273
|
* An array of the public keys used for signing the transaction when
|
|
266
|
-
* spending the output associated with this descriptor.
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
274
|
+
* spending the previous output associated with this descriptor.
|
|
275
|
+
*
|
|
276
|
+
* This parameter is only used if the descriptor object is being used to
|
|
277
|
+
* finalize a transaction. It is necessary to specify the spending path
|
|
278
|
+
* when working with miniscript-based expressions that have multiple
|
|
279
|
+
* spending paths.
|
|
280
|
+
*
|
|
281
|
+
* Set this parameter to an array containing the public
|
|
282
|
+
* keys involved in the desired spending path. Leave it `undefined` if you
|
|
283
|
+
* only need to generate the `scriptPubKey` or `address` for a descriptor,
|
|
284
|
+
* or if all the public keys involved in the descriptor will sign the
|
|
285
|
+
* transaction. In the latter case, the satisfier will automatically
|
|
286
|
+
* choose the most optimal spending path (if more than one is available).
|
|
287
|
+
*
|
|
276
288
|
* For more details on using this parameter, refer to [this Stack Exchange
|
|
277
289
|
* answer](https://bitcoin.stackexchange.com/a/118036/89665).
|
|
278
290
|
*/
|
|
@@ -328,7 +340,7 @@ export declare function DescriptorsFactory(ecc: TinySecp256k1Interface): {
|
|
|
328
340
|
* Important: As mentioned above, note that this function only applies to
|
|
329
341
|
* miniscript descriptors.
|
|
330
342
|
*/
|
|
331
|
-
getScriptSatisfaction(signatures: PartialSig[]): Buffer;
|
|
343
|
+
getScriptSatisfaction(signatures: PartialSig[] | 'DANGEROUSLY_USE_FAKE_SIGNATURES'): Buffer;
|
|
332
344
|
/**
|
|
333
345
|
* Gets the nSequence required to fulfill this `Output`.
|
|
334
346
|
*/
|
package/dist/descriptors.js
CHANGED
|
@@ -522,8 +522,28 @@ function DescriptorsFactory(ecc) {
|
|
|
522
522
|
*
|
|
523
523
|
* `signatures` must be passed using this format (pairs of `pubKey/signature`):
|
|
524
524
|
* `interface PartialSig { pubkey: Buffer; signature: Buffer; }`
|
|
525
|
+
*
|
|
526
|
+
* * Alternatively, if you do not have the signatures, you can use the option
|
|
527
|
+
* `'DANGEROUSLY_USE_FAKE_SIGNATURES'`. This will generate script satisfactions
|
|
528
|
+
* using 72-byte zero-padded signatures. While this can be useful in
|
|
529
|
+
* modules like coinselector that require estimating transaction size before
|
|
530
|
+
* signing, it is critical to understand the risks:
|
|
531
|
+
* - Using this option generales invalid unlocking scripts.
|
|
532
|
+
* - It should NEVER be used with real transactions.
|
|
533
|
+
* - Its primary use is for testing and size estimation purposes only.
|
|
534
|
+
*
|
|
535
|
+
* ⚠️ Warning: Misuse of 'DANGEROUSLY_USE_FAKE_SIGNATURES' can lead to security
|
|
536
|
+
* vulnerabilities, including but not limited to invalid transaction generation.
|
|
537
|
+
* Ensure you fully understand the implications before use.
|
|
538
|
+
*
|
|
525
539
|
*/
|
|
526
540
|
signatures) {
|
|
541
|
+
if (signatures === 'DANGEROUSLY_USE_FAKE_SIGNATURES')
|
|
542
|
+
signatures = __classPrivateFieldGet(this, _Output_signersPubKeys, "f").map(pubkey => ({
|
|
543
|
+
pubkey,
|
|
544
|
+
// https://transactionfee.info/charts/bitcoin-script-ecdsa-length/
|
|
545
|
+
signature: Buffer.alloc(72, 0)
|
|
546
|
+
}));
|
|
527
547
|
const miniscript = __classPrivateFieldGet(this, _Output_miniscript, "f");
|
|
528
548
|
const expandedMiniscript = __classPrivateFieldGet(this, _Output_expandedMiniscript, "f");
|
|
529
549
|
const expansionMap = __classPrivateFieldGet(this, _Output_expansionMap, "f");
|
|
@@ -750,7 +770,8 @@ function DescriptorsFactory(ecc) {
|
|
|
750
770
|
//signatures don't matter
|
|
751
771
|
const fakeSignatures = signersPubKeys.map(pubkey => ({
|
|
752
772
|
pubkey,
|
|
753
|
-
|
|
773
|
+
// https://transactionfee.info/charts/bitcoin-script-ecdsa-length/
|
|
774
|
+
signature: Buffer.alloc(72, 0)
|
|
754
775
|
}));
|
|
755
776
|
const { nLockTime, nSequence } = (0, miniscript_1.satisfyMiniscript)({
|
|
756
777
|
expandedMiniscript,
|
package/dist/types.d.ts
CHANGED
|
@@ -9,13 +9,15 @@ import type { Payment, Network } from 'bitcoinjs-lib';
|
|
|
9
9
|
*/
|
|
10
10
|
export type Preimage = {
|
|
11
11
|
/**
|
|
12
|
-
* Use same expressions as in miniscript. For example: "sha256(cdabb7f2dce7bfbd8a0b9570c6fd1e712e5d64045e9d6b517b3d5072251dc204)" or "ripemd160(095ff41131e5946f3c85f79e44adbcf8e27e080e)"
|
|
12
|
+
* Use same string expressions as in miniscript. For example: "sha256(cdabb7f2dce7bfbd8a0b9570c6fd1e712e5d64045e9d6b517b3d5072251dc204)" or "ripemd160(095ff41131e5946f3c85f79e44adbcf8e27e080e)"
|
|
13
|
+
*
|
|
13
14
|
* Accepted functions: sha256, hash256, ripemd160, hash160
|
|
15
|
+
*
|
|
14
16
|
* Digests must be: 64-character HEX for sha256, hash160 or 30-character HEX for ripemd160 or hash160.
|
|
15
17
|
*/
|
|
16
18
|
digest: string;
|
|
17
19
|
/**
|
|
18
|
-
* Hex encoded
|
|
20
|
+
* Hex encoded preimage. Preimages are always 32 bytes (so, 64 character in hex).
|
|
19
21
|
*/
|
|
20
22
|
preimage: string;
|
|
21
23
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@bitcoinerlab/descriptors",
|
|
3
3
|
"description": "This library parses and creates Bitcoin Miniscript Descriptors and generates Partially Signed Bitcoin Transactions (PSBTs). It provides PSBT finalizers and signers for single-signature, BIP32 and Hardware Wallets.",
|
|
4
4
|
"homepage": "https://github.com/bitcoinerlab/descriptors",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.3",
|
|
6
6
|
"author": "Jose-Luis Landabaso",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|