import json


def wallet_to_str(wallet):
    """
    Convenience function to convert a Wallet instance to a JSON-encoded string.
    This is more performant for transferring the wallet to the mocked
    HTTP server.
    """
    if wallet is None:
        return None

    return json.dumps(wallet.to_dict(wallet))