public void GetStakingInfo_StakingEnabled() { using (var dir = TestDirectory.Create()) { IFullNode fullNode = PurpleBitcoinPosRunner.BuildStakingNode(dir.FolderName); var fullNodeRunTask = fullNode.RunAsync(); INodeLifetime nodeLifetime = fullNode.NodeService <INodeLifetime>(); nodeLifetime.ApplicationStarted.WaitHandle.WaitOne(); MiningRPCController controller = fullNode.Services.ServiceProvider.GetService <MiningRPCController>(); Assert.NotNull(fullNode.NodeService <IPosMinting>(true)); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); nodeLifetime.StopApplication(); nodeLifetime.ApplicationStopped.WaitHandle.WaitOne(); fullNode.Dispose(); Assert.False(fullNodeRunTask.IsFaulted); } }
public void GetStakingInfo_StakingEnabled() { string dir = AssureEmptyDir("TestData/GetStakingInfoActionTests/GetStakingInfo_StakingEnabled"); IFullNode fullNode = this.BuildStakingNode(dir); Task.Run(() => { fullNode.Run(); }); INodeLifetime nodeLifetime = fullNode.NodeService <INodeLifetime>(); nodeLifetime.ApplicationStarted.WaitHandle.WaitOne(); MiningRPCController controller = fullNode.Services.ServiceProvider.GetService <MiningRPCController>(); Assert.NotNull(fullNode.NodeService <PosMinting>(true)); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); nodeLifetime.StopApplication(); nodeLifetime.ApplicationStopped.WaitHandle.WaitOne(); fullNode.Dispose(); }
public void CanCall_IsInitialBlockDownload() { string dir = CreateTestDir(this); IFullNode fullNode = this.BuildServicedNode(dir, KnownNetworks.StraxMain); var isIBDProvider = fullNode.NodeService <IInitialBlockDownloadState>(true); var chainState = fullNode.NodeService <IChainState>(true); chainState.ConsensusTip = new ChainedHeader(fullNode.Network.GetGenesis().Header, fullNode.Network.GenesisHash, 0); Assert.NotNull(isIBDProvider); Assert.True(isIBDProvider.IsInitialBlockDownload()); }
/// <summary> /// Creates an RPC client for the specified full node. /// </summary> /// <param name="fullNode">The fill node to create the RPC client for.</param> /// <returns>An RPC client created for the specified full node.</returns> private RPCClient CreateRPCClient(IFullNode fullNode) { var rpcSettings = fullNode.NodeService <RpcSettings>(); System.Net.IPEndPoint nodeEndPoint = rpcSettings.Bind.Where(b => b.Address.ToString() == "127.0.0.1").FirstOrDefault() ?? rpcSettings.Bind[0]; return(new RPCClient($"{rpcSettings.RpcUser}:{rpcSettings.RpcPassword}", new Uri($"http://{nodeEndPoint}"), fullNode.Network)); }
public void CallWithDependencies() { string dir = AssureEmptyDir("TestData/GetInfoActionTests/CallWithDependencies"); IFullNode fullNode = this.BuildServicedNode(dir); FullNodeController controller = fullNode.Services.ServiceProvider.GetService <FullNodeController>(); Assert.NotNull(fullNode.NodeService <INetworkDifficulty>(true)); GetInfoModel info = controller.GetInfo(); uint expectedProtocolVersion = (uint)NodeSettings.Default().ProtocolVersion; var expectedRelayFee = MempoolValidator.MinRelayTxFee.FeePerK.ToUnit(NBitcoin.MoneyUnit.BTC); Assert.NotNull(info); Assert.Equal(0, info.blocks); Assert.NotEqual <uint>(0, info.version); Assert.Equal(expectedProtocolVersion, info.protocolversion); Assert.Equal(0, info.timeoffset); Assert.Equal(0, info.connections); Assert.NotNull(info.proxy); Assert.Equal(0, info.difficulty); Assert.False(info.testnet); Assert.Equal(expectedRelayFee, info.relayfee); Assert.Empty(info.errors); }
public void CallWithDependencies() { string dir = CreateTestDir(this); IFullNode fullNode = this.BuildServicedNode(dir); FullNodeController controller = fullNode.Services.ServiceProvider.GetService <FullNodeController>(); Assert.NotNull(fullNode.NodeService <INetworkDifficulty>(true)); GetInfoModel info = controller.GetInfo(); NodeSettings nodeSettings = NodeSettings.Default(); uint expectedProtocolVersion = (uint)nodeSettings.ProtocolVersion; var expectedRelayFee = nodeSettings.MinRelayTxFeeRate.FeePerK.ToUnit(NBitcoin.MoneyUnit.BTC); Assert.NotNull(info); Assert.Equal(0, info.Blocks); Assert.NotEqual <uint>(0, info.Version); Assert.Equal(expectedProtocolVersion, info.ProtocolVersion); Assert.Equal(0, info.TimeOffset); Assert.Equal(0, info.Connections); Assert.NotNull(info.Proxy); Assert.Equal(0, info.Difficulty); Assert.False(info.Testnet); Assert.Equal(expectedRelayFee, info.RelayFee); Assert.Empty(info.Errors); }
public void GetStakingInfo_StartStaking() { using (var dir = TestDirectory.Create()) { IFullNode fullNode = StratisBitcoinPosRunner.BuildStakingNode(dir.FolderName, false); var node = fullNode as FullNode; var fullNodeRunTask = fullNode.RunAsync(); INodeLifetime nodeLifetime = fullNode.NodeService <INodeLifetime>(); nodeLifetime.ApplicationStarted.WaitHandle.WaitOne(); MiningRPCController controller = fullNode.Services.ServiceProvider.GetService <MiningRPCController>(); WalletManager walletManager = node.NodeService <IWalletManager>() as WalletManager; var password = "******"; // create the wallet var mnemonic = walletManager.CreateWallet(password, "test"); Assert.NotNull(fullNode.NodeService <PosMinting>(true)); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.False(info.Enabled); Assert.False(info.Staking); controller.StartStaking("test", "test"); info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); nodeLifetime.StopApplication(); nodeLifetime.ApplicationStopped.WaitHandle.WaitOne(); fullNode.Dispose(); Assert.False(fullNodeRunTask.IsFaulted); } }
public void GetStakingInfo_StartStaking() { string dir = AssureEmptyDir("TestData/GetStakingInfoActionTests/GetStakingInfo_StartStaking"); IFullNode fullNode = this.BuildStakingNode(dir, false); var node = fullNode as FullNode; Task.Run(() => { fullNode.Run(); }); INodeLifetime nodeLifetime = fullNode.NodeService <INodeLifetime>(); nodeLifetime.ApplicationStarted.WaitHandle.WaitOne(); MiningRPCController controller = fullNode.Services.ServiceProvider.GetService <MiningRPCController>(); WalletManager walletManager = node.NodeService <IWalletManager>() as WalletManager; var password = "******"; // create the wallet var mnemonic = walletManager.CreateWallet(password, "test"); Assert.NotNull(fullNode.NodeService <PosMinting>(true)); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.False(info.Enabled); Assert.False(info.Staking); controller.StartStaking("test", "test"); info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); nodeLifetime.StopApplication(); nodeLifetime.ApplicationStopped.WaitHandle.WaitOne(); fullNode.Dispose(); }
public void CanCall_IsInitialBlockDownload() { string dir = CreateTestDir(this); IFullNode fullNode = this.BuildServicedNode(dir); var isIBDProvider = fullNode.NodeService <IInitialBlockDownloadState>(true); Assert.NotNull(isIBDProvider); Assert.True(isIBDProvider.IsInitialBlockDownload()); }
public void GetStakingInfo_StartStaking() { IFullNode fullNode = StratisBitcoinPosRunner.BuildStakingNode(TestBase.CreateTestDir(this), false); var node = fullNode as FullNode; Task fullNodeRunTask = fullNode.RunAsync(); var nodeLifetime = fullNode.NodeService <INodeLifetime>(); nodeLifetime.ApplicationStarted.WaitHandle.WaitOne(); var controller = fullNode.NodeController <StakingRpcController>(); var walletManager = node.NodeService <IWalletManager>() as WalletManager; string password = "******"; string passphrase = "passphrase"; // create the wallet walletManager.CreateWallet(password, "test", passphrase); Assert.NotNull(fullNode.NodeService <IPosMinting>(true)); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.False(info.Enabled); Assert.False(info.Staking); controller.StartStaking("test", "test"); info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); nodeLifetime.StopApplication(); nodeLifetime.ApplicationStopped.WaitHandle.WaitOne(); fullNode.Dispose(); Assert.False(fullNodeRunTask.IsFaulted); }
public void CanCall_AddNode_AddsNodeToCollection() { string testDirectory = CreateTestDir(this); IFullNode fullNode = this.BuildServicedNode(testDirectory); var controller = fullNode.NodeController <ConnectionManagerRPCController>(); var connectionManager = fullNode.NodeService <IConnectionManager>(); controller.AddNode("0.0.0.0", "add"); Assert.Single(connectionManager.ConnectionSettings.RetrieveAddNodes()); }
public void CanCall_AddNode_AddsNodeToCollection() { string testDirectory = CreateTestDir(this); IFullNode fullNode = this.BuildServicedNode(testDirectory); var controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>(); var connectionManager = fullNode.NodeService <IConnectionManager>(); controller.AddNodeRPC("0.0.0.0", "add"); Assert.Single(connectionManager.ConnectionSettings.AddNode); }
public static void Main(string[] args) { try { var nodeSettings = new NodeSettings(networksSelector: Blockcore.Networks.Xds.Networks.Xds, args: args); IFullNodeBuilder nodeBuilder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseBlockStore() .UsePosConsensus() .UseMempool() .UseColdStakingWallet() .AddPowPosMining() .UseNodeHost() .AddRPC(); var window = new WebWindow("Blockcore"); window.NavigateToString("<h1>Blockcore node loading....</h1> "); WriteResourceToFile("Xds-ui.favicon.ico", "Xds-ui.favicon.ico"); window.SetIconFile("Xds-ui.favicon.ico"); IFullNode node = null; Task nodeTask = null; Task.Run(() => { try { node = nodeBuilder.Build(); nodeTask = node.RunAsync(); } catch (Exception ex) { window.NavigateToString("There was a problem initializing the node. <br> see the log file " + nodeSettings.DataFolder.LogPath + " " + ex.ToString()); return; } window.Title = node.Network.CoinTicker + " Node"; window.NavigateToUrl(node.NodeService <NodeHostSettings>().ApiUri.ToString()); }); window.WaitForExit(); nodeTask.Wait(); } catch (Exception ex) { Console.WriteLine("There was a problem initializing the node. Details: '{0}'", ex.ToString()); } }
public void GetStakingInfo_StakingEnabled() { IFullNode fullNode = StratisBitcoinPosRunner.BuildStakingNode(TestBase.CreateTestDir(this)); Task fullNodeRunTask = fullNode.RunAsync(); var nodeLifetime = fullNode.NodeService <INodeLifetime>(); nodeLifetime.ApplicationStarted.WaitHandle.WaitOne(); var controller = fullNode.NodeController <StakingRpcController>(); Assert.NotNull(fullNode.NodeService <IPosMinting>(true)); GetStakingInfoModel info = controller.GetStakingInfo(); Assert.NotNull(info); Assert.True(info.Enabled); Assert.False(info.Staking); nodeLifetime.StopApplication(); nodeLifetime.ApplicationStopped.WaitHandle.WaitOne(); fullNode.Dispose(); Assert.False(fullNodeRunTask.IsFaulted); }
public DepositExtractor( ILoggerFactory loggerFactory, IFederationGatewaySettings federationGatewaySettings, IOpReturnDataReader opReturnDataReader, IFullNode fullNode) { this.logger = loggerFactory.CreateLogger(this.GetType().FullName); // Note: MultiSigRedeemScript.PaymentScript equals MultiSigAddress.ScriptPubKey this.depositScript = federationGatewaySettings?.MultiSigRedeemScript?.PaymentScript ?? federationGatewaySettings?.MultiSigAddress?.ScriptPubKey; this.opReturnDataReader = opReturnDataReader; this.MinimumDepositConfirmations = federationGatewaySettings.MinimumDepositConfirmations; this.chain = fullNode.NodeService <ConcurrentChain>(); }
public void CanSpecifyStoreSettings() { string dir = CreateTestDir(this); var nodeSettings = new NodeSettings(this.Network, args: new string[] { $"-datadir={dir}" }); IFullNode node1 = FullNodeSetup(nodeSettings); var settings1 = node1.NodeService <StoreSettings>(); Assert.False(settings1.ReIndex); nodeSettings = new NodeSettings(this.Network, args: new string[] { $"-datadir={dir}", "-reindex=1" }); IFullNode node2 = FullNodeSetup(nodeSettings); var settings2 = node2.NodeService <StoreSettings>(); Assert.True(settings2.ReIndex); }
public void CanCall_AddNode_AddsNodeToCollection() { var initialBlockSignature = Block.BlockSignature; try { Block.BlockSignature = false; string testDirectory = CreateTestDir(this); IFullNode fullNode = this.BuildServicedNode(testDirectory); ConnectionManagerController controller = fullNode.Services.ServiceProvider.GetService <ConnectionManagerController>(); var connectionManager = fullNode.NodeService <IConnectionManager>(); controller.AddNode("0.0.0.0", "add"); Assert.Single(connectionManager.ConnectionSettings.AddNode); } finally { Block.BlockSignature = initialBlockSignature; } }
static async Task MainAsync(string[] args) { try { var nodeSettings = GetPatchedNodeSettings(args); var builder = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseBlockStore() .UsePosConsensus() .UseMempool() .UseX1Wallet() .UseX1WalletApi() .UseSecureApiHost(); FullNode = builder.Build(); Init.PrintWelcomeMessage(nodeSettings, FullNode); cancellationTokenSource = Init.RunIfDebugModeDelayed(FullNode); await FullNode.RunAsync(); } catch (Exception e) { var message = $"Critical error in {Init.GetName()}: {e.Message}"; try { FullNode.NodeService <ILoggerFactory>().CreateLogger(typeof(Program).Name).LogCritical(message); } catch (Exception) { Console.WriteLine(message); } } }