public async Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) { Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <MoneroPoolPaymentProcessingConfigExtra>(); logger = LogUtil.GetPoolScopedLogger(typeof(MoneroPayoutHandler), poolConfig); // configure standard daemon var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); var daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) .ToArray(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints, MoneroConstants.DaemonRpcLocation); // configure wallet daemon var walletDaemonEndpoints = poolConfig.Daemons .Where(x => x.Category?.ToLower() == MoneroConstants.WalletDaemonCategory) .ToArray(); walletDaemon = new DaemonClient(jsonSerializerSettings); walletDaemon.Configure(walletDaemonEndpoints, MoneroConstants.DaemonRpcLocation); // detect transfer_split support var response = await walletDaemon.ExecuteCmdSingleAsync <TransferResponse>(MWC.TransferSplit); walletSupportsTransferSplit = response.Error.Code != MoneroConstants.MoneroRpcMethodNotFound; }
internal ServiceResponse <TransferModel> GetTransferRequestForSymbol(string symbol) { Func <TransferModel> func = delegate { string btcAddress = "17QnVor1B6oK1rWnVVBrdX9gFzVkZZbhDm"; DaemonClient coinClient = _daemonClientFactory.GetDaemonClient(CoinType.BTC); if (null != coinClient) { var daemonResponse = coinClient.ExecuteCmdSingleAsync <string>(BlockchainConstants.BitcoinCommands.GetNewAddress, null, _jsonSerializerSettings).Result; if (null == daemonResponse.Error) { btcAddress = daemonResponse.Response; } else { _logger.Error($"Daemon returned error: {daemonResponse.Error.Message} code {daemonResponse.Error.Code}"); } } TransferModel response = new TransferModel(); response.FromAddress = btcAddress; if (null != _contextHolder.ExchangeRate) { response.ExchangeRate = _contextHolder.ExchangeRate.Bid; } return(response); }; return(this.Execute(func)); }
protected override void ConfigureDaemons() { var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); daemon.Configure(daemonEndpoints); }
public void Configure(ClusterConfig clusterConfig, PoolConfig poolConfig) { Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <MoneroPoolPaymentProcessingConfigExtra>(); logger = LogUtil.GetPoolScopedLogger(typeof(MoneroPayoutHandler), poolConfig); // configure standard daemon var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); var daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) .ToArray(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints, MoneroConstants.DaemonRpcLocation); // configure wallet daemon var walletDaemonEndpoints = poolConfig.Daemons .Where(x => x.Category?.ToLower() == MoneroConstants.WalletDaemonCategory) .ToArray(); walletDaemon = new DaemonClient(jsonSerializerSettings); walletDaemon.Configure(walletDaemonEndpoints, MoneroConstants.DaemonRpcLocation); }
private void UpdateTransferRequestStatus(TransferRequest request, DaemonClient daemonClient, DateTime timeStamp) { if (null != daemonClient) { object[] args = new object[] { request.FromAddress, // address (request.Status == (int)TransferStatus.Unknown)? 0: request.ConfirmationRequired // minconf }; var balanceResult = daemonClient.ExecuteCmdSingleAsync <object>(BlockchainConstants.BitcoinCommands.GetReceivedByAddress, args, _jsonSerializerSettings).Result; if (null == balanceResult.Error) { decimal amount = (decimal)(double)balanceResult.Response; if (request.Status == (int)TransferStatus.Unknown && amount > 0) { request.Amount = amount; request.Status = (int)TransferStatus.Pending; request.ConfirmationRequired = CalculateConfirmationRequired(amount); request.Updated = timeStamp; } else if (request.Status == (int)TransferStatus.Pending && amount > 0) { request.Status = (int)TransferStatus.Confirmed; request.Updated = timeStamp; } } else { _logger.Error($"Daemon returned error: {balanceResult.Error.Message} code {balanceResult.Error.Code}"); } } }
public override async Task Initialize() { _logger.Information($"initializing pool.."); try { PoolContext = new MoneroPoolContext(); var miningDaemon = new DaemonClient("127.0.0.1", 28081, "user", "pass", MoneroConstants.DaemonRpcLocation); var wallDaemon = new DaemonClient("127.0.0.1", 28085, "user", "pass", MoneroConstants.DaemonRpcLocation); var jobManager = new MoneroJobManager(); var stratumServer = ServerFactory.GetStratumServer(); ((MoneroPoolContext)PoolContext).Configure(miningDaemon, wallDaemon, jobManager, stratumServer); // configure the pool context. PoolContext.JobManager.Configure(PoolContext); await RunPreInitChecksAsync(); // any pre-init checks. PoolContext.Daemon.Initialize(); // initialize mining daemon. ((MoneroPoolContext)PoolContext).WalletDaemon.Initialize(); // initialize wallet daemon. await WaitDaemonConnection(); // wait for coin daemon connection. await EnsureDaemonSynchedAsync(); // ensure the coin daemon is synced to network. await RunPostInitChecksAsync(); // run any post init checks required by the blockchain. } catch (Exception ex) { _logger.Fatal(ex.Message); } }
protected override void ConfigureDaemons() { var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints); }
private static void SafeLockWallet(DaemonClient daemonClient, bool didUnlockWallet) { if (didUnlockWallet) { // lock wallet _logger.Info("Locking wallet"); var walletLockResponse = daemonClient.ExecuteCmdSingleAsync <JToken>(BlockchainConstants.BitcoinCommands.WalletLock).Result; } }
protected override void ConfigureDaemons() { var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); _daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); _daemon.Configure(poolConfig.Daemons); _wallet = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); _wallet.Configure(_extraPoolConfig.Wallets); }
public async Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) { Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <CryptonotePoolPaymentProcessingConfigExtra>(); logger = LogUtil.GetPoolScopedLogger(typeof(CryptonotePayoutHandler), poolConfig); // configure standard daemon var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); var daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) .Select(x => { if (string.IsNullOrEmpty(x.HttpPath)) { x.HttpPath = CryptonoteConstants.DaemonRpcLocation; } return(x); }) .ToArray(); daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); daemon.Configure(daemonEndpoints); // configure wallet daemon var walletDaemonEndpoints = poolConfig.Daemons .Where(x => x.Category?.ToLower() == CryptonoteConstants.WalletDaemonCategory) .Select(x => { if (string.IsNullOrEmpty(x.HttpPath)) { x.HttpPath = CryptonoteConstants.DaemonRpcLocation; } return(x); }) .ToArray(); walletDaemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); walletDaemon.Configure(walletDaemonEndpoints); // detect network await GetNetworkTypeAsync(); // detect transfer_split support var response = await walletDaemon.ExecuteCmdSingleAsync <TransferResponse>(logger, CryptonoteWalletCommands.TransferSplit); walletSupportsTransferSplit = response.Error.Code != CryptonoteConstants.MoneroRpcMethodNotFound; }
public void Execute(DaemonClient client, string commandLine) { string name = commandLine.Substring(Command.Length + 1); Repository db = client.Daemon.OpenRepository(name); if (db == null) return; bool on = Enabled; if (Overridable) on = db.Config.getBoolean("daemon", Config, on); if (on) Execute(client, db); }
protected override void ConfigureDaemons() { var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints, MoneroConstants.DaemonRpcLocation); // also setup wallet daemon walletDaemon = new DaemonClient(jsonSerializerSettings); walletDaemon.Configure(walletDaemonEndpoints, MoneroConstants.DaemonRpcLocation); }
public void Configure(ClusterConfig clusterConfig, PoolConfig poolConfig) { Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; logger = LogUtil.GetPoolScopedLogger(typeof(BitcoinPayoutHandler), poolConfig); var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(poolConfig.Daemons); }
protected override void ConfigureDaemons() { var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); daemon.Configure(daemonEndpoints); if (clusterConfig.PaymentProcessing?.Enabled == true && poolConfig.PaymentProcessing?.Enabled == true) { // also setup wallet daemon walletDaemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); walletDaemon.Configure(walletDaemonEndpoints); } }
protected override void ConfigureDaemons() { var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints, MoneroConstants.DaemonRpcLocation); if (clusterConfig.PaymentProcessing?.Enabled == true && poolConfig.PaymentProcessing?.Enabled == true) { // also setup wallet daemon walletDaemon = new DaemonClient(jsonSerializerSettings); walletDaemon.Configure(walletDaemonEndpoints, MoneroConstants.DaemonRpcLocation); } }
public void OpenDaemon(CommandProcess process, string target) { Session activeSession = GetClient(process).activeSession; foreach (Daemon daemon in activeSession.connectedNode.daemons) { if (daemon.IsOfType(target)) { DaemonClient daemonClient = daemon.CreateClient(activeSession, process); StartProcess(process, daemonClient); daemon.OnConnect(activeSession, daemonClient); GetClient(process).activeSession.AttachProcess(daemonClient); } } }
public override void OnConnect(Session connectSession, DaemonClient client) { base.OnConnect(connectSession, client); connectSession.owner.Send(PacketType.MESSG, "Connected to IRC Service"); connectSession.owner.Send(PacketType.KERNL, "state", "irc", "join"); var commandData = new List <string>() { "state", "irc", "messg" }; foreach (IrcMessage message in messages) { commandData.AddRange(new string[] { message.author, message.content }); } connectSession.owner.Send(PacketType.KERNL, commandData.ToArray()); SendMessage(new IrcMessage("ChanBot", connectSession.owner.username + " just logged in !")); }
static void Main(string[] args) { SettingsHandler = SettingsHandlerService.FromConfig(); //DigitalPriceExchange = new DigitalPriceExchangeService(); RandomManager = new RandomManagerService(); YoMommaJokes = new YoMommaJokeService(); DaemonClient = new DaemonClient(SettingsHandler.Daemon.IpAddress + ":" + SettingsHandler.Daemon.Port) { credentials = new NetworkCredential(SettingsHandler.Daemon.Username, SettingsHandler.Daemon.Password) }; // Ensure fee account is already created DaemonClient.GetWalletAddressFromAccount(SettingsHandler.Dallar.FeeAccount, true, out string toWallet); MainAsync(args).Wait(); }
public AionJob(string id, AionBlockTemplate blockTemplate, ILogger logger, DaemonClient daemon) { Id = id; BlockTemplate = blockTemplate; this.logger = logger; var target = blockTemplate.Target; if (target.StartsWith("0x")) { target = target.Substring(2); } this.daemonClient = daemon; Difficulty = getNetworkDifficulty(); blockTarget = new uint256(target.HexToByteArray().ReverseArray()); }
public void Configure(ClusterConfig clusterConfig, PoolConfig poolConfig) { this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; logger = LogUtil.GetPoolScopedLogger(typeof(EthereumPayoutHandler), poolConfig); // configure standard daemon var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); var daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) .ToArray(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints); }
public virtual Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) { Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; coinProperties = BitcoinProperties.GetCoinProperties(poolConfig.Coin.Type, poolConfig.Coin.Algorithm); logger = LogUtil.GetPoolScopedLogger(typeof(BitcoinPayoutHandler), poolConfig); var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(poolConfig.Daemons); return(Task.FromResult(true)); }
public async Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) { this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <AionPoolPaymentExtraConfig>(); logger = LogUtil.GetPoolScopedLogger(typeof(AionPayoutHandler), poolConfig); // configure standard daemon var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); var daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) .ToArray(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(daemonEndpoints); }
public AionJob(string id, AionBlockTemplate blockTemplate, ILogger logger, DaemonClient daemon, IComponentContext ctx, JObject solver) { Id = id; BlockTemplate = blockTemplate; this.logger = logger; var target = blockTemplate.Target; if (target.StartsWith("0x")) { target = target.Substring(2); } this.daemonClient = daemon; Difficulty = getNetworkDifficulty(); blockTarget = new uint256(target.HexToReverseByteArray()); equihash = EquihashSolverFactory.GetSolver(ctx, solver); }
public virtual Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) { Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraPoolConfig = poolConfig.Extra.SafeExtensionDataAs <BitcoinDaemonEndpointConfigExtra>(); extraPoolPaymentProcessingConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <BitcoinPoolPaymentProcessingConfigExtra>(); logger = LogUtil.GetPoolScopedLogger(typeof(BitcoinPayoutHandler), poolConfig); var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); daemon.Configure(poolConfig.Daemons); return(Task.FromResult(true)); }
public virtual Task ConfigureAsync(XPoolConfig clusterConfig, PoolConfig poolConfig) { Assertion.RequiresNonNull(poolConfig, nameof(poolConfig)); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraPoolConfig = poolConfig.Extra.SafeExtensionDataAs <BitcoinDaemonEndpointConfigExtra>(); extraPoolPaymentProcessingConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <BitcoinPoolPaymentProcessingConfigExtra>(); coinProperties = BitcoinProperties.GetCoinProperties(poolConfig.Coin.Type, poolConfig.Coin.Algorithm); logger = LogUtil.GetPoolScopedLogger(typeof(BitcoinPayoutHandler), poolConfig); var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); daemon = new DaemonClient(jsonSerializerSettings); daemon.Configure(poolConfig.Daemons); return(Task.FromResult(true)); }
public void Execute(DaemonClient client, string commandLine) { string name = commandLine.Substring(Command.Length + 1); Repository db = client.Daemon.OpenRepository(name); if (db == null) { return; } bool on = Enabled; if (Overridable) { on = db.Config.getBoolean("daemon", Config, on); } if (on) { Execute(client, db); } }
private void PayoutTransferRequest(TransferRequest request, DaemonClient fromDaemonClient, DaemonClient toDaemonClient, DateTime timeStamp) { if (null != fromDaemonClient && null != toDaemonClient) { if (request.Status == (int)TransferStatus.Confirmed && request.Updated == timeStamp) { decimal exchangeRate = _contextHolder.ExchangeRate.Bid; if (exchangeRate > 0) { decimal tradeAmount = (request.Amount * exchangeRate); decimal fee = 0;// (tradeAmount * 0.05m); decimal amount = (tradeAmount - fee); Transfer transfer = new Transfer { BidAmount = request.Amount, Created = request.Created, Updated = timeStamp, ExchangeRate = exchangeRate, FromAddress = request.FromAddress, FromCoin = request.FromCoin, Status = request.Status, ToAddress = request.ToAddress, ToCoin = request.ToCoin, TradeAmount = amount }; transfer.Reference = PayoutToAddress(request.ToAddress, amount, toDaemonClient); if (!string.IsNullOrEmpty(transfer.Reference)) { PersistPayment(request, transfer); } } } else if (request.Status == (int)TransferStatus.Pending && request.Updated == timeStamp) { _iConnectionFactory.Run(con => _iTransferRequestRepository.Update(con, null, request)); } } }
public async Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) { this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; extraPoolConfig = poolConfig.Extra.SafeExtensionDataAs <EthereumPoolConfigExtra>(); extraConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs <EthereumPoolPaymentProcessingConfigExtra>(); logger = LogUtil.GetPoolScopedLogger(typeof(EthereumPayoutHandler), poolConfig); // configure standard daemon var jsonSerializerSettings = ctx.Resolve <JsonSerializerSettings>(); var daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) .ToArray(); daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); daemon.Configure(daemonEndpoints); await DetectChainAsync(); }
private void InternalProcessTransferRequests(TransferRequest[] requests) { if (!_updatingThroughput) { _updatingThroughput = true; _logger.Debug("Executing Payout Manager."); if (null != requests && requests.Length > 0) { DaemonClient fromDaemonClient = _daemonClientFactory.GetDaemonClient(CoinType.BTC); DaemonClient toDaemonClient = _daemonClientFactory.GetDaemonClient(CoinType.BTP); DateTime timeStamp = DateTime.Now; foreach (TransferRequest request in requests) { UpdateTransferRequestStatus(request, fromDaemonClient, timeStamp); PayoutTransferRequest(request, fromDaemonClient, toDaemonClient, timeStamp); } } _updatingThroughput = false; } }
public override void OnConnect(Session connectSession, DaemonClient client) { base.OnConnect(connectSession, client); connectSession.owner.Send(PacketType.MESSG, "Opening DNS service"); connectSession.owner.Send(PacketType.KERNL, "state", "dns", "open"); }
public abstract void Execute(DaemonClient client, Repository db);
public abstract void Execute(DaemonClient client, Repository db);