private async void PaySender(TelegramBotClient botClient, Message _message)
        {
            if (transaction.IsConfirmOrCancelUserRecipient == 1 && transaction.IsConfirmOrCancelUserSender == 1)
            {
                switch (transaction.PaymentId)
                {
                case 1:
                    addresBTC = db.GetAddresBTCInt(transaction.AddresBTCId);                            //dec - (dec * percent)

                    await BlockchainManager.Instance.SendBTC(transaction.PublicKeyWallet, transaction.SumPayNew - (transaction.SumPayNew * (BlockchainManager.Instance.Settings.transactionPercentFee / 100)), (transaction.SumPayNew * (BlockchainManager.Instance.Settings.transactionPercentFee / 100)), addresBTC);

                    break;

                case 3:
                    await BlockchainManager.Instance.SendETH(transaction.PublicKeyWallet, transaction.SumPayNew);

                    break;

                case 4:
                    await BlockchainManager.Instance.SendRipple(transaction.PublicKeyWallet, transaction.SumPayNew);

                    break;
                }

                String text = "Деньги были отправлены отправителю!";

                botClient.SendText(transaction.UserRecipient.ID, text);
                botClient.SendText(transaction.UserSender.ID, text);
                ChangeTransactionInPay();
            }
        }
        private void SendMessage(TelegramBotClient botClient, Message _message)
        {
            botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");

            String text = $"Отправитель: {transaction.UserSender.FIO}";

            text += transaction.UserRecipient != null ? $"\nПолучатель: {transaction.UserRecipient.FIO}" : "";
            text += "\nКомиссия: ";
            text += transaction.WhoCommissionPay == true ? "получатель" : "отправитель";
            text += $"\nСумма: {transaction.SumPayNew}\nВалюта: ";
            text += transaction.PaymentId == 1 ? "BTC" : transaction.PaymentId == 2 ? "USDT" : transaction.PaymentId == 3 ? "Ethereum" : transaction.PaymentId == 4 ? "Ripple" : "не выбрана!";

            if (transaction.PaymentId == 1 && transaction.UserRecipient == null)
            {
                GenerateKey();

                AddresBTC addres = db.GetAddresBTC(addresBTC.PrivateKey);

                transaction.AddresBTCId = addres.Id;
                user.Chain = (Int32)SetChain.SetIdTransaction;
                db.Save();
                text += "__\nНомер кошелька для отправки денег:__ " + "```" + addresBTC.PublickKey + "``` " + "(Текст можно скопировать тапом)";
                text += "__\n\nВведите HASH транзакции, этот параметр обязателен, мы должны понимать что именно вы отправили деньги на наш кошелек!\nВ противном случаи услуги гаранта для вас будут недоступны!__";
                botClient.SendText(_message.From.Id, text, user, replyMarkup: InlineButtonBlockchain.SetTransactionMenu(transaction), IsMarkdown: true);
            }
            else
            {
                botClient.EditMessage(_message.From.Id, user.MessageID, text, "55 - SetBlockChain", user, replyMarkup: InlineButtonBlockchain.SelectConfirmOrCancelThisTransaction(transaction));
                botClient.SendText(transaction.UserSenderId, $"Транзакция была подтверждена {user.FIO}");
            }
        }
        private void GenerateKey()
        {
            BitcoinSecret temp = BlockchainManager.Instance.GenerateBTCKey();

            addresBTC = new AddresBTC
            {
                PrivateKey = temp.ToString(),
                PublickKey = temp.PubKey.GetAddress(Network.Main).ToString()
            };
            db.SetValue <AddresBTC>(new AddresBTC()
            {
                PrivateKey = temp.ToString(), PublickKey = temp.GetAddress().ToString()
            });
            db.Save();
        }
        private async void PaySender()
        {
            switch (transaction.PaymentId)
            {
            case 1:
                addresBTC = db.GetAddresBTCInt(transaction.AddresBTCId);
                await BlockchainManager.Instance.SendBTC(transaction.PublicKeyWallet, transaction.SumPayNew - (transaction.SumPayNew * ((BlockchainManager.Instance.Settings.transactionPercentFee + BlockchainManager.Instance.Settings.transactionPercentFeeAdmin) / 100)), (transaction.SumPayNew * ((BlockchainManager.Instance.Settings.transactionPercentFee + BlockchainManager.Instance.Settings.transactionPercentFeeAdmin) / 100)), addresBTC);

                break;

            case 3:
                await BlockchainManager.Instance.SendETH(transaction.IdTransaction, transaction.SumPayNew);

                break;

            case 4:
                await BlockchainManager.Instance.SendRipple(transaction.IdTransaction, transaction.SumPayNew);

                break;
            }
        }
Exemple #5
0
        private async Task <Boolean> CheckIdTransaction(TelegramBotClient botClient)
        {
            Transaction   found   = db.GetTransactionByHash(_message.Text);
            TransactionId errTran = db.GetFailedTransactionByHash(_message.Text);

            Boolean isAlreadyUsed = (found != null || errTran != null);

            if (isAlreadyUsed)
            {
                AddIdTransactionFalse();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Данная транзакция уже была использованна или она не действительная!", "51 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }

            Money money = null;

            try
            {
                switch (transaction.PaymentId)
                {
                case 0:
                {
                    return(false);
                }

                case 1:                         // BTC
                {
                    addresBTC = db.GetAddresBTCInt(transaction.AddresBTCId);
                    money     = await BlockchainManager.Instance.GetBTCTransactionMoney(_message.Text, addresBTC);

                    break;
                }

                case 3:                         // Eth
                {
                    money = await BlockchainManager.Instance.GetETHTransactionMoney(_message.Text);

                    break;
                }

                case 4:                         // Ripple
                {
                    money = await BlockchainManager.Instance.GetXRPTransactionMoney(_message.Text);

                    break;
                }
                }
            }
            catch
            {
                AddIdTransactionIsNotBD();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Данная транзакция не действительная или она не была подтвержденна, попробуйте ввести транзакцию позже!", "86 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }
            if (money == null)
            {
                AddIdTransactionFalse();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Данная транзакция не действительная или она не была подтвержденна, попробуйте ввести транзакцию позже!", "92 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }
            Decimal dec     = money.ToDecimal(MoneyUnit.BTC);
            Decimal percent = Convert.ToDecimal(0.15);

            if (dec < transaction.SumPayNew)
            {
                switch (transaction.PaymentId)
                {
                case 1:
                {
                    addresBTC = db.GetAddresBTCInt(transaction.AddresBTCId);
                    await BlockchainManager.Instance.SendBTC(transaction.PublicKeyWalletSender, dec, 0, addresBTC);

                    break;
                }

                case 3:
                {
                    await BlockchainManager.Instance.SendETHBackByHash(_message.Text);

                    break;
                }

                case 4:
                {
                    await BlockchainManager.Instance.SendXRPBackByHash(_message.Text);

                    break;
                }
                }

                AddIdTransactionFalse();
                botClient.DeleteMessage(_message.From.Id, _message.MessageId, "48 - SetBlockChain");
                botClient.EditMessage(_message.From.Id, user.MessageID, "Вы отправили меньше денег нежелеи заявили, ваши деньги были возращены на ваш кошелек!", "122 - SetIdTransaction", user, replyMarkup: InlineButtonBlockchain.TransactionCreationGuarantor(transaction));
                return(false);
            }

            AddIdTransaction();
            return(true);
        }