コード例 #1
0
        private async Task <bool> HandleTransferResponseAsync(DaemonResponse <TransferResponse> response, params Balance[] balances)
        {
            var coin = poolConfig.Template.As <CryptonoteCoinTemplate>();

            if (response.Error == null)
            {
                var txHash = response.Response.TxHash;
                var txFee  = (decimal)response.Response.Fee / coin.SmallestUnit;

                logger.Info(() => $"[{LogCategory}] Payout transaction id: {txHash}, TxFee {FormatAmount(txFee)}, TxKey {response.Response.TxKey}");

                await PersistPaymentsAsync(balances, txHash);

                NotifyPayoutSuccess(poolConfig.Id, balances, new[] { txHash }, txFee);
                return(true);
            }

            else
            {
                logger.Error(() => $"[{LogCategory}] Daemon command '{CryptonoteWalletCommands.Transfer}' returned error: {response.Error.Message} code {response.Error.Code}");

                NotifyPayoutFailure(poolConfig.Id, balances, $"Daemon command '{CryptonoteWalletCommands.Transfer}' returned error: {response.Error.Message} code {response.Error.Code}", null);
                return(false);
            }
        }
コード例 #2
0
        private async Task <bool> HandleTransferResponseAsync(DaemonResponse <TransferSplitResponse> response, params Balance[] balances)
        {
            var coin = poolConfig.Template.As <CryptonoteCoinTemplate>();

            if (response.Error == null)
            {
                var txHashes = response.Response.TxHashList;
                var txFees   = response.Response.FeeList.Select(x => (decimal)x / coin.SmallestUnit).ToArray();

                logger.Info(() => $"[{LogCategory}] Split-Payout transaction ids: {string.Join(", ", txHashes)}, Corresponding TxFees were {string.Join(", ", txFees.Select(FormatAmount))}");

                await PersistPaymentsAsync(balances, txHashes.First());

                NotifyPayoutSuccess(poolConfig.Id, balances, txHashes, txFees.Sum());
                return(true);
            }

            else
            {
                logger.Error(() => $"[{LogCategory}] Daemon command '{CryptonoteWalletCommands.TransferSplit}' returned error: {response.Error.Message} code {response.Error.Code}");

                NotifyPayoutFailure(poolConfig.Id, balances, $"Daemon command '{CryptonoteWalletCommands.TransferSplit}' returned error: {response.Error.Message} code {response.Error.Code}", null);
                return(false);
            }
        }
コード例 #3
0
        private async Task HandleTransferResponseAsync(DaemonResponse <TransferResponse> response, params Balance[] balances)
        {
            if (response.Error == null)
            {
                var txHash = response.Response.TxHash;
                var txFee  = (decimal)response.Response.Fee / MoneroConstants.Piconero;

                // check result
                if (string.IsNullOrEmpty(txHash))
                {
                    logger.Error(() => $"[{LogCategory}] Daemon command '{MWC.Transfer}' did not return a transaction id!");
                }
                else
                {
                    logger.Info(() => $"[{LogCategory}] Payout transaction id: {txHash}, TxFee was {FormatAmount(txFee)}");
                }

                PersistPayments(balances, txHash);

                await NotifyPayoutSuccess(balances, txHash, txFee);
            }

            else
            {
                logger.Error(() => $"[{LogCategory}] Daemon command '{MWC.Transfer}' returned error: {response.Error.Message} code {response.Error.Code}");

                await NotifyPayoutFailureAsync(balances, $"Daemon command '{MWC.Transfer}' returned error: {response.Error.Message} code {response.Error.Code}", null);
            }
        }
