Returns the event which contains the corresponding balance proof.

    Use this function to find a balance proof for a call to unlock, which only
    happens after settle, so the channel has the unblinded version of the
    balance proof.

def get_event_with_balance_proof_by_locksroot(
        storage: sqlite.SQLiteStorage,
        canonical_identifier: CanonicalIdentifier,
        locksroot: Locksroot,
        recipient: Address,
) -> sqlite.EventRecord:
    """ Returns the event which contains the corresponding balance proof.

    Use this function to find a balance proof for a call to unlock, which only
    happens after settle, so the channel has the unblinded version of the
    balance proof.
    """
    return storage.get_latest_event_by_data_field({
        'balance_proof.canonical_identifier.chain_identifier': str(
            canonical_identifier.chain_identifier,
        ),
        'balance_proof.canonical_identifier.token_network_address': to_checksum_address(
            canonical_identifier.token_network_address,
        ),
        'balance_proof.canonical_identifier.channel_identifier': str(
            canonical_identifier.channel_identifier,
        ),
        'balance_proof.locksroot': serialize_bytes(locksroot),
        'recipient': to_checksum_address(recipient),
    })