Exemple #1
0
        private void btnSnedTransaction_Click(object sender, EventArgs e)
        {
            var     keyPath = GlobalVar.keystore_path + "\\" + cboxAccount.Text;
            var     keyPwd  = txtKeyPwd.Text;
            Account account;

            try
            {
                account = TransactionEx.UnlockAccountFromKeyStoreFile(keyPath, keyPwd);
            }
            catch (Exception)
            {
                account = null;
            }
            if (account == null)
            {
                EasyMsg.ShowTips("密码错误!");
                return;
            }
            var trans = new TransactionEx(cBoxRpc.Text);
            var nonce = trans.GetTransactionCount(account.Address);
            var sign  = trans.SignTransaction(account.PrivateKey, txtReciveAddress.Text, decimal.Parse(txtAmount.Text), nonce, account.Address);
            var msg   = trans.SendRawTransaction(sign);

            if (string.IsNullOrEmpty(msg))
            {
                EasyMsg.ShowTips("网络异常,请重新尝试!");
                return;
            }
            if (msg.IndexOf("0x") == 0)
            {
                EasyMsg.ShowTips("转赠成功!\r\nhash值:" + msg);
                var balance = decimal.Parse(txtBalance.Text);
                var amount  = decimal.Parse(txtAmount.Text);
                txtBalance.Text = (balance - amount).ToString();
            }
            else
            {
                EasyMsg.ShowTips("转赠失败:" + msg);
                return;
            }
        }
Exemple #2
0
        private void cboxAccount_SelectedIndexChanged(object sender, EventArgs e)
        {
            var trans = new TransactionEx(cBoxRpc.Text);

            txtBalance.Text = trans.GetBalance(cboxAccount.Text).ToString();
        }