def create_keystore_file_of_wallet(keystore_file_path, password): """ create both a wallet and a keystore file :param keystore_file_path: File path for the keystore file of the wallet. :param password: Password including alphabet character, number, and special character. :return: Instance of Wallet class. """ if not validate_password(password): raise PasswordIsNotAcceptable try: signer = IcxSigner() byte_private_key = signer.private_key_bytes key_store_contents = create_keyfile_json(byte_private_key, bytes(password, 'utf-8'), iterations=262144) key_store_contents['address'] = "hx" + signer.address.hex() key_store_contents['coinType'] = 'icx' json_string_keystore_data = json.dumps(key_store_contents) store_wallet(keystore_file_path, json_string_keystore_data) wallet = Wallet(key_store_contents) return wallet, signer.private_key_bytes.hex() except FileExistsError: raise FileExists except PermissionError: raise NoPermissionToWriteFile except FileNotFoundError: raise FilePathIsWrong except IsADirectoryError: raise FilePathWithoutFileName
def open_keystore_file_of_wallet(keystore_file_path, password): """ open the keystore file and read the information of the file :param keystore_file_path: File path for the keystore file of the wallet. :param password: Password including alphabet character, number, and special character. :return Instance of Wallet Class. """ if not validate_password(password): raise PasswordIsNotAcceptable try: validate_key_store_file(keystore_file_path) private_key_bytes = key_from_key_store(keystore_file_path, bytes(password, 'utf-8')) wallet = Wallet(read_wallet(keystore_file_path)) return_value = (wallet, private_key_bytes.hex()) return return_value except FileNotFoundError: raise FilePathIsWrong except ValueError: raise PasswordIsWrong