public AddressControl GetPublicAddressControl(PublicAddress data, ref string strError) { AddressControl addrControl = null; addrControl = new AddressControl(); addrControl.AddressObject = data; try { switch (data.CoinName) { case PublicAddress.ChosenCoin.Anoncoin: case PublicAddress.ChosenCoin.Dogecoin: case PublicAddress.ChosenCoin.Bitcoin: case PublicAddress.ChosenCoin.Mooncoin: case PublicAddress.ChosenCoin.FedoraCoin: case PublicAddress.ChosenCoin.Zetacoin: case PublicAddress.ChosenCoin.Coino: case PublicAddress.ChosenCoin.Devcoin: case PublicAddress.ChosenCoin.Feathercoin: case PublicAddress.ChosenCoin.Infinitecoin: case PublicAddress.ChosenCoin.LeafCoin: case PublicAddress.ChosenCoin.DigiByte: case PublicAddress.ChosenCoin.Vertcoin: case PublicAddress.ChosenCoin.Ixcoin: case PublicAddress.ChosenCoin.Megacoin: case PublicAddress.ChosenCoin.Netcoin: case PublicAddress.ChosenCoin.Animecoin: case PublicAddress.ChosenCoin.Auroracoin: addrControl.AddressObject.Balance = GetBalanceAPI(data.CoinName, addrControl.AddressObject.Address); break; case PublicAddress.ChosenCoin.Litecoin: case PublicAddress.ChosenCoin.Digitalcoin: case PublicAddress.ChosenCoin.Quark: addrControl.AddressObject.Balance = GetBalanceJSON(data.CoinName, addrControl.AddressObject.Address); break; case PublicAddress.ChosenCoin.Worldcoin: case PublicAddress.ChosenCoin.Peercoin: case PublicAddress.ChosenCoin.Namecoin: case PublicAddress.ChosenCoin.Novacoin: case PublicAddress.ChosenCoin.YBcoin: addrControl.AddressObject.Balance = GetBalanceAPI2(data.CoinName, addrControl.AddressObject.Address); break; } } catch (Exception ex) { strError = ex.Message; } return addrControl; }
public PublicAddress InsertPublicAddress(PublicAddress addressToAdd, ref string strError) { PublicAddress address = new PublicAddress(); try { using (var conn = new SQLiteConnection(ConnectionString)) using (var cmd = new SQLiteCommand("INSERT INTO PublicAddress (CoinName, Address, AddressDescription, Notify, Condition, Price) VALUES (@CoinName, @Address, @AddressDescription, @Notify, @Condition, @Price)", conn)) { conn.Open(); cmd.Parameters.Add(new SQLiteParameter("@CoinName", addressToAdd.CoinName.ToString())); cmd.Parameters.Add(new SQLiteParameter("@Address", addressToAdd.Address)); cmd.Parameters.Add(new SQLiteParameter("@AddressDescription", addressToAdd.AddressDescription)); cmd.Parameters.Add(new SQLiteParameter("@Price", addressToAdd.Price)); cmd.Parameters.Add(new SQLiteParameter("@Notify", addressToAdd.Notify)); cmd.Parameters.Add(new SQLiteParameter("@Condition", addressToAdd.Condition)); cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT LAST_INSERT_ROWID();"; int ID = Convert.ToInt32(cmd.ExecuteScalar()); cmd.CommandText = "SELECT * FROM PublicAddress WHERE PublicAddressPK = " + ID.ToString(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { PublicAddress addr = new PublicAddress() { PublicAddressPK = reader.GetInt32(reader.GetOrdinal("PublicAddressPK")), CoinName = (PublicAddress.ChosenCoin)Enum.Parse(typeof(PublicAddress.ChosenCoin), reader.GetString(reader.GetOrdinal("CoinName")), true), Address = reader.GetString(reader.GetOrdinal("Address")), AddressDescription = reader.GetString(reader.GetOrdinal("AddressDescription")), Condition = reader.GetString(reader.GetOrdinal("Condition")), Notify = reader.GetBoolean(reader.GetOrdinal("Notify")), Price = reader.GetInt32(reader.GetOrdinal("Price")) }; address = addr; } } } } catch (Exception ex) { strError = ex.Message; } return address; }
public frmEditPublicAddress(PublicAddress addr) { InitializeComponent(); if (File.Exists(Application.StartupPath + @"\images\c3.ico")) this.Icon = new Icon(Application.StartupPath + @"\images\c3.ico"); publicAddress = addr; txtAddress.Text = publicAddress.Address; txtCoinName.Text = publicAddress.CoinName.ToString(); txtDescription.Text = publicAddress.AddressDescription; txtPrice.Text = publicAddress.Price.ToString(); chkNotify.Checked = publicAddress.Notify; foreach (var item in cbxCondition.Items) if (item.ToString() == publicAddress.Condition) cbxCondition.SelectedItem = item; }
public List<PublicAddress> GetPublicAddresses(ref string strError) { List<PublicAddress> pubAddresses = new List<PublicAddress>(); try { using (var conn = new SQLiteConnection(ConnectionString)) using (var cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "SELECT * FROM PublicAddress"; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { PublicAddress address = new PublicAddress() { PublicAddressPK = reader.GetInt32(reader.GetOrdinal("PublicAddressPK")), CoinName = (PublicAddress.ChosenCoin)Enum.Parse(typeof(PublicAddress.ChosenCoin), reader.GetString(reader.GetOrdinal("CoinName")), true), Address = reader.GetString(reader.GetOrdinal("Address")), AddressDescription = reader.GetString(reader.GetOrdinal("AddressDescription")), Condition = reader.GetString(reader.GetOrdinal("Condition")), Notify = reader.GetBoolean(reader.GetOrdinal("Notify")), Price = reader.GetInt32(reader.GetOrdinal("Price")) }; pubAddresses.Add(address); } } } } catch (Exception ex) { strError = ex.Message; } return pubAddresses; }
public void UpdatePublicAddress(PublicAddress address, ref string strError) { try { using (var conn = new SQLiteConnection(ConnectionString)) using (var cmd = new SQLiteCommand("UPDATE PublicAddress SET Address = @Address, AddressDescription = @AddressDescription, Price = @Price, Notify = @Notify, Condition = @Condition " + "WHERE PublicAddressPK = @PublicAddressPK", conn)) { conn.Open(); cmd.Parameters.Add(new SQLiteParameter("@PublicAddressPK", address.PublicAddressPK)); cmd.Parameters.Add(new SQLiteParameter("@Address", address.Address)); cmd.Parameters.Add(new SQLiteParameter("@AddressDescription", address.AddressDescription)); cmd.Parameters.Add(new SQLiteParameter("@Price", address.Price)); cmd.Parameters.Add(new SQLiteParameter("@Notify", address.Notify)); cmd.Parameters.Add(new SQLiteParameter("@Condition", address.Condition)); cmd.ExecuteNonQuery(); } } catch (Exception ex) { strError = ex.Message; } }
public void UpdateAddressNotification(PublicAddress address, ref string strError) { try { using (var conn = new SQLiteConnection(ConnectionString)) using (var cmd = new SQLiteCommand("UPDATE PublicAddress SET Notify = @Notify WHERE PublicAddressPK = @PublicAddressPK", conn)) { conn.Open(); cmd.Parameters.Add(new SQLiteParameter("@PublicAddressPK", address.PublicAddressPK)); cmd.Parameters.Add(new SQLiteParameter("@Notify", address.Notify)); cmd.ExecuteNonQuery(); } } catch (Exception ex) { strError = ex.Message; } }
public void RemoveAddressControl(PublicAddress address) { foreach (AddressControl ctrl in flpControls.Controls) if (ctrl.AddressObject.Address == address.Address) flpControls.Controls.Remove(ctrl); }
private string GetBalanceJSON(PublicAddress.ChosenCoin coinName, string address) { string balance = "0"; string coinURL = string.Empty; if (coinName == PublicAddress.ChosenCoin.Litecoin) coinURL = "http://ltc.blockr.io/api/v1/address/balance/"; else if (coinName == PublicAddress.ChosenCoin.Digitalcoin) coinURL = "http://dgc.blockr.io/api/v1/address/balance/"; else if (coinName == PublicAddress.ChosenCoin.Quark) coinURL = "http://qrk.blockr.io/api/v1/address/balance/"; string html = GetHTML(coinURL + address); balance = JsonConvert.DeserializeObject<dynamic>(html).data.balance; return balance; }
private string GetBalanceAPI2(PublicAddress.ChosenCoin coinName, string address) { string finalBalance = "0"; string receivedbyBalance = "0"; string sentbyBalance = "0"; string urlReceivedBy = string.Empty; string urlSentBy = string.Empty; if (coinName == PublicAddress.ChosenCoin.Peercoin) { urlReceivedBy = "http://ppc.cryptocoinexplorer.com/chain/PPCoin/q/getreceivedbyaddress/"; urlSentBy = "http://ppc.cryptocoinexplorer.com/chain/PPCoin/q/getsentbyaddress/"; } else if (coinName == PublicAddress.ChosenCoin.Namecoin) { urlReceivedBy = "http://192.241.222.65/chain/Namecoin/q/getreceivedbyaddress/"; urlSentBy = "http://192.241.222.65/chain/Namecoin/q/getsentbyaddress/"; } else if (coinName == PublicAddress.ChosenCoin.Worldcoin) { urlReceivedBy = "http://wdc.cryptocoinexplorer.com/chain/Worldcoin/q/getreceivedbyaddress/"; urlSentBy = "http://wdc.cryptocoinexplorer.com/chain/Worldcoin/q/getsentbyaddress/"; } else if (coinName == PublicAddress.ChosenCoin.Novacoin) { urlReceivedBy = "http://nvc.cryptocoinexplorer.com/chain/Novacoin/q/getreceivedbyaddress/"; urlSentBy = "http://nvc.cryptocoinexplorer.com/chain/Novacoin/q/getsentbyaddress/"; } else if (coinName == PublicAddress.ChosenCoin.YBcoin) { urlReceivedBy = "http://explorer.ybcoin.com/chain/Ybcoin/q/getreceivedbyaddress/"; urlSentBy = "http://explorer.ybcoin.com/chain/Ybcoin/q/getsentbyaddress/"; } receivedbyBalance = GetHTML(urlReceivedBy + address); sentbyBalance = GetHTML(urlSentBy + address); finalBalance = (Convert.ToDecimal(receivedbyBalance) - Convert.ToDecimal(sentbyBalance)).ToString(); return finalBalance; }
private string GetBalanceAPI(PublicAddress.ChosenCoin coinName, string address) { string balance = "0"; string url = string.Empty; if (coinName == PublicAddress.ChosenCoin.Dogecoin) url = "http://dogechain.info/chain/CHAIN/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Bitcoin) url = "https://blockchain.info/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Mooncoin) url = "http://moonchain.info/chain/Mooncoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.FedoraCoin) url = "http://fedorachain.info/chain/Fedora/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Zetacoin) url = "http://zetachain.com/chain/Zetacoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Coino) url = "http://cryptexplorer.com/chain/Coino/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Anoncoin) url = "http://explorer.anoncoin.net/chain/Anoncoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Devcoin) url = "http://darkgamex.ch:2751/chain/DevCoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Feathercoin) url = "https://explorer.feathercoin.com/chain/Feathercoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Infinitecoin) url = "http://exploretheblocks.com:2750/chain/Infinitecoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.LeafCoin) url = "http://explorer.leafco.in/chain/LeafCoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.DigiByte) url = "http://cryptexplorer.com/chain/DigiByte/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Vertcoin) url = "http://explorer.vertcoin.org/chain/Vertcoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Ixcoin) url = "http://darkgamex.ch:2751/chain/IXCoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Megacoin) url = "http://mega.rapta.net:2750/chain/MegaCoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Netcoin) url = "http://explorer.netcoinfoundation.org/chain/Netcoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Animecoin) url = "http://explorer.anime.cf/chain/Animecoin/q/addressbalance/"; else if (coinName == PublicAddress.ChosenCoin.Auroracoin) url = "http://blockexplorer.auroracoin.eu/chain/AuroraCoin/q/addressbalance/"; string html = GetHTML(url + address); if (html == "ERROR: address invalid" || html == "Checksum does not validate" || html == "(INVALID ADDRESS)") balance = "HTML GET ERROR"; else { if (coinName == PublicAddress.ChosenCoin.Bitcoin) balance = (Convert.ToDecimal(html) / 100000000).ToString(); else balance = html; } return balance; }
public void UpdatePublicAddress(PublicAddress address, ref string strError) { addressData.UpdatePublicAddress(address, ref strError); }
public void UpdateAddressNotification(PublicAddress address, ref string strError) { AddressData data = new AddressData(); data.UpdateAddressNotification(address, ref strError); }
public PublicAddress InsertPublicAddress(PublicAddress addressToAdd, ref string strError) { PublicAddress address = new PublicAddress(); address = addressData.InsertPublicAddress(addressToAdd, ref strError); return address; }
private bool IsAddressAlreadyShown(PublicAddress addr) { bool isInListView = false; foreach (ListViewItem lvi in lvAddresses.Items) { if (lvi.SubItems[2].Text == addr.Address) { isInListView = true; break; } } return isInListView; }
private void btnAdd_Click(object sender, EventArgs e) { if (cbxCoins.SelectedIndex == -1) { MessageBox.Show("Please select a coin.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtAddress.Text == string.Empty || txtAddress.Text.Length != 34) { MessageBox.Show("Please enter a valid address.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (IsAddressInList(txtAddress.Text)) { MessageBox.Show("That address has already been added.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (chkNotify.Checked) { if (cbxCondition.SelectedIndex == -1) { MessageBox.Show("if you want a notification, you must specify a condition.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtPrice.Text == string.Empty) { MessageBox.Show("if you want a notification, you must enter a price.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } PublicAddress address = new PublicAddress() { CoinName = (PublicAddress.ChosenCoin)Enum.Parse(typeof(PublicAddress.ChosenCoin), cbxCoins.SelectedValue.ToString(), true), Address = txtAddress.Text, AddressDescription = txtDescription.Text, Notify = chkNotify.Checked, Condition = cbxCondition.SelectedIndex == -1 ? "" : cbxCondition.SelectedItem.ToString(), Price = txtPrice.Text == string.Empty ? 0 : Convert.ToInt32(txtPrice.Text) }; string strError = string.Empty; SettingsManager.PublicAddresses.Add(cAddress.InsertPublicAddress(address, ref strError)); if (!string.IsNullOrEmpty(strError)) MessageBox.Show("An error occurred while trying to save that address to the database." + Environment.NewLine + Environment.NewLine + strError, "", MessageBoxButtons.OK, MessageBoxIcon.Error); else { frmSettings settings = null; foreach (Form form in Application.OpenForms) if (form.Name == "frmSettings") settings = (frmSettings)form; settings.RefreshAddresses(); this.Close(); } }