Пример #1
0
 private void btnExportVault_Click(object sender, EventArgs e)
 {
     try
     {
         CoinRPC b          = new CoinRPC(new Uri(GetURL(Main.coinIP[Main.CoinType]) + ":" + Main.coinPort[Main.CoinType]), new NetworkCredential(Main.coinUser[Main.CoinType], Main.coinPassword[Main.CoinType]));
         var     strAddress = b.GetAddressesByAccount("~~~~~" + cmbTipAddress.Text);
         Thread  thread     = new Thread(() => Clipboard.SetText(b.DumpPrivateKey(strAddress.First())));
         thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
         thread.Start();
         thread.Join();                                //Wait for the thread to end
     }
     catch { }
 }
Пример #2
0
        private void btnArchive_Click(object sender, EventArgs e)
        {
            DialogResult prompt = MessageBox.Show("You are about to permanently etch a profile onto " + Main.CoinType + "." + Environment.NewLine + "            !!! Apertus may lock up during this process !!!" + Environment.NewLine + "       Please be patient.  We will thread it better next time.", "Confirmation", MessageBoxButtons.YesNoCancel);

            if (prompt == DialogResult.Yes)
            {
                Main.ProfileID    = "";
                Main.ProfileLabel = "";
                var    mainForm      = Application.OpenForms.OfType <Main>().Single();
                string tempSignature = Main.SignatureLabel;
                Main.SignatureLabel = "~~" + cmbProfileAddress.Text;
                Match  match            = Regex.Match(openFileDialog1.FileName, @"([a-fA-F0-9]{64})");
                string profileImagePath = "";
                if (openFileDialog1.FileName != "openFileDialog1" && !match.Success)

                {
                    mainForm.PerformArchive(Main.CoinType, openFileDialog1.FileName, "");
                    var b            = new CoinRPC(new Uri(GetURL(Main.coinIP[Main.CoinType]) + ":" + Main.coinPort[Main.CoinType]), new NetworkCredential(Main.coinUser[Main.CoinType], Main.coinPassword[Main.CoinType]));
                    var transactions = b.ListTransactions("~~~~" + cmbProfileAddress.Text, 100, 0);

                    foreach (var transaction in transactions.Reverse())
                    {
                        if (transaction.category == "receive")
                        {
                            if (mainForm.CreateArchive(transaction.txid, Main.CoinType, false, true, null, null, false))
                            {
                                if (System.IO.File.Exists("root//" + transaction.txid + "//" + Path.GetFileName(openFileDialog1.FileName)))
                                {
                                    profileImagePath = "../" + transaction.txid + "/" + Path.GetFileName(openFileDialog1.FileName);
                                    break;
                                }
                            }
                        }
                    }
                }

                if (match.Success)
                {
                    profileImagePath = "../" + match.Value + "/" + Path.GetFileName(openFileDialog1.FileName);
                }


                String processId = Guid.NewGuid().ToString();
                System.IO.Directory.CreateDirectory("process//" + processId);
                System.IO.StreamWriter proFile = new System.IO.StreamWriter("process//" + processId + "//PRO");
                proFile.WriteLine("IMG=" + profileImagePath);
                proFile.WriteLine("NIK=" + txtNickName.Text);
                proFile.WriteLine("PRE=" + txtPrefix.Text);
                proFile.WriteLine("FNM=" + txtFirstName.Text);
                proFile.WriteLine("MNM=" + txtMiddleName.Text);
                proFile.WriteLine("LNM=" + txtLastName.Text);
                proFile.WriteLine("SUF=" + txtSuffix.Text);
                proFile.WriteLine("AD1=" + txtAddress1.Text);
                proFile.WriteLine("AD2=" + txtAddress2.Text);
                proFile.WriteLine("AD3=" + txtAddress3.Text);
                CoinRPC a = new CoinRPC(new Uri(GetURL(Main.coinIP[Main.CoinType]) + ":" + Main.coinPort[Main.CoinType]), new NetworkCredential(Main.coinUser[Main.CoinType], Main.coinPassword[Main.CoinType]));
                IEnumerable <string> Address = null;
                if (cmbTipAddress.SelectedIndex > 0)
                {
                    Address = a.GetAddressesByAccount("~~~~~" + cmbTipAddress.Text);
                    proFile.WriteLine("TIP=" + Address.First());
                }
                Address = a.GetAddressesByAccount("~~~~" + cmbProfileAddress.Text);
                var privKeyHex = BitConverter.ToString(Base58.Decode(a.DumpPrivateKey(Address.First()))).Replace("-", "");
                privKeyHex = privKeyHex.Substring(2, 64);
                BigInteger privateKey = Hex.HexToBigInteger(privKeyHex);
                ECPoint    publicKey  = Secp256k1.Secp256k1.G.Multiply(privateKey);

                proFile.WriteLine("MSG=" + Address.First());
                proFile.WriteLine("PKX=" + publicKey.X.ToHex());
                proFile.WriteLine("PKY=" + publicKey.Y.ToHex());
                proFile.Close();

                mainForm.PerformArchive(Main.CoinType, Application.StartupPath + "//process//" + processId + "//PRO", "");
                Main.SignatureLabel = tempSignature;
                BuildSelectedProfile();
                Main.ProfileID    = txtTransID.Text;
                Main.ProfileLabel = cmbProfileAddress.Text;
                mainForm.AddProfile(cmbProfileAddress.Text);
            }
        }