コード例 #1
0
        private void btn_continue_Click(object sender, EventArgs e)
        {
            if (!CheckStatus())
            {
                return;
            }

            UserWallet wallet;

            try
            {
                wallet = UserWallet.Open(passwordItem1.GetWalletPath(), passwordItem1.GetPassword());
            }
            catch (CryptographicException ex)
            {
                lbl_warning.Text = StringTable.DATA[iLang, 21];
                lbl_warning.Show();
                return;
            }
            catch (FormatException ex)
            {
                lbl_warning.Text = ex.Message;
                lbl_warning.Show();
                return;
            }

            Settings.Default.LastWalletPath = passwordItem1.GetWalletPath();
            Settings.Default.Save();

            this.Hide();
            mainWalletForm = new MainWalletForm(wallet);
            if (mainWalletForm.ShowDialog() == DialogResult.OK)
            {
            }
        }
コード例 #2
0
        private void btn_new_wallet_yes_Click(object sender, EventArgs e)
        {
            if (!CheckParameter())
            {
                return;
            }

            UserWallet wallet;

            if (chk_anonymous.Checked == true)
            {
                wallet = UserWallet.Create(txb_wallet_path.Text, txb_password.Text, KeyType.Anonymous);
            }
            else
            {
                wallet = UserWallet.Create(txb_wallet_path.Text, txb_password.Text, KeyType.Transparent);
            }


            Settings.Default.LastWalletPath = txb_wallet_path.Text;
            Settings.Default.Save();

            using (MainWalletForm dialog = new MainWalletForm(wallet))
            {
                this.Hide();
                FormManager.GetInstance().Push(dialog);
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            //Get hSig
            byte[] random_byte256 = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(random_byte256);
            }
            UInt256        hSig    = new UInt256(random_byte256);
            NoteEncryption noteEnc = new NoteEncryption(hSig);

            SpendingKey sk = SpendingKey.random();

            Console.Write("SpendingKey is " + sk.ToArray().ToHexString());
            Console.WriteLine();

            PaymentAddress addr  = sk.address();
            PaymentAddress addr1 = sk.address();


            byte[] plain_text  = { 0x74, 0x64, 0x64, 0x66, 0x23, 0x46, 0x54, 0x23, 0x32, 0x33, 0x33, 0x33, 0x33 };
            byte[] cipher_text = noteEnc.Encrypt(addr.pk_enc, plain_text);

            NoteDecryption noteDec = new NoteDecryption(sk.receiving_key());

            byte[] plain_text_m = noteDec.Decrypt(cipher_text, noteEnc.get_epk(), hSig, (char)0);
        }