public PaymentProcessor(string pool, IDaemonClient daemonClient, IStorage storage , IWalletConfig walletConfig) { _daemonClient = daemonClient; _storage = storage; _walletConfig = walletConfig; _logger = Log.ForContext<PaymentProcessor>().ForContext("Component", pool); }
public PaymentProcessor(IPoolConfig poolConfig, IDaemonClient daemonClient, IStorage storage, IBlockProcessor blockProcessor) { _daemonClient = daemonClient; _storage = storage; _blockProcessor = blockProcessor; _walletConfig = poolConfig.Wallet; _rewardsConfig = poolConfig.Rewards; _logger = Log.ForContext <PaymentProcessor>().ForContext("Component", poolConfig.Coin.Name); }
public DevWallet(IWalletConfig walletConfig, ILogManager logManager) { _logger = logManager.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _keySeed[31] = 1; for (int i = 0; i < walletConfig?.DevAccounts; i++) { PrivateKey key = new PrivateKey(_keySeed); _keys.Add(key.Address, key); _passwords.Add(key.Address, AnyPassword); _isUnlocked.Add(key.Address, true); _keySeed[31]++; } }
/// <summary> /// Creates a new instance of generation transaction. /// </summary> /// <param name="extraNonce">The extra nonce.</param> /// <param name="daemonClient">The daemon client.</param> /// <param name="blockTemplate">The block template.</param> /// <param name="rewardsConfig"></param> /// <param name="supportTxMessages">if set to <c>true</c> [support tx messages].</param> /// <remarks> /// Reference implementations: /// https://github.com/zone117x/node-stratum-pool/blob/b24151729d77e0439e092fe3a1cdbba71ca5d12e/lib/transactions.js /// https://github.com/Crypto-Expert/stratum-mining/blob/master/lib/coinbasetx.py /// </remarks> public GenerationTransaction(IExtraNonce extraNonce, IDaemonClient daemonClient, IBlockTemplate blockTemplate, IWalletConfig walletConfig, IRewardsConfig rewardsConfig, bool supportTxMessages = false) { DaemonClient = daemonClient; BlockTemplate = blockTemplate; ExtraNonce = extraNonce; SupportTxMessages = supportTxMessages; Version = (UInt32)(supportTxMessages ? 2 : 1); Message = Serializers.SerializeString("https://github.com/CoiniumServ/CoiniumServ"); LockTime = 0; // transaction inputs Inputs = new List<TxIn> { new TxIn { PreviousOutput = new OutPoint { Hash = Hash.ZeroHash, Index = (UInt32) Math.Pow(2, 32) - 1 }, Sequence = 0x0, SignatureScript = new SignatureScript( blockTemplate.Height, blockTemplate.CoinBaseAux.Flags, TimeHelpers.NowInUnixTime(), (byte) extraNonce.ExtraNoncePlaceholder.Length, "/CoiniumServ/") } }; // transaction outputs Outputs = new Outputs(daemonClient); double blockReward = BlockTemplate.Coinbasevalue; // the amount rewarded by the block. // generate output transactions for recipients (set in config). foreach (var pair in rewardsConfig) { var amount = blockReward * pair.Value / 100; // calculate the amount he recieves based on the percent of his shares. blockReward -= amount; Outputs.AddRecipient(pair.Key, amount); } // send the remaining coins to pool's central wallet. Outputs.AddPoolWallet(walletConfig.Adress, blockReward); }
public JobManager(string pool, IDaemonClient daemonClient, IJobTracker jobTracker, IShareManager shareManager, IMinerManager minerManager, IHashAlgorithm hashAlgorithm, IWalletConfig walletConfig, IRewardsConfig rewardsConfig) { _daemonClient = daemonClient; _jobTracker = jobTracker; _shareManager = shareManager; _minerManager = minerManager; _hashAlgorithm = hashAlgorithm; _walletConfig = walletConfig; _rewardsConfig = rewardsConfig; _jobCounter = new JobCounter(); // todo make this ioc based too. _logger = Log.ForContext<JobManager>().ForContext("Component", pool); }
public IPaymentProcessor GetPaymentProcessor(string pool, IDaemonClient daemonClient, IStorage storage, IWalletConfig walletConfig) { var @params = new NamedParameterOverloads { {"pool", pool}, {"daemonClient", daemonClient}, {"storage", storage}, {"walletConfig", walletConfig}, }; return _applicationContext.Container.Resolve<IPaymentProcessor>(@params); }
public IJobManager GetJobManager(string pool, IDaemonClient daemonClient, IJobTracker jobTracker, IShareManager shareManager, IMinerManager minerManager, IHashAlgorithm hashAlgorithm, IWalletConfig walletConfig, IRewardsConfig rewardsConfig) { var @params = new NamedParameterOverloads { {"pool", pool}, {"daemonClient", daemonClient}, {"jobTracker", jobTracker}, {"shareManager", shareManager}, {"minerManager", minerManager}, {"hashAlgorithm", hashAlgorithm}, {"walletConfig", walletConfig}, {"rewardsConfig", rewardsConfig}, }; return _applicationContext.Container.Resolve<IJobManager>(@params); }
public GenerationTransactionTests() { // daemon client _daemonClient = Substitute.For<IDaemonClient>(); _daemonClient.ValidateAddress(Arg.Any<string>()).Returns(new ValidateAddress { IsValid = true }); // block template const string json = "{\"result\":{\"version\":2,\"previousblockhash\":\"e9bbcc9b46ed98fd4850f2d21e85566defdefad3453460caabc7a635fc5a1261\",\"transactions\":[],\"coinbaseaux\":{\"flags\":\"062f503253482f\"},\"coinbasevalue\":5000000000,\"target\":\"0000004701b20000000000000000000000000000000000000000000000000000\",\"mintime\":1402660580,\"mutable\":[\"time\",\"transactions\",\"prevblock\"],\"noncerange\":\"00000000ffffffff\",\"sigoplimit\":20000,\"sizelimit\":1000000,\"curtime\":1402661060,\"bits\":\"1d4701b2\",\"height\":302526},\"error\":null,\"id\":1}"; var @object = JsonConvert.DeserializeObject<DaemonResponse<BlockTemplate>>(json); _blockTemplate = @object.Result; // extra nonce _extraNonce = new ExtraNonce(0); // signature script _signatureScript = new SignatureScript( _blockTemplate.Height, _blockTemplate.CoinBaseAux.Flags, 1402661059432, (byte)_extraNonce.ExtraNoncePlaceholder.Length, "/nodeStratum/"); // use the same output data within our sample data. _outputs = Substitute.For<Outputs>(_daemonClient); double blockReward = 5000000000; // the amount rewarded by the block. // sample reward recipient _rewardsConfig = Substitute.For<IRewardsConfig>(); var amount = blockReward * 0.01; blockReward -= amount; var rewards = new Dictionary<string, float> { { "mrwhWEDnU6dUtHZJ2oBswTpEdbBHgYiMji", (float)amount } }; _rewardsConfig.GetEnumerator().Returns(rewards.GetEnumerator()); foreach (var pair in rewards) { _outputs.AddRecipient(pair.Key, pair.Value); } // sample pool wallet _walletConfig = Substitute.For<IWalletConfig>(); _walletConfig.Adress.Returns("mk8JqN1kNWju8o3DXEijiJyn7iqkwktAWq"); _outputs.AddPoolWallet(_walletConfig.Adress, blockReward); }