Beispiel #1
0
    def purchase(self, user_settings, wallet):
        # Prepare for the purchase on the AzireVPN website
        self._register(user_settings)
        self._login(user_settings)
        page = self._order(user_settings, wallet)

        # Make the payment
        print("Purchasing AzireVPN instance")
        amount, address = self.gateway.extract_info(page.url)
        print(('Paying %s BTC to %s' % (amount, address)))
        fee = wallet_util.get_network_fee()
        print(('Calculated fee: %s' % fee))
        transaction_hash = wallet.pay(address, amount, fee)
        print('Done purchasing')
        return transaction_hash
Beispiel #2
0
    def pay(cls, wallet, gateway, url):
        """Do a payment (should be moved to the payment gateways?)

        :param wallet: the wallet to pay with
        :param gateway: gateway through which to make the payment
        :param url: url from which the amount and address can be extracted
        """
        name, _ = cls.get_metadata()

        # Make the payment
        print("Purchasing {} instance".format(name))
        info = gateway.extract_info(url)
        print(('Paying %s BTC to %s' % (info.amount, info.address)))
        fee = wallet_util.get_network_fee()
        print(('Calculated fee: %s' % fee))
        transaction_hash = wallet.pay(info.address, info.amount, fee)
        print('Done purchasing')
        return transaction_hash
Beispiel #3
0
    def print_options(self, options):
        bandwidth = "Unlimited" if options.bandwidth == sys.maxsize else options.bandwidth
        speed = "Unlimited" if options.speed == sys.maxsize else options.speed

        # Calculate the estimated price
        rate = wallet_util.get_rate("USD")
        fee = wallet_util.get_network_fee()
        estimate = self.gateway.estimate_price(
            options.price * rate) + fee  # BTC
        estimate = round(1000 * estimate, 2)  # mBTC

        # Print everything
        row = "{:18}" * 6
        print(
            row.format("Name", "Protocol", "Bandwidth", "Speed",
                       "Est. Price (mBTC)", "Price (USD)"))
        print(
            row.format(options.name, options.protocol, bandwidth, speed,
                       str(estimate), str(options.price)))
    def pay(self, amount, address, coin_type, wallet):
        #Pay amount using specified COIN wallet, if their is not enough balance available print "Not enough balance for the specified COIN-payment"

        print("\nPayment process of " + str(amount) + " of " + str(coin_type) +
              " to " + str(address) + " started")
        if coin_type == 'BTC':
            print("\nConnecting to bitcoin wallet")
            print("\nChecking Balance...")
            fee = bitcoin_wallet_util.get_network_fee()
        elif coin_type == 'ETH':
            print("\nConnecting to bitcoin wallet")
            print("\nChecking Balance...")
            fee = ethereum_wallet_util.get_network_fee()
        if (wallet.get_balance() >= fee + float(amount)):
            transaction_hash = wallet.pay(address, amount, fee)
            print('Done purchasing')
            return transaction_hash
        else:
            print(" Not enough " + str(coin_type))
Beispiel #5
0
def _options_vpn_bitcoin(provider):
    name, _ = provider.get_metadata()
    print(("Options for %s:\n" % name))
    options = provider.get_options()

    # Print heading
    row = "{:18}" * 6
    print(row.format("Name", "Protocol", "Bandwidth", "Speed", "Est. Price (mBTC)", "Price (USD)"))

    for option in options:
        bandwidth = "Unlimited" if option.bandwidth == sys.maxsize else str(option.bandwidth)
        speed = "Unlimited" if option.speed == sys.maxsize else option.speed

        # Calculate the estimated price for Bitcoin
        rate = bitcoin_wallet_util.get_rate("USD")
        fee = bitcoin_wallet_util.get_network_fee()
        gateway = provider.get_gateway()
        estimate = gateway.estimate_price(option.price * rate) + fee  # BTC
        estimate = round(1000 * estimate, 2)  # mBTC

        print(row.format(option.name, option.protocol, bandwidth, speed, str(estimate), str(option.price)))
Beispiel #6
0
def _options_vps_bitcoin(p):
    name, _ = p.get_metadata()
    print(("Options for %s:\n" % name))
    options = p.get_options()

    # Print heading
    row = "{:<5}" + "{:20}" * 8
    print(row.format("#", "Name", "Cores", "Memory (GB)", "Storage (GB)", "Bandwidth", "Connection (Gbit/s)",
                     "Est. Price (mBTC)", "Price (USD)"))

    for i, option in enumerate(options):
        bandwidth = "Unlimited" if option.bandwidth == sys.maxsize else str(option.bandwidth)

        # Calculate the estimated price for Bitcoin
        rate = bitcoin_wallet_util.get_rate("USD")
        fee = bitcoin_wallet_util.get_network_fee()
        gateway = p.get_gateway()
        estimate = gateway.estimate_price(option.price * rate) + fee  # BTC
        estimate = round(1000 * estimate, 2)  # mBTC

        print(row.format(i, option.name, str(option.cores), str(option.memory), str(option.storage), bandwidth,
                         str(option.connection), str(estimate), str(option.price)))