Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/1.0.7.2' into SidechainM…
Browse files Browse the repository at this point in the history
…asternode
  • Loading branch information
fassadlr committed Mar 11, 2021
2 parents b5cac38 + a57bf78 commit fe05cdc
Show file tree
Hide file tree
Showing 195 changed files with 2,802 additions and 921 deletions.
8 changes: 8 additions & 0 deletions PushNuget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ rm "src\Stratis.Bitcoin.Features.RPC\bin\Release\" -Recurse -Force
dotnet pack src\Stratis.Bitcoin.Features.RPC --configuration Release --include-source --include-symbols
dotnet nuget push "src\Stratis.Bitcoin.Features.RPC\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json"

rm "src\Stratis.Bitcoin.Features.SmartContracts\bin\Release\" -Recurse -Force
dotnet pack src\Stratis.Bitcoin.Features.SmartContracts --configuration Release --include-source --include-symbols
dotnet nuget push "src\Stratis.Bitcoin.Features.SmartContracts\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json"

rm "src\Stratis.Bitcoin.Features.Wallet\bin\Release\" -Recurse -Force
dotnet pack src\Stratis.Bitcoin.Features.Wallet --configuration Release --include-source --include-symbols
dotnet nuget push "src\Stratis.Bitcoin.Features.Wallet\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json"
Expand All @@ -73,6 +77,10 @@ rm "src\Stratis.Features.SQLiteWalletRepository\bin\Release\" -Recurse -Force
dotnet pack src\Stratis.Features.SQLiteWalletRepository --configuration Release --include-source --include-symbols
dotnet nuget push "src\Stratis.Features.SQLiteWalletRepository\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json"

rm "src\Stratis.Bitcoin.Features.ColdStaking\bin\Release\" -Recurse -Force
dotnet pack src\Stratis.Bitcoin.Features.ColdStaking --configuration Release --include-source --include-symbols
dotnet nuget push "src\Stratis.Bitcoin.Features.ColdStaking\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json"

# TEST PROJECTS

rm "src\Stratis.Bitcoin.Tests.Common\bin\Release\" -Recurse -Force
Expand Down
2 changes: 1 addition & 1 deletion PushSCNuget.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$packageNames = @("Stratis.Sidechains.Networks","Stratis.SmartContracts.CLR", "Stratis.SmartContracts.CLR.Validation", "Stratis.SmartContracts.Core", "Stratis.SmartContracts.Networks","Stratis.SmartContracts.RuntimeObserver", "Stratis.Bitcoin.Features.SmartContracts", "Stratis.SmartContracts.RuntimeObserver")
$packageNames = @("Stratis.Sidechains.Networks","Stratis.SmartContracts.CLR", "Stratis.SmartContracts.CLR.Validation", "Stratis.SmartContracts.Core", "Stratis.SmartContracts.Networks","Stratis.SmartContracts.RuntimeObserver", "Stratis.SmartContracts.Tests.Common")

# A little gross to have to enter src/ and then go back after, but this is where the file is atm
cd "src"
Expand Down
2 changes: 1 addition & 1 deletion src/FederationSetup/FederationSetup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.6.5</Version>
<Version>1.0.7.0</Version>
<Authors>Stratis Group Ltd.</Authors>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/FodyNlogAdapter/FodyNlogAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>FodyNlogAdapter</AssemblyName>
<Version>1.0.6.5</Version>
<Version>1.0.7.0</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Stratis Group Ltd.</Authors>
<PackageId>Stratis.Utils.FodyNlogAdapter</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/NBitcoin.Tests/NetworkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void StraxTestnetIsInitializedCorrectly()
{
Network network = this.straxTest;

Assert.Empty(network.Checkpoints);
Assert.Equal(7, network.Checkpoints.Count);
Assert.Single(network.SeedNodes);

Assert.Equal("StraxTest", network.Name);
Expand Down
2 changes: 1 addition & 1 deletion src/NBitcoin/IStandardScriptsRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface IStandardScriptsRegistry
{
void RegisterStandardScriptTemplate(ScriptTemplate scriptTemplate);

bool IsStandardTransaction(Transaction tx, Network network);
bool IsStandardTransaction(Transaction tx, Network network, int blockHeight = -1, uint256 blockHash = null);

bool AreOutputsStandard(Network network, Transaction tx);

Expand Down
2 changes: 1 addition & 1 deletion src/NBitcoin/NBitcoin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>4.0.0.79</Version>
<Version>4.0.0.80</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/NBitcoin/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public interface IFederations

IFederation GetFederation(byte[] federationId);

IFederation GetFederationAtHeight(byte[] federationId, ulong blockHeight, uint256 blockHash);

IFederation GetOnlyFederation();
}

Expand All @@ -214,6 +216,13 @@ public IFederation GetFederation(byte[] federationId)
return this.federations.TryGetValue(new FederationId(federationId), out IFederation federation) ? federation : null;
}

