def validate_pow_address(address: str) -> Union[None, bool]: """ Validate a bis (PoW address). :param address: :return: True if address is valid, raise a ValueError exception if not. """ # TODO!: To evolve with more addresses # if re.match("[abcdef0123456789]{56}", address): if SignerFactory.address_is_valid(address): return True raise ValueError("Bis Address format error: {}".format(address))
def api_getaddressinfo(self, socket_handler, db_handler, peers): """ Returns a dict with known: Did that address appear on a transaction? pubkey: The pubkey of the address if it signed a transaction, :param address: The bismuth address to examine :return: dict """ info = {'known': False, 'pubkey': ''} # get the address address = connections.receive(socket_handler) # print('api_getaddressinfo', address) try: # format check if not SignerFactory.address_is_valid(address): self.app_log.info("Bad address format <{}>".format(address)) connections.send(socket_handler, info) return try: db_handler.execute_param(db_handler.h, ( 'SELECT block_height FROM transactions WHERE address= ? or recipient= ? LIMIT 1;' ), (address, address)) _ = db_handler.h.fetchone()[0] # no exception? then we have at least one known tx info['known'] = True db_handler.execute_param(db_handler.h, ( 'SELECT public_key FROM transactions WHERE address= ? and reward = 0 LIMIT 1;' ), (address, )) try: info['pubkey'] = db_handler.h.fetchone()[0] info['pubkey'] = base64.b64decode( info['pubkey']).decode('utf-8') except Exception as e: self.app_log.warning(e) except Exception as e: self.app_log.warning(e) # returns info # print("info", info) connections.send(socket_handler, info) except Exception as e: self.app_log.warning(e)
def address_validate(address: str) -> bool: return SignerFactory.address_is_valid(address)
balance = stats_account[0] print("Transaction address: %s" % address) print("Transaction address balance: %s" % balance) try: amount_input = sys.argv[1] except IndexError: amount_input = input("Amount: ") try: recipient_input = sys.argv[2] except IndexError: recipient_input = input("Recipient: ") if not SignerFactory.address_is_valid(recipient_input): print("Wrong address format") sys.exit(1) try: operation_input = sys.argv[3] except IndexError: operation_input = "" try: openfield_input = sys.argv[4] except IndexError: openfield_input = "" fee = fee_calculate(openfield_input) print("Fee: %s" % fee)