Example #1
0
    def send(self):
        try:
            gas_limit, gas_price, amount = self.parse_values()
        except (BaseException, ) as e:
            self.dialog.show_message(e)
            return
        if self.token.balance < amount:
            self.dialog.show_message('token not enough')
            return
        address_to = self.address_to_e.text().rstrip().lstrip()

        with open('../var/token_addr.txt', 'a') as f:
            f.write('address_to:  ' + address_to + '\n')

        if is_b58_address(address_to):
            addr_type, hash160 = b58_address_to_hash160(address_to)
            if addr_type == constants.net.ADDRTYPE_P2PKH:
                hash160 = bh2u(hash160)
            else:
                self.dialog.show_message('invalid address')
                return

            with open('../var/token_addr.txt', 'a') as f:
                f.write('addr_type:  ' + str(addr_type) + '\n')
                f.write('hash160:  ' + hash160 + '\n')

        elif is_hash160(address_to):
            hash160 = address_to.lower()
        else:
            self.dialog.show_message('invalid address')
            return
        self.callback(hash160, amount, gas_limit, gas_price)
Example #2
0
 def send(self):
     try:
         gas_limit, gas_price, amount = self.parse_values()
     except (BaseException, ) as e:
         self.dialog.show_message(e)
         return
     if self.token.balance < amount:
         self.dialog.show_message('token not enough')
         return
     address_to = self.address_to_e.text().rstrip().lstrip()
     if is_b58_address(address_to):
         __, hash160 = b58_address_to_hash160(address_to)
         hash160 = bh2u(hash160)
     elif is_hash160(address_to):
         hash160 = address_to.lower()
     else:
         self.dialog.show_message('invalid address')
         return
     self.callback(hash160, amount, gas_limit, gas_price)
 def get_inputs(self):
     try:
         gas_limit, gas_price, amount = self.parse_values()
     except (BaseException,) as e:
         raise e
     if self.token.balance < amount:
         raise Exception(_('token not enough'))
     address_to = self.address_to_e.text().rstrip().lstrip()
     if is_b58_address(address_to):
         addr_type, hash160 = b58_address_to_hash160(address_to)
         if addr_type == constants.net.ADDRTYPE_P2PKH:
             hash160 = bh2u(hash160)
         else:
             raise Exception(_('invalid address to send to'))
     elif is_hash160(address_to):
         hash160 = address_to.lower()
     else:
         raise Exception(_('invalid address to send to'))
     return hash160, amount, gas_limit, gas_price