tbc-lib-js
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -264,5 +264,3 @@ const secp256k1 = require("secp256k1"); | ||
if (leftHash.compare(rightHash) > 0) { | ||
const temp = leftHash; | ||
leftHash = rightHash; | ||
rightHash = temp; | ||
[leftHash, rightHash] = [rightHash, leftHash]; // Swap hashes if needed | ||
} | ||
@@ -275,3 +273,4 @@ | ||
return [combinedTree, branchHash]; | ||
} else { | ||
} else if (Array.isArray(scriptTree) && scriptTree.length === 2) { | ||
// Ensure that the leaf node is also an array with two elements | ||
const [leafVersion, script] = scriptTree; | ||
@@ -284,6 +283,8 @@ const scriptBuffer = Taproot.serScript(script); | ||
return [[[(leafVersion, script), Buffer.alloc(0)]], leafHash]; | ||
// Return a tuple of tree and hash | ||
return [[[leafVersion, script], Buffer.alloc(0)], leafHash]; | ||
} else { | ||
throw new Error("Invalid scriptTree format"); | ||
} | ||
} | ||
/** | ||
@@ -391,6 +392,4 @@ * | ||
*/ | ||
static pubkeyToTaprootTweakPubkey(pubkey, scriptTree) { | ||
let h; | ||
if (scriptTree === null) h = ""; | ||
else h = Taproot.taprootTreeHelper(scriptTree); | ||
static pubkeyToTaprootTweakPubkey(pubkey) { | ||
let h = ""; | ||
return Taproot.taprootTweakPubkey(pubkey, Buffer.from(h, "ascii")); | ||
@@ -405,6 +404,4 @@ } | ||
*/ | ||
static seckeyToTaprootTweakSeckey(seckey, scriptTree) { | ||
let h; | ||
if (scriptTree === null) h = ""; | ||
else h = Taproot.taprootTreeHelper(scriptTree); | ||
static seckeyToTaprootTweakSeckey(seckey) { | ||
let h = ""; | ||
return Taproot.taprootTweakSeckey(seckey, Buffer.from(h, "ascii")); | ||
@@ -426,3 +423,6 @@ } | ||
const t = Taproot.intFromBuffer( | ||
Taproot.taggedHash("TapTweak", Buffer.concat([Taproot.bufferFromInt(p.x), h])) | ||
Taproot.taggedHash( | ||
"TapTweak", | ||
Buffer.concat([Taproot.bufferFromInt(p.x), h]) | ||
) | ||
); | ||
@@ -429,0 +429,0 @@ if (t >= N) throw Error("value error !"); |
{ | ||
"name": "tbc-lib-js", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "A library for tbc functionality", | ||
@@ -5,0 +5,0 @@ "author": "Austin <austinwang149@gmail.com>", |
1115594
24988