diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 500b9239..55170988 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,13 +47,13 @@ jobs: shell: bash - name: Publish - run: dotnet publish -c Debug -r ${{matrix.runtime}} /p:Version=${{ env.VERSION }}.${{ github.run_number }} -v m -o publish ${{env.PROJECT_PATH}} + run: dotnet publish -c Release -r ${{matrix.runtime}} /p:Version=${{ env.VERSION }}.${{ github.run_number }} -v m -o publish ${{env.PROJECT_PATH}} env: matrix.runtime: ${{ matrix.os == 'windows-latest' && 'win-x64' || matrix.os == 'ubuntu-latest' && 'linux-x64' || 'osx-x64' }} - name: Run Tests continue-on-error: true - run: dotnet test -c Debug -r ${{matrix.runtime}} --verbosity normal ${{env.SOLUTION_PATH}} + run: dotnet test -c Release -r ${{matrix.runtime}} --verbosity normal ${{env.SOLUTION_PATH}} env: matrix.runtime: ${{ matrix.os == 'windows-latest' && 'win-x64' || matrix.os == 'ubuntu-latest' && 'linux-x64' || 'osx-x64' }} diff --git a/src/Angor.Test/Angor.Test.csproj b/src/Angor.Test/Angor.Test.csproj index c6a9c380..02195e48 100644 --- a/src/Angor.Test/Angor.Test.csproj +++ b/src/Angor.Test/Angor.Test.csproj @@ -22,7 +22,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Angor.Test/DataBuilders/AngorScripts.cs b/src/Angor.Test/DataBuilders/AngorScripts.cs index 98c9b6fa..7df1679e 100644 --- a/src/Angor.Test/DataBuilders/AngorScripts.cs +++ b/src/Angor.Test/DataBuilders/AngorScripts.cs @@ -27,8 +27,7 @@ public static Script CreateControlBlock(ProjectScripts scripts, Expression (sw.Item1, sw.Item2.ToTapScript(TapLeafVersion.C0))) + .ToList(); + + var treeInfo = TaprootSpendInfo.WithHuffmanTree(taprootKey, tapScriptWeights.ToArray()); return treeInfo; } diff --git a/src/Angor.Test/DataBuilders/InvestmentOperations.cs b/src/Angor.Test/DataBuilders/InvestmentOperations.cs index c94f2b1c..3204869d 100644 --- a/src/Angor.Test/DataBuilders/InvestmentOperations.cs +++ b/src/Angor.Test/DataBuilders/InvestmentOperations.cs @@ -204,7 +204,7 @@ public Transaction SpendFounderStage(Network network, FounderContext context, in var allSpendingOutputs = signingContext.Select(s => s.spendingOutput.TxOut).ToArray(); var trxData = spender.PrecomputeTransactionData(allSpendingOutputs); - var execData = new TaprootExecutionData(inputIndex, scriptToExecute.TaprootV1LeafHash) { SigHash = sighash }; + var execData = new TaprootExecutionData(inputIndex, scriptToExecute.ToTapScript(TapLeafVersion.C0).LeafHash) { SigHash = sighash }; var hash = spender.GetSignatureHashTaproot(trxData, execData); var key = new Key(Encoders.Hex.DecodeData(founderPrivateKey)); @@ -287,7 +287,7 @@ public List FounderSignInvestorRecoveryTransactions(InvestorContext cont var hash = stageTransaction.GetSignatureHashTaproot(new[] { investmentTransaction.Outputs[i+2] }, new TaprootExecutionData(0, - new NBitcoin.Script(scriptStages.Recover.ToBytes()).TaprootV1LeafHash) + new NBitcoin.Script(scriptStages.Recover.ToBytes()).ToTapScript(TapLeafVersion.C0).LeafHash) { SigHash = sigHash }); @@ -329,7 +329,7 @@ public void AddWitScriptToInvestorRecoveryTransactions(InvestorContext context, var hash = stageTransaction.GetSignatureHashTaproot(new[] { investmentTransaction.Outputs[index + 2] }, new TaprootExecutionData(0, - new NBitcoin.Script(projectScripts.Recover.ToBytes()).TaprootV1LeafHash) + new NBitcoin.Script(projectScripts.Recover.ToBytes()).ToTapScript(TapLeafVersion.C0).LeafHash) { SigHash = sigHash }); var investorSignature = key.SignTaprootKeySpend(hash, sigHash); @@ -446,7 +446,7 @@ public Transaction RecoverEndOfProjectFunds(Network network, InvestorContext con var allSpendingOutputs = signingContext.Select(s => s.spendingOutput.TxOut).ToArray(); var trxData = spender.PrecomputeTransactionData(allSpendingOutputs); - var execData = new TaprootExecutionData(inputIndex, scriptToExecute.TaprootV1LeafHash) { SigHash = sighash }; + var execData = new TaprootExecutionData(inputIndex, scriptToExecute.ToTapScript(TapLeafVersion.C0).LeafHash) { SigHash = sighash }; var hash = spender.GetSignatureHashTaproot(trxData, execData); var key = new Key(Encoders.Hex.DecodeData(investorPrivateKey)); @@ -566,7 +566,7 @@ public Transaction RecoverFundsNoPenalty(Network network, InvestorContext contex var allSpendingOutputs = signingContext.Select(s => s.spendingOutput.TxOut).ToArray(); var trxData = spender.PrecomputeTransactionData(allSpendingOutputs); - var execData = new TaprootExecutionData(inputIndex, scriptToExecute.TaprootV1LeafHash) { SigHash = sighash }; + var execData = new TaprootExecutionData(inputIndex, scriptToExecute.ToTapScript(TapLeafVersion.C0).LeafHash) { SigHash = sighash }; var hash = spender.GetSignatureHashTaproot(trxData, execData); var key = new Key(Encoders.Hex.DecodeData(investorPrivateKey)); diff --git a/src/Angor/Client/Angor.Client.csproj b/src/Angor/Client/Angor.Client.csproj index fa6ed8c1..3497b235 100644 --- a/src/Angor/Client/Angor.Client.csproj +++ b/src/Angor/Client/Angor.Client.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Angor/Shared/Angor.Shared.csproj b/src/Angor/Shared/Angor.Shared.csproj index 59b5ccde..1f948dbd 100644 --- a/src/Angor/Shared/Angor.Shared.csproj +++ b/src/Angor/Shared/Angor.Shared.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs b/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs index 25e63d92..0bf7c039 100644 --- a/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs +++ b/src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs @@ -62,7 +62,9 @@ public SignatureInfo SignInvestorRecoveryTransactions(ProjectInfo projectInfo, s { var scriptStages = _investmentScriptBuilder.BuildProjectScriptsForStage(projectInfo, investorKey, stageIndex, secretHash); - var execData = new TaprootExecutionData(stageIndex, new NBitcoin.Script(scriptStages.Recover.ToBytes()).TaprootV1LeafHash) { SigHash = sigHash }; + var tapScript = new NBitcoin.Script(scriptStages.Recover.ToBytes()).ToTapScript(TapLeafVersion.C0); + + var execData = new TaprootExecutionData(stageIndex, tapScript.LeafHash) { SigHash = sigHash }; var hash = nbitcoinRecoveryTransaction.GetSignatureHashTaproot(outputs, execData); var sig = key.SignTaprootKeySpend(hash, sigHash).ToString(); @@ -123,8 +125,10 @@ public TransactionInfo SpendFounderStage(ProjectInfo projectInfo, IEnumerable _.Recover); - var execData = new TaprootExecutionData(stageIndex, new NBitcoin.Script(scriptStages.Recover.ToBytes()).TaprootV1LeafHash) { SigHash = sigHash }; + var tapScript = new NBitcoin.Script(scriptStages.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}; investor-pubkey={key.PubKey.ToHex()}; stage={stageIndex}; hash={hash}"); @@ -290,7 +292,9 @@ public bool CheckInvestorRecoverySignatures(ProjectInfo projectInfo, Transaction { var scriptStages = _investmentScriptBuilder.BuildProjectScriptsForStage(projectInfo, investorKey, stageIndex, secretHash); - var execData = new TaprootExecutionData(stageIndex, new NBitcoin.Script(scriptStages.Recover.ToBytes()).TaprootV1LeafHash) { SigHash = sigHash }; + var tapScript = new NBitcoin.Script(scriptStages.Recover.ToBytes()).ToTapScript(TapLeafVersion.C0); + + var execData = new TaprootExecutionData(stageIndex, tapScript.LeafHash) { SigHash = sigHash }; var hash = nBitcoinRecoveryTransaction.GetSignatureHashTaproot(outputs, execData); var sig = founderSignatures.Signatures.First(f => f.StageIndex == stageIndex).Signature; diff --git a/src/Angor/Shared/ProtocolNew/Scripts/TaprootScriptBuilder.cs b/src/Angor/Shared/ProtocolNew/Scripts/TaprootScriptBuilder.cs index 4365cf29..a820c479 100644 --- a/src/Angor/Shared/ProtocolNew/Scripts/TaprootScriptBuilder.cs +++ b/src/Angor/Shared/ProtocolNew/Scripts/TaprootScriptBuilder.cs @@ -25,8 +25,7 @@ public Script CreateControlBlock(ProjectScripts scripts, Expression (sw.Item1, sw.Item2.ToTapScript(TapLeafVersion.C0))) + .ToList(); + + var treeInfo = TaprootSpendInfo.WithHuffmanTree(taprootKey, tapScriptWeights.ToArray()); return treeInfo; } diff --git a/src/Angor/Shared/ProtocolNew/SeederTransactionActions.cs b/src/Angor/Shared/ProtocolNew/SeederTransactionActions.cs index 54854f01..63080df8 100644 --- a/src/Angor/Shared/ProtocolNew/SeederTransactionActions.cs +++ b/src/Angor/Shared/ProtocolNew/SeederTransactionActions.cs @@ -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}"); diff --git a/src/Angor/Shared/ProtocolNew/TransactionBuilders/SpendingTransactionBuilder.cs b/src/Angor/Shared/ProtocolNew/TransactionBuilders/SpendingTransactionBuilder.cs index a68ce9d8..6f975b17 100644 --- a/src/Angor/Shared/ProtocolNew/TransactionBuilders/SpendingTransactionBuilder.cs +++ b/src/Angor/Shared/ProtocolNew/TransactionBuilders/SpendingTransactionBuilder.cs @@ -77,7 +77,7 @@ public TransactionInfo BuildRecoverInvestorRemainingFundsInProject(string invest input.WitScript[input.WitScript.PushCount - 2]); //control block is the last and execute one before it var hash = spendingTrx.GetSignatureHashTaproot(trxData, - new TaprootExecutionData(inputIndex, scriptToExecute.TaprootV1LeafHash) { SigHash = sigHash }); + new TaprootExecutionData(inputIndex, scriptToExecute.ToTapScript(TapLeafVersion.C0).LeafHash) { SigHash = sigHash }); var sig = key.SignTaprootKeySpend(hash, sigHash);