コード例 #4
0
 /// <summary>
 /// Asserts that two DaemonResponses are equal.
 /// If the test passes, the TestStatus should be set by the caller.
 /// If the test fails, TestStatus is set by this method.
 /// </summary>
 /// <param name="val1"></param>
 /// <param name="val2"></param>
 /// <param name="message">Error message for the user</param>
 /// <returns>Boolean indicating whether the test was successful</returns>
 public bool AssertEqual(DaemonResponse val1, DaemonResponse val2, string message)
 {
     if (val1 != val2)
     {
         this.TestStatus   = Status.Failed;
         this.ErrorMessage = message;
         Log.Logger.Fatal($"{message} : {val1} != {val2}");
     }
     else
     {
         Log.Logger.Debug($"Success : {val1} == {val2}");
     }
     return(val1 == val2);
 }
コード例 #5
0
        private async Task <string> PayoutAsync(Balance balance)
        {
            DaemonResponse <string> response = null;

            if (extraConfig.SendTransactionsUsingPrivateKey.Equals(true))
            {
                response = await SendTransactionPrivateKey(balance);
            }
            else if (!String.IsNullOrEmpty(extraConfig.AccountPassword))
            {
                await UnlockAccount();

                response = await SendTransactionUnlockedAccount(balance);
            }
            else
            {
                logger.Error(() => $"[{LogCategory}] The password or private key is missing from the configuration, unable to send payments.");
                throw new Exception("Missing password or private key");
            }

            if (response.Error != null)
            {
                throw new Exception($"{AionCommands.SendTx} returned error: {response.Error.Message}, code {response.Error.Code}. {response.Error.Data}");
            }

            if (string.IsNullOrEmpty(response.Response) || AionConstants.ZeroHashPattern.IsMatch(response.Response))
            {
                throw new Exception($"{AionCommands.SendTx} did not return a valid transaction hash");
            }

            var txHash = response.Response;

            logger.Info(() => $"[{LogCategory}] Payout transaction id: {txHash}");

            // update db
            await PersistPaymentsAsync(new[] { balance }, txHash);

            NotifyPayoutSuccess(poolConfig.Id, new[] { balance }, new[] { txHash }, null);

            // done
            return(txHash);
        }
コード例 #6
0
        private void HandleTransferResponse(DaemonResponse <TransferSplitResponse> response, params Balance[] balances)
        {
            if (response.Error == null)
            {
                var txHashes = response.Response.TxHashList;
                var txFees   = response.Response.FeeList.Select(x => (decimal)x / MoneroConstants.Piconero).ToArray();

                logger.Info(() => $"[{LogCategory}] Split-Payout transaction ids: {string.Join(", ", txHashes)}, Corresponding TxFees were {string.Join(", ", txFees.Select(FormatAmount))}");

                PersistPayments(balances, txHashes.First());
                NotifyPayoutSuccess(balances, txHashes, txFees.Sum());
            }

            else
            {
                logger.Error(() => $"[{LogCategory}] Daemon command '{MWC.TransferSplit}' returned error: {response.Error.Message} code {response.Error.Code}");

                NotifyPayoutFailure(balances, $"Daemon command '{MWC.TransferSplit}' returned error: {response.Error.Message} code {response.Error.Code}", null);
            }
        }
コード例 #7
0
        private void HandleTransferResponse(DaemonResponse <TransferResponse> response, params Balance[] balances)
        {
            if (response.Error == null)
            {
                var txHash = response.Response.TxHash;
                var txFee  = (decimal)response.Response.Fee / MoneroConstants.Piconero;

                logger.Info(() => $"[{LogCategory}] Payout transaction id: {txHash}, TxFee was {FormatAmount(txFee)}");

                PersistPayments(balances, txHash);
                NotifyPayoutSuccess(balances, new[] { txHash }, txFee);
            }

            else
            {
                logger.Error(() => $"[{LogCategory}] Daemon command '{MWC.Transfer}' returned error: {response.Error.Message} code {response.Error.Code}");

                NotifyPayoutFailure(balances, $"Daemon command '{MWC.Transfer}' returned error: {response.Error.Message} code {response.Error.Code}", null);
            }
        }