示例#1
0
    def print_full_account_info(self):
        """
        Displays all saved addresses and there balance

        :return:
        """
        self.update_addresses_balance(
            self._data['account_data'][0]['fal_balance'][0]["f_index"])
        self._update_fal_balance()
        if len(self._data['account_data'][0]['address_data']) > 0:
            all_address_data = ""
            for p in self._data['account_data'][0]['address_data']:
                address = p["address"]
                checksum = p["checksum"]
                balance = int(p["balance"])
                integrity = verify_checksum(checksum, address, self._seed)
                if integrity:
                    data = "Index: " + str(p["index"]) + "   " + p["address"] + \
                           "   balance: " + convert_units(balance, self._data['account_data'][0]['settings'][0]['units']) + "\n"
                    all_address_data += data

                else:
                    data = "Index: " + str(
                        p["index"]) + "   Invalid Checksum!!!" + "\n"
                    all_address_data += data

            print(all_address_data)
            fal_data = "First index with balance: " + str(
                self._data['account_data'][0]['fal_balance'][0]
                ["f_index"]) + "\n" + "Last index with balance is: " + str(
                    self._data['account_data'][0]['fal_balance'][0]["l_index"])
            print(fal_data)
        else:
            print("No Data to display!")
示例#2
0
    def deposit_address(self):
        """
        Return deposit address of account
        :return:
        """
        if self.l_index == 0:
            if len(self.addresses) > 0:
                return self.addresses[0]

            for a in self.addresses:
                integrity = verify_checksum(a.checksum, a.address, self.seed)
                if a.index > self.l_index and integrity:
                    return a
                elif not integrity:
                    raise Exception('Integrity error')

            self._generate_addresses(1)
            for a in self.addresses:
                integrity = verify_checksum(a.checksum, a.address, self.seed)
                if a.index > self.l_index and integrity:
                    return a
示例#3
0
    def print_standard_account_info(self):
        """
        Displays all addresses with balance, the total account balance and a deposit address.
        In case that there are no saved addresses it will ask if the account should be scanned for balance
        If the User answers with no, then it will just generate a deposit address (at index 0)

        :return:
        """
        address_count = len(self._data['account_data'][0]['address_data'])
        self.update_addresses_balance(
            self._data['account_data'][0]['fal_balance'][0]["f_index"])
        self._update_fal_balance()

        if address_count < 1:
            self.find_balance(10)
            self.print_standard_account_info()

        elif address_count > 0:
            all_address_data = ""
            total_balance = 0
            for p in self._data['account_data'][0]['address_data']:
                balance = p["balance"]
                address = p["address"]
                checksum = p["checksum"]
                integrity = verify_checksum(checksum, address, self._seed)
                if balance > 0 and integrity:
                    total_balance += balance
                    data = "Index: " + str(
                        p["index"]
                    ) + "   " + address + "   balance: " + convert_units(
                        balance, self._data['account_data'][0]['settings'][0]
                        ['units']) + "\n"
                    all_address_data += data

                elif not integrity:
                    total_balance += balance
                    data = "Index: " + str(
                        p["index"]) + "   Invalid Checksum!!!" + "\n"
                    all_address_data += data

            if total_balance > 0:
                print(all_address_data)
                print("\n" + "Deposit address: " +
                      str(self.get_deposit_address()))
                print("\nTotal Balance: " + convert_units(
                    total_balance, self._data['account_data'][0]['settings'][0]
                    ['units']))

            else:
                print("No addresses with balance!")
                print("\n" + "Deposit address: " +
                      str(self.get_deposit_address()))
示例#4
0
    def get_deposit_address(self):
        """
        Gets the first address after the last address with balance. If there is no saved address it will generate a new one

        :return:
        """
        try:
            l_index = self._data['account_data'][0]['fal_balance'][0][
                "l_index"]
            if l_index == 0:
                deposit_address = self._data['account_data'][0][
                    'address_data'][0]["address"]
                return deposit_address

            for p in self._data['account_data'][0]['address_data']:
                address = p["address"]
                checksum = p["checksum"]
                integrity = verify_checksum(checksum, address, self._seed)
                if p["index"] > l_index and integrity:
                    deposit_address = p["address"]
                    return deposit_address
                elif not integrity:
                    return "Invalid checksum!!!"
            self._logger.info("Generating address...")
            self.generate_addresses(1)

            for p in self._data['account_data'][0]['address_data']:
                address = p["address"]
                checksum = p["checksum"]
                integrity = verify_checksum(checksum, address, self._seed)
                if p["index"] > l_index and integrity:
                    deposit_address = p["address"]
                    return deposit_address

        except Exception as ex:
            self._logger.critical(
                "An error acoured while trying to get the deposit address")
            raise ex