AddressForAvatar() public method

public AddressForAvatar ( string user_identifier, string user_email ) : string
user_identifier string
user_email string
return string
        private bool Create()
        {
            //m_created_ts = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
            m_created_ts = 0;

            if (m_original_currency_code == "BTC") {
                m_btc_amount = m_original_amount;
            } else {
                m_btc_amount = ToBTC(m_original_amount, m_original_currency_code);
            }

            BitcoinAddress addr = new BitcoinAddress(m_connectionString, m_config);
            m_btc_address = addr.AddressForAvatar(m_payee, m_payee_email);
            if (m_btc_address == "") {
                return false;
            }
            //m_btc_address = "15S5AqChfugJRaUZSAe2tkvhjqMkn3qo7y";

            string query = "";
            query += "INSERT INTO opensim_btc_transactions (";
            query += "payee, ";
            query += "item_name, ";
            query += "transaction_code, ";
            query += "original_amount, ";
            query += "original_currency_code, ";
            query += "btc_amount, ";
            query += "notify_url, ";
            query += "btc_address, ";
            query += "num_confirmations_required, ";
            query += "created_ts";
            query += ") values(";
            query += "?payee, ";
            query += "?item_name, ";
            query += "?transaction_code, ";
            query += "?original_amount, ";
            query += "?original_currency_code, ";
            query += "?btc_amount, ";
            query += "?notify_url, ";
            query += "?btc_address, ";
            query += "?num_confirmations_required, ";
            query += "?created_ts);";

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {

                dbcon.Open();

                MySqlCommand cmd = new MySqlCommand( query, dbcon);

                try
                {
                    using (cmd)
                    {
                        cmd.Parameters.AddWithValue("?payee", m_payee);
                        cmd.Parameters.AddWithValue("?item_name", m_item_name);
                        cmd.Parameters.AddWithValue("?transaction_code", m_transaction_code);
                        cmd.Parameters.AddWithValue("?original_amount", m_original_amount);
                        cmd.Parameters.AddWithValue("?original_currency_code", m_original_currency_code);
                        cmd.Parameters.AddWithValue("?btc_amount", m_btc_amount);
                        cmd.Parameters.AddWithValue("?notify_url", m_notify_url);
                        cmd.Parameters.AddWithValue("?btc_address", m_btc_address);
                        cmd.Parameters.AddWithValue("?num_confirmations_required", m_num_confirmations_required);
                        cmd.Parameters.AddWithValue("?created_ts", m_created_ts);
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();

                        return true;

                    }
                }
                catch (Exception)
                {
                    //m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
                }

            }

            return false;
        }
Esempio n. 2
0
        private bool Create()
        {
            //m_created_ts = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
            m_created_ts = 0;

            if (m_original_currency_code == "BTC")
            {
                m_btc_amount = m_original_amount;
            }
            else
            {
                m_btc_amount = ToBTC(m_original_amount, m_original_currency_code);
            }

            BitcoinAddress addr = new BitcoinAddress(m_connectionString, m_config);

            m_btc_address = addr.AddressForAvatar(m_payee, m_payee_email);
            if (m_btc_address == "")
            {
                return(false);
            }
            //m_btc_address = "15S5AqChfugJRaUZSAe2tkvhjqMkn3qo7y";

            string query = "";

            query += "INSERT INTO opensim_btc_transactions (";
            query += "payee, ";
            query += "item_name, ";
            query += "transaction_code, ";
            query += "original_amount, ";
            query += "original_currency_code, ";
            query += "btc_amount, ";
            query += "notify_url, ";
            query += "btc_address, ";
            query += "num_confirmations_required, ";
            query += "created_ts";
            query += ") values(";
            query += "?payee, ";
            query += "?item_name, ";
            query += "?transaction_code, ";
            query += "?original_amount, ";
            query += "?original_currency_code, ";
            query += "?btc_amount, ";
            query += "?notify_url, ";
            query += "?btc_address, ";
            query += "?num_confirmations_required, ";
            query += "?created_ts);";

            using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
            {
                dbcon.Open();

                MySqlCommand cmd = new MySqlCommand(query, dbcon);

                try
                {
                    using (cmd)
                    {
                        cmd.Parameters.AddWithValue("?payee", m_payee);
                        cmd.Parameters.AddWithValue("?item_name", m_item_name);
                        cmd.Parameters.AddWithValue("?transaction_code", m_transaction_code);
                        cmd.Parameters.AddWithValue("?original_amount", m_original_amount);
                        cmd.Parameters.AddWithValue("?original_currency_code", m_original_currency_code);
                        cmd.Parameters.AddWithValue("?btc_amount", m_btc_amount);
                        cmd.Parameters.AddWithValue("?notify_url", m_notify_url);
                        cmd.Parameters.AddWithValue("?btc_address", m_btc_address);
                        cmd.Parameters.AddWithValue("?num_confirmations_required", m_num_confirmations_required);
                        cmd.Parameters.AddWithValue("?created_ts", m_created_ts);
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();

                        return(true);
                    }
                }
                catch (Exception)
                {
                    //m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
                }
            }

            return(false);
        }