@bitcoinerlab/descriptors 2.3.5 → 2.3.6
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/dist/applyPR2137.js +10 -0
- package/dist/signers.js +9 -4
- package/package.json +1 -1
package/dist/applyPR2137.js
CHANGED
|
@@ -55,6 +55,16 @@ function getTweakSignersFromHD(inputIndex, inputs, hdKeyPair) {
|
|
|
55
55
|
if (!bipDv.pubkey.equals(toXOnly(node.publicKey))) {
|
|
56
56
|
throw new Error('pubkey did not match tapBip32Derivation');
|
|
57
57
|
}
|
|
58
|
+
//FIX BITCOINERLAB:
|
|
59
|
+
//The 3 lines below detect script-path spends and disable key-path tweaking.
|
|
60
|
+
//Reasoning:
|
|
61
|
+
//- In Taproot, key-path spends require tweaking the internal key.
|
|
62
|
+
//- Script-path spends MUST NOT tweak the key; signatures use the raw internal key.
|
|
63
|
+
const input = inputs[inputIndex];
|
|
64
|
+
if (!input)
|
|
65
|
+
throw new Error('could not find the input');
|
|
66
|
+
if (input.tapLeafScript && input.tapLeafScript.length > 0)
|
|
67
|
+
return node;
|
|
58
68
|
const h = calculateScriptTreeMerkleRoot(bipDv.leafHashes);
|
|
59
69
|
const tweakValue = (0, bip341_1.tapTweakHash)(toXOnly(node.publicKey), h);
|
|
60
70
|
return node.tweak(tweakValue);
|
package/dist/signers.js
CHANGED
|
@@ -34,15 +34,20 @@ function range(n) {
|
|
|
34
34
|
*/
|
|
35
35
|
function signInputECPair({ psbt, index, ecpair }) {
|
|
36
36
|
//psbt.signInput(index, ecpair); <- Replaced for the code below
|
|
37
|
-
//that can handle
|
|
37
|
+
//that can handle taproot inputs automatically.
|
|
38
38
|
//See https://github.com/bitcoinjs/bitcoinjs-lib/pull/2137#issuecomment-2713264848
|
|
39
39
|
const input = psbt.data.inputs[index];
|
|
40
40
|
if (!input)
|
|
41
41
|
throw new Error('Invalid index');
|
|
42
42
|
if ((0, bip371_1.isTaprootInput)(input)) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
// If script-path (tapLeafScript present) -> DO NOT TWEAK
|
|
44
|
+
if (input.tapLeafScript && input.tapLeafScript.length > 0)
|
|
45
|
+
psbt.signInput(index, ecpair);
|
|
46
|
+
else {
|
|
47
|
+
const hash = (0, bip341_1.tapTweakHash)(Buffer.from(ecpair.publicKey.slice(1, 33)), undefined);
|
|
48
|
+
const tweakedEcpair = ecpair.tweak(hash);
|
|
49
|
+
psbt.signInput(index, tweakedEcpair);
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
52
|
else
|
|
48
53
|
psbt.signInput(index, ecpair);
|
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.3.
|
|
5
|
+
"version": "2.3.6",
|
|
6
6
|
"author": "Jose-Luis Landabaso",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|