public IFederation GetFederationAtHeight(byte[] federationId, ulong blockHeight, uint256 blockHash)
{
// TODO: Determine the federation at the given height.

return this.federations.TryGetValue(new FederationId(federationId), out IFederation federation) ? federation : null;
}

// TODO: Deprectate this method when multiple federations are supported.
public IFederation GetOnlyFederation()
{
Expand Down
2 changes: 1 addition & 1 deletion src/NBitcoin/Policy/ITransactionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,6 @@ public interface ITransactionPolicy
/// <param name="transaction">The transaction</param>
/// <param name="spentCoins">The previous coins</param>
/// <returns>Policy errors</returns>
TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins);
TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins, int blockHeight = -1, uint256 blockHash = null);
}
}
2 changes: 1 addition & 1 deletion src/NBitcoin/Policy/MinerTransactionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static MinerTransactionPolicy Instance

#region ITransactionPolicy Members

public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins)
public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins, int blockHeight = -1, uint256 blockHash = null)
{
spentCoins = spentCoins ?? new ICoin[0];
var errors = new List<TransactionPolicyError>();
Expand Down
6 changes: 4 additions & 2 deletions src/NBitcoin/Policy/StandardTransactionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public StandardTransactionPolicy(Network network)
this.CheckScriptPubKey = true;
}

public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins)
public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoins, int blockHeight = -1, uint256 blockHash = null)
{
if (transaction == null)
throw new ArgumentNullException("transaction");
Expand All @@ -78,7 +78,9 @@ public TransactionPolicyError[] Check(Transaction transaction, ICoin[] spentCoin
{
if (this.ScriptVerify != null)
{
if (!input.VerifyScript(this.Network, coin.TxOut.ScriptPubKey, coin.TxOut.Value, this.ScriptVerify.Value, out ScriptError error))
var script = (blockHeight < 0) ? coin.TxOut.ScriptPubKey : new ScriptAtHeight(coin.TxOut.ScriptPubKey, blockHeight, blockHash);

if (!input.VerifyScript(this.Network, script, coin.TxOut.Value, this.ScriptVerify.Value, out ScriptError error))
{
errors.Add(new ScriptPolicyError(input, error, this.ScriptVerify.Value, coin.TxOut.ScriptPubKey));
}
Expand Down
15 changes: 15 additions & 0 deletions src/NBitcoin/ScriptAtHeight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace NBitcoin
{
public class ScriptAtHeight : Script
{
public ScriptAtHeight(Script script, int blockHeight, uint256 blockHash) : base()
{
this._Script = script._Script;
this.BlockHeight = blockHeight;
this.BlockHash = blockHash;
}

public uint256 BlockHash { get; private set; }
public int BlockHeight { get; private set; }
}
}
5 changes: 4 additions & 1 deletion src/NBitcoin/ScriptEvaluationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,10 @@ private bool EvalScript(Script s, TransactionChecker checker, int hashversion)
int sigsReq;
try
{
(members, sigsReq) = this.Network.Federations.GetFederation(federationId).GetFederationDetails();
if (s is ScriptAtHeight sah)
(members, sigsReq) = this.Network.Federations.GetFederationAtHeight(federationId, (ulong)sah.BlockHeight, sah.BlockHash).GetFederationDetails();
else
(members, sigsReq) = this.Network.Federations.GetFederation(federationId).GetFederationDetails();
}
catch (Exception)
{
Expand Down
4 changes: 2 additions & 2 deletions src/NBitcoin/StandardScriptsRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public ScriptTemplate this[Type key]
get => this.GetScriptTemplates.FirstOrDefault(template => template.GetType() == key);
}

public virtual bool IsStandardTransaction(Transaction tx, Network network)
public virtual bool IsStandardTransaction(Transaction tx, Network network, int blockHeight = -1, uint256 blockHash = null)
{
return new StandardTransactionPolicy(network).Check(tx, null).Length == 0;
return new StandardTransactionPolicy(network).Check(tx, null, blockHeight, blockHash).Length == 0;
}

public virtual bool AreOutputsStandard(Network network, Transaction tx)
Expand Down
2 changes: 1 addition & 1 deletion src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.6.5</Version>
<Version>1.0.7.0</Version>
<Authors>Stratis Group Ltd.</Authors>
<Company>Stratis Group Ltd.</Company>
<Product />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>Stratis.Bitcoin.Features.Api</AssemblyName>
<OutputType>Library</OutputType>
<PackageId>Stratis.Features.Api</PackageId>
<Version>1.0.6.5</Version>
<Version>1.0.7.2</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<ApplicationIcon />
<OutputTypeEx>library</OutputTypeEx>
Expand Down
Loading

0 comments on commit fe05cdc

Please sign in to comment.