private void CreateWalletSuccessForm_Load(object sender, EventArgs e)
 {
     labelCreateWalletInformation.Text =
         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletsubmenulabelinformationtext);
     labelYourPinCode.Text =
         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletsubmenulabelpincodetext) + " " + PinCode;
     labelYourPrivateKey.Text =
         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletsubmenulabelprivatekeytext) + " " +
         PrivateKey;
     labelYourPublicKey.Text =
         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletsubmenulabelpublickeytext) + " " +
         PublicKey;
     buttonAcceptAndCloseWalletInformation.Text =
         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletsubmenubuttonacceptwalletinformationtext);
     buttonCopyWalletInformation.Text =
         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletsubmenubuttoncopywalletinformationtext);
     ClassParallelForm.HideWaitingCreateWalletFormAsync();
 }
Esempio n. 2
0
        private async void ButtonSendTransaction_ClickAsync(object sender, EventArgs e)
        {
            try
            {
                string amountstring = textBoxAmount.Text.Replace(",", ".");
                string feestring    = textBoxFee.Text.Replace(",", ".");

                var checkAmount = CheckAmount(amountstring);
                var checkFee    = CheckAmount(feestring);
                if (checkAmount.Item1)
                {
                    var amountSend = checkAmount.Item2;
                    if (checkFee.Item1)
                    {
                        var feeSend = checkFee.Item2;
                        if (CheckAmountNetwork(amountSend + feeSend))
                        {
                            string destination = ClassUtility.RemoveSpecialCharacters(textBoxWalletDestination.Text);
                            if ((destination.Length >= 48 &&
                                 destination.Length <= 128) && Regex.IsMatch(
                                    destination,
                                    "[a-z0-9]+", RegexOptions.IgnoreCase))
                            {
#if WINDOWS
                                if (ClassFormPhase.MessageBoxInterface(ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_SUBMIT_CONTENT_TEXT").Replace(ClassTranslation.AmountSendOrder, "" + amountSend).Replace(ClassTranslation.TargetAddressOrder, destination),
                                                                       ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_SUBMIT_TITLE_TEXT"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
                                    DialogResult.Yes)
#else
                                if (MessageBox.Show(ClassFormPhase.WalletXiropht, ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_SUBMIT_CONTENT_TEXT").Replace(ClassTranslation.AmountSendOrder, "" + amountSend).Replace(ClassTranslation.TargetAddressOrder, destination),
                                                    ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_SUBMIT_TITLE_TEXT"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
                                    DialogResult.Yes)
#endif
                                {
                                    ClassParallelForm.ShowWaitingForm();

                                    if (checkBoxHideWalletAddress.Checked)
                                    {
                                        await ClassWalletObject.WalletConnect.SendPacketWallet(
                                            ClassWalletCommand.ClassWalletSendEnumeration.SendTransaction + "|" +
                                            destination + "|" + amountSend + "|" + feeSend + "|1", ClassWalletObject.Certificate, true);
                                    }
                                    else
                                    {
                                        await ClassWalletObject.WalletConnect.SendPacketWallet(
                                            ClassWalletCommand.ClassWalletSendEnumeration.SendTransaction + "|" +
                                            destination + "|" + amountSend + "|" + feeSend + "|0", ClassWalletObject.Certificate, true);
                                    }

                                    MethodInvoker invoke = () =>
                                    {
                                        checkBoxHideWalletAddress.Checked = false;
                                        textBoxAmount.Text            = "0.00000000";
                                        textBoxFee.Text               = "0.00001000";
                                        textBoxWalletDestination.Text = string.Empty;
                                    };
                                    BeginInvoke(invoke);
                                }
                            }
                            else
                            {
#if WINDOWS
                                ClassFormPhase.MessageBoxInterface(ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_ERROR_TARGET_CONTENT_TEXT"), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                                MessageBox.Show(ClassFormPhase.WalletXiropht, ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_ERROR_TARGET_CONTENT_TEXT"));
#endif
                            }
                        }
                    }
                    else
                    {
#if WINDOWS
                        ClassFormPhase.MessageBoxInterface(ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_ERROR_FEE_CONTENT_TEXT"), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                        MessageBox.Show(ClassFormPhase.WalletXiropht, ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_ERROR_FEE_CONTENT_TEXT"));
#endif
                    }
                }
                else
                {
#if WINDOWS
                    ClassFormPhase.MessageBoxInterface(ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_ERROR_AMOUNT_CONTENT_TEXT"), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                    MessageBox.Show(ClassFormPhase.WalletXiropht, ClassTranslation.GetLanguageTextFromOrder("SEND_TRANSACTION_WALLET_MESSAGE_ERROR_AMOUNT_CONTENT_TEXT"));
#endif
                }
            }
            catch (Exception error)
            {
                Console.WriteLine("Exception error: " + error.Message);
            }
            Refresh();
        }
        private async void buttonRestoreYourWallet_ClickAsync(object sender, EventArgs e)
        {
            if (CheckPasswordValidity())
            {
                ClassParallelForm.ShowWaitingFormAsync();

                var walletPath     = textBoxPathWallet.Text;
                var walletPassword = textBoxPassword.Text;
                var walletKey      = textBoxPrivateKey.Text;
                walletKey              = Regex.Replace(walletKey, @"\s+", string.Empty);
                textBoxPassword.Text   = string.Empty;
                textBoxPathWallet.Text = string.Empty;
                textBoxPrivateKey.Text = string.Empty;
                CheckPasswordValidity();


                await Task.Factory.StartNew(async() =>
                {
                    var walletRestoreFunctions = new ClassWalletRestoreFunctions();

                    var requestRestoreQrCodeEncrypted =
                        walletRestoreFunctions.GenerateQrCodeKeyEncryptedRepresentation(walletKey, walletPassword);

                    if (Program.WalletXiropht.ClassWalletObject != null)
                    {
                        await Program.WalletXiropht.InitializationWalletObject();
                    }

                    if (await Program.WalletXiropht.ClassWalletObject.InitializationWalletConnection(string.Empty,
                                                                                                     walletPassword, string.Empty, ClassWalletPhase.Restore))
                    {
                        Program.WalletXiropht.ClassWalletObject.ListenSeedNodeNetworkForWallet();

                        Program.WalletXiropht.ClassWalletObject.WalletDataCreationPath = walletPath;
                        if (await Program.WalletXiropht.ClassWalletObject.WalletConnect.SendPacketWallet(
                                Program.WalletXiropht.ClassWalletObject.Certificate, string.Empty, false))
                        {
                            if (requestRestoreQrCodeEncrypted != null)
                            {
                                Program.WalletXiropht.ClassWalletObject.WalletNewPassword = walletPassword;
                                Program.WalletXiropht.ClassWalletObject.WalletPrivateKeyEncryptedQRCode = walletKey;

                                await Task.Delay(1000);

                                if (!await Program.WalletXiropht.ClassWalletObject.SeedNodeConnectorWallet
                                    .SendPacketToSeedNodeAsync(
                                        ClassWalletCommand.ClassWalletSendEnumeration.AskPhase + ClassConnectorSetting.PacketContentSeperator +
                                        requestRestoreQrCodeEncrypted,
                                        Program.WalletXiropht.ClassWalletObject.Certificate, false, true))
                                {
                                    ClassParallelForm.HideWaitingFormAsync();
#if WINDOWS
                                    ClassFormPhase.MessageBoxInterface(
                                        ClassTranslation.GetLanguageTextFromOrder(
                                            ClassTranslationEnumeration.createwalleterrorcantconnectmessagecontenttext), string.Empty,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                                    MethodInvoker invoke = () => MessageBox.Show(Program.WalletXiropht,
                                                                                 ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalleterrorcantconnectmessagecontenttext));
                                    Program.WalletXiropht.BeginInvoke(invoke);
#endif
                                }
                            }
                            else
                            {
                                ClassParallelForm.HideWaitingFormAsync();

#if WINDOWS
                                ClassFormPhase.MessageBoxInterface("Invalid private key inserted.", string.Empty,
                                                                   MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                                MethodInvoker invoke =
                                    () => MessageBox.Show(Program.WalletXiropht, "Invalid private key inserted.");
                                Program.WalletXiropht.BeginInvoke(invoke);
#endif
                            }
                        }
                        else
                        {
                            ClassParallelForm.HideWaitingFormAsync();

#if WINDOWS
                            ClassFormPhase.MessageBoxInterface(
                                ClassTranslation.GetLanguageTextFromOrder(
                                    ClassTranslationEnumeration.createwalleterrorcantconnectmessagecontenttext), string.Empty,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                            MethodInvoker invoke = () => MessageBox.Show(Program.WalletXiropht,
                                                                         ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalleterrorcantconnectmessagecontenttext));
                            Program.WalletXiropht.BeginInvoke(invoke);
#endif
                        }
                    }
                    else
                    {
                        ClassParallelForm.HideWaitingFormAsync();

#if WINDOWS
                        ClassFormPhase.MessageBoxInterface(
                            ClassTranslation.GetLanguageTextFromOrder(
                                ClassTranslationEnumeration.createwalleterrorcantconnectmessagecontenttext), string.Empty,
                            MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                        MethodInvoker invoke = () => MessageBox.Show(Program.WalletXiropht,
                                                                     ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalleterrorcantconnectmessagecontenttext));
                        Program.WalletXiropht.BeginInvoke(invoke);
#endif
                    }

                    walletRestoreFunctions.Dispose();
                }, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Current);
            }
            else
            {
#if WINDOWS
                ClassFormPhase.MessageBoxInterface(
                    ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletlabelpasswordrequirementtext),
                    ClassTranslation.GetLanguageTextFromOrder(
                        ClassTranslationEnumeration.walletnetworkobjectcreatewalletpassworderror2titletext), MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
#else
                await Task.Factory.StartNew(() =>
                {
                    MethodInvoker invoke = () => MessageBox.Show(Program.WalletXiropht,
                                                                 ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.createwalletlabelpasswordrequirementtext),
                                                                 ClassTranslation.GetLanguageTextFromOrder(ClassTranslationEnumeration.walletnetworkobjectcreatewalletpassworderror2titletext), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Program.WalletXiropht.BeginInvoke(invoke);
                }).ConfigureAwait(false);
#endif
            }
        }