Ejemplo n.º 1
0
 public void AddNewAccount(string name)
 {
     AccountItem newAccount = new AccountItem();
     newAccount.m_name=name;
     newAccount.GenerateKey();
     m_Accounts.Add(newAccount);
 }
Ejemplo n.º 2
0
        public void SendTX(AccountItem account, byte[] to, Int64 qAmount)
        {
            SC_Transaction tx = new SC_Transaction();
            tx.m_dwAddressID = account.m_addressid;
            Array.Copy(account.GetPubKeyBytes(), 1, tx.m_Extra1, 0, 64);    //this isnt always sent, but may as well just copy it
            if (tx.m_dwAddressID == 0)  tx.m_dwType = 1;
            for (int x = 0; x < 8; x++) tx.m_Info[x] = 0;
            tx.m_FromAddress = account.GetAddressBytes();
            tx.m_RecvAddress = to;
            tx.m_qAmount = qAmount*10000;

            byte[] hash = tx.GetHash(false);
            string s = MicroCashFunctions.ToHex(hash);
            tx.m_Signature = account.Sign(hash);

            MicroCashRPC mcrpc = CreateMCRPC();
            byte[] txserialized = tx.GetByteBuffer(true);
            if (txserialized.Length != 108)
            {
                int n = 0;
            }
            SendTransaction sendtx = mcrpc.SendTransaction(MicroCashFunctions.ToHex(txserialized));
            if (sendtx != null && sendtx.sent == true)
            {
                account.m_addressid++;
            }
            else
            {
                m_LogItems.Add("Failed to send transaction from "+account.m_name + " amount "+qAmount.ToString() + " error:"+mcrpc.m_ErrorMessage);
            }
        }
Ejemplo n.º 3
0
 public bool LoadFromFile(string filename)
 {
     m_FileName = filename;
     bool bRet = false;
     XmlTextReader reader = null;
     try
     {
         reader = new XmlTextReader(m_FileName);
         while (reader.Read())
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element: // The node is an element.
                     switch (reader.Name)
                     {
                         case "name": reader.MoveToContent(); m_name = reader.ReadElementContentAsString(); break;
                         case "pass1": reader.MoveToContent(); m_pass1 = reader.ReadElementContentAsString(); break;
                         case "pass2": reader.MoveToContent(); m_pass2 = reader.ReadElementContentAsString(); break;
                         case "icon": reader.MoveToContent(); m_icon = reader.ReadElementContentAsInt(); break;
                         case "account":
                             {
                                 AccountItem newAccount = new AccountItem();
                                 if (newAccount.AccountXMLLoad(reader))
                                 {
                                     m_Accounts.Add(newAccount);
                                 }
                                 break;
                             }
                     }
                     break;
                 case XmlNodeType.EndElement:
                     break;
             }
         }
     }
     catch (System.IO.FileNotFoundException exception)
     {
         return false;
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error reading " + m_FileName);
     }
     finally
     {
         reader.Close();
     }
     return bRet;
 }