def test_wallet_is_wallet_file_encrypted(self, encrypt_wallet, encrypt_secrets, wallet_factory, wallet_path): wallet = wallet_factory(balance=1000, confirmed=True) wallet.change_passphrase( passphrase="password", encrypt_wallet=encrypt_wallet, encrypt_secrets=encrypt_secrets, ) wallet.save(wallet_path) assert Wallet.is_wallet_file_encrypted(wallet_path) == encrypt_wallet
def wrapper(*args, **kwargs): server = kwargs.get("server", None) passphrase = kwargs.get("passphrase", None) # Convert empty string parameters to None kwargs = { k: None if v == "" else v for k, v in kwargs.items() } try: server.work.validate_config() except ConfigurationError as exc: raise StdioError( "work_configuration_error", "Work plugin has incomplete configuration: {}".format( str(exc) ) ) try: server.network.validate_config() except ConfigurationError as exc: raise StdioError( "network_configuration_error", "Network plugin has incomplete configuration: {}".format( str(exc) ) ) if wallet_required: if not kwargs["wallet_path"]: raise StdioError( "wallet_required", "--wallet is required" ) try: wallet_encrypted = Wallet.is_wallet_file_encrypted( kwargs["wallet_path"] ) if wallet_encrypted and sys.stdout.isatty(): print("Passphrase required to open encrypted wallet.") passphrase = getpass("Passphrase: ") server.load_wallet( path=kwargs["wallet_path"], passphrase=passphrase ) except InvalidEncryptionKey: raise StdioError( "incorrect_passphrase", "Incorrect passphrase" ) except WalletLocked: raise StdioError( "wallet_encrypted", "Wallet is encrypted but no passphrase was provided" ) except WalletFileLocked: raise StdioError( "wallet_locked", "Wallet is locked and in use by another process" ) except WalletFileInvalid: raise StdioError( "wallet_invalid", "Wallet file is invalid. It may be corrupted." ) except WalletMigrationRequired as exc: raise StdioError( "wallet_migration_required", "Wallet file needs to be migrated before it can be " "used. Current version: {}, " "required version: {}".format( exc.wallet_version, exc.required_version ) ) except UnsupportedWalletVersion as exc: raise StdioError( "unsupported_wallet_version", "Wallet file with newer version {} was loaded but " "only {} is supported. The wallet might have been " "created with a newer version of this " "application.".format( exc.wallet_version, exc.required_version ) ) kwargs["server"] = server if start_work: server.start_work() if start_network: server.start_network() try: server.network.wait_for_connection(timeout=5) except TimeoutError: raise StdioError( "network_connection_failure", "Network plugin couldn't establish a connection." ) except UnsupportedProtocolVersion as exc: raise StdioError( "unsupported_protocol_version", "NANO node only supports protocol version " f"{exc.current_version} while " f"protocol version {exc.required_version} is " "required" ) del kwargs["wallet_path"] try: return func(*args, **kwargs) except Exception as exc: # Raise a corresponding StdioError for a common error # if possible raise_common_error(exc)