Beispiel #1
0
    private void CheckBTCWallet()
    {
        if (string.IsNullOrEmpty(BtcAddressTextBox.Text))
        {
            return;
        }

        BitcoinValidator.BitcoinValidator.ValidateBitcoinAddress(BtcAddressTextBox.Text);
        CryptocurrencyWithdrawalAddress.AddIfNotExists(
            User.Id,
            BtcAddressTextBox.Text.Replace(" ", String.Empty),
            CryptocurrencyType.BTC);
        BtcAddressWarning.Visible = true;
    }
Beispiel #2
0
    public static void AddIfNotExists(int userId, string address, CryptocurrencyType cryptocurrenyType)
    {
        var currentAddresses = GetAddress(userId, cryptocurrenyType);

        if (currentAddresses == null)
        {
            var newAddress = new CryptocurrencyWithdrawalAddress(userId, address, cryptocurrenyType);
            newAddress.Save();
        }
        else if (currentAddresses.Address != address)
        {
            currentAddresses.Address   = address;
            currentAddresses.DateAdded = AppSettings.ServerTime;
            currentAddresses.IsNew     = false;
            currentAddresses.Save();
        }
    }
Beispiel #3
0
    private void CheckTokenWallet()
    {
        if (String.IsNullOrWhiteSpace(TokenAddressTextBox.Text))
        {
            return;
        }

        if (TokenCryptocurrency.WithdrawalEnabled)
        {
            CryptocurrencyWithdrawalAddress.AddIfNotExists(
                User.Id,
                TokenAddressTextBox.Text.Replace(" ", String.Empty),
                CryptocurrencyType.ERC20Token);

            TokenAddressWarning.Visible = true;
        }
    }
Beispiel #4
0
    private void CheckEthereumWallet()
    {
        if (String.IsNullOrWhiteSpace(EthAddressTextBox.Text))
        {
            return;
        }

        if (EthCryptocurrency.WithdrawalEnabled)
        {
            CryptocurrencyWithdrawalAddress.AddIfNotExists(
                User.Id,
                EthAddressTextBox.Text.Replace(" ", String.Empty),
                CryptocurrencyType.ETH);

            EthAddressWarning.Visible = true;
        }
    }
Beispiel #5
0
    private void CheckRippleWallet()
    {
        if (String.IsNullOrWhiteSpace(XrpAddressTextBox.Text) || String.IsNullOrWhiteSpace(XrpDestTagTextBox.Text))
        {
            return;
        }

        if (XrpCryptocurrency.WithdrawalEnabled)
        {
            var rippleAddress = new RippleAddress(
                XrpAddressTextBox.Text.Replace(" ", String.Empty),
                XrpDestTagTextBox.Text.Replace(" ", String.Empty));

            CryptocurrencyWithdrawalAddress.AddIfNotExists(User.Id, rippleAddress.ToString(), CryptocurrencyType.XRP);
            XrpAddressWarning.Visible = true;
        }
    }
    private static string GetAndUseBTCWallet(int userId)
    {
        var BtcCryptocurrency = CryptocurrencyFactory.Get(CryptocurrencyType.BTC);

        var daysToActivate = BtcCryptocurrency.ActivateUserAddressAfterDays;
        var btcAddress     = CryptocurrencyWithdrawalAddress.GetAddress(userId, CryptocurrencyType.BTC);

        if (btcAddress == null)
        {
            throw new MsgException(U6000.ADDBTCADDRESSFIRST);
        }

        if (!btcAddress.IsNew && btcAddress.DateAdded.AddDays(daysToActivate) > AppSettings.ServerTime)
        {
            throw new MsgException(string.Format(U6000.CANTWITHDRAWBTCUNTIL, (btcAddress.DateAdded.AddDays(daysToActivate) - AppSettings.ServerTime).ToFriendlyDisplay(2)));
        }

        return(btcAddress.Address.Replace(" ", String.Empty));
    }
Beispiel #7
0
    protected string TryGetWithdrawalAddress(Cryptocurrency cryptocurrency)
    {
        string address = String.Empty;

        if (cryptocurrency.WithdrawalApiProcessor == CryptocurrencyAPIProvider.Coinbase)
        {
            CoinbaseAddressesDDL.Enabled = false;
            if (AppSettings.Cryptocurrencies.CoinbaseAddressesPolicy == CoinbaseAddressesPolicy.CoinbaseEmailOrBTCWallet)
            {
                if (CoinbaseAddressesDDL.SelectedValue == CoinbaseAddressesPolicy.BTCWallet.ToString())
                {
                    address = CoinbaseAddressHelper.TryToGetAndUseAddress(User.Id, 2);
                }
                else
                {
                    address = CoinbaseAddressHelper.TryToGetAndUseAddress(User.Id, 1);
                }
            }
            else
            {
                address = CoinbaseAddressHelper.TryToGetAndUseAddress(User.Id);
            }
        }
        else
        {
            cryptocurrencyAddress = CryptocurrencyWithdrawalAddress.GetAddress(Member.CurrentId, SelectedCryptocurrency);

            if (cryptocurrencyAddress == null)
            {
                throw new MsgException(U6000.ADDBTCADDRESSFIRST);
            }

            if (!cryptocurrencyAddress.IsNew && cryptocurrencyAddress.DateAdded.AddDays(cryptocurrency.ActivateUserAddressAfterDays) > AppSettings.ServerTime)
            {
                throw new MsgException(string.Format(U6000.CANTWITHDRAWBTCUNTIL, (cryptocurrencyAddress.DateAdded.AddDays(cryptocurrency.ActivateUserAddressAfterDays) - AppSettings.ServerTime).ToFriendlyDisplay(2)));
            }

            address = cryptocurrencyAddress.Address.Replace(" ", String.Empty);
        }

        return(address);
    }
Beispiel #8
0
    private void SetAndCheckCryptocurrencyAddress()
    {
        var WalletAddressCryptocurrencyType = SelectedCryptocurrency;

        cryptocurrencyAddress = CryptocurrencyWithdrawalAddress.GetAddress(Member.CurrentId, WalletAddressCryptocurrencyType);

        if (cryptocurrencyAddress != null)
        {
            WithdrawCryptocurrencyAddressTextBox.Text = cryptocurrencyAddress.Address;

            if (SelectedCryptocurrency == CryptocurrencyType.XRP)
            {
                var rippleAddress = RippleAddress.FromString(WithdrawCryptocurrencyAddressTextBox.Text);
                WithdrawCryptocurrencyAddressTextBox.Text = rippleAddress.ToDisplayString();
            }

            ChangeCryptocurrencyAddressButton.Text = U6007.CHANGE;
        }
        else
        {
            ChangeCryptocurrencyAddressButton.Text = L1.ADDNEW;
        }
    }
 private static CryptocurrencyWithdrawalAddress GetBTCWallet(int userId)
 {
     return(CryptocurrencyWithdrawalAddress.GetAddress(userId, CryptocurrencyType.BTC));
 }
Beispiel #10
0
    protected void PaymentSettingsView_Activate(object sender, EventArgs e)
    {
        tokenImage.ImageUrl = AppSettings.Ethereum.ERC20TokenImageUrl;
        //Coinbase addresses policy
        if (BtcCryptocurrency.WithdrawalApiProcessor == CryptocurrencyAPIProvider.Coinbase)
        {
            switch (AppSettings.Cryptocurrencies.CoinbaseAddressesPolicy)
            {
            case CoinbaseAddressesPolicy.BTCWallet:
                BtcAddressTextBox.Text = CoinbaseAddressHelper.GetAddress(User.Id);
                break;

            case CoinbaseAddressesPolicy.CoinbaseEmail:
                SetCoinbaseEmailControls();
                btcSettings.Visible = false;
                break;

            case CoinbaseAddressesPolicy.CoinbaseEmailOrBTCWallet:
                SetCoinbaseEmailControls();
                BtcAddressTextBox.Text    = CoinbaseAddressHelper.GetAddress(User.Id, 2);
                CoinbaseEmailTextBox.Text = CoinbaseAddressHelper.GetAddress(User.Id, 1);
                break;
            }
        }
        else
        {
            var currentAddress = CryptocurrencyWithdrawalAddress.GetAddress(User.Id, CryptocurrencyType.BTC);

            if (currentAddress != null)
            {
                BtcAddressTextBox.Text = currentAddress.Address;
            }
            else
            {
                BtcAddressWarning.Visible = false;
            }

            //Ripple
            if (XrpCryptocurrency.WithdrawalEnabled)
            {
                var currentRippleAddress = CryptocurrencyWithdrawalAddress.GetAddress(User.Id, CryptocurrencyType.XRP);

                if (currentRippleAddress != null)
                {
                    var rippleAddress = RippleAddress.FromString(currentRippleAddress.Address);
                    XrpAddressTextBox.Text = rippleAddress.Address;
                    XrpDestTagTextBox.Text = rippleAddress.DestinationTag;
                }
                else
                {
                    XrpAddressWarning.Visible = false;
                }
            }
        }

        //Ethereum
        if (EthCryptocurrency.WithdrawalEnabled)
        {
            var currentEthereumAddress = CryptocurrencyWithdrawalAddress.GetAddress(User.Id, CryptocurrencyType.ETH);

            if (currentEthereumAddress != null)
            {
                EthAddressTextBox.Text = currentEthereumAddress.Address;
            }
            else
            {
                EthAddressWarning.Visible = false;
            }
        }
    }