Skip to content

Commit

Permalink
Final fix for main code
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreb committed Dec 10, 2024
1 parent 6ce1292 commit 9859444
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Angor/Shared/ProtocolNew/Scripts/TaprootScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ private static TaprootSpendInfo BuildTaprootSpendInfo(ProjectScripts scripts)

var scriptWeights = BuildTaprootScripts(scripts);

var treeInfo = TaprootSpendInfo.WithHuffmanTree(taprootKey, scriptWeights.ToArray());
// Transform the scripts to TapScript format
var tapScriptWeights = scriptWeights
.Select(sw => (sw.Item1, sw.Item2.ToTapScript(TapLeafVersion.C0)))
.ToList();

var treeInfo = TaprootSpendInfo.WithHuffmanTree(taprootKey, tapScriptWeights.ToArray());

return treeInfo;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Angor/Shared/ProtocolNew/SeederTransactionActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public Transaction AddSignaturesToRecoverSeederFundsTransaction(ProjectInfo proj

var controlBlock = _taprootScriptBuilder.CreateControlBlock(projectScripts, _ => _.Recover);

var execData = new TaprootExecutionData(stageIndex, new NBitcoin.Script(projectScripts.Recover.ToBytes()).TaprootV1LeafHash) { SigHash = sigHash };
var tapScript = new NBitcoin.Script(projectScripts.Recover.ToBytes()).ToTapScript(TapLeafVersion.C0);

var execData = new TaprootExecutionData(stageIndex, tapScript.LeafHash) { SigHash = sigHash };
var hash = nbitcoinRecoveryTransaction.GetSignatureHashTaproot(outputs, execData);

_logger.LogInformation($"project={projectInfo.ProjectIdentifier}; seeder-pubkey={key.PubKey.ToHex()}; stage={stageIndex}; hash={hash}");
Expand Down

0 comments on commit 9859444

Please sign in to comment.