def parse(bin_payload, block_height):
    """
    Parse a token transfer
    NOTE: bin_payload *excludes* the leading 3 bytes (magic + op) returned by build.

    Record format:
   
    0     2  3              19         38          46                        80
    |-----|--|--------------|----------|-----------|-------------------------|
    magic op  consensus_hash token_type amount (BE) scratch area
                             (ns_id)

    Returns a parsed payload on success
    Returns None on error
    """
    
    epoch_features = get_epoch_features(block_height)
    if EPOCH_FEATURE_TOKEN_TRANSFER not in epoch_features:
        log.warning("Token transfers are not enabled in this epoch")
        return None

    if len(bin_payload) < LENGTHS['consensus_hash'] + LENGTHS['namespace_id'] + LENGTHS['tokens_burnt']:
        log.warning('Invalid payload {}: expected at least {} bytes'.format(bin_payload.encode('hex'), LENGTHS['consensus_hash'] + LENGTHS['namespace_id'] + LENGTHS['tokens_burnt']))
        return None

    consensus_hash = bin_payload[0: LENGTHS['consensus_hash']].encode('hex')
    token_type = bin_payload[LENGTHS['consensus_hash']: LENGTHS['consensus_hash'] + LENGTHS['namespace_id']]
    amount_str = bin_payload[LENGTHS['consensus_hash'] + LENGTHS['namespace_id']: LENGTHS['consensus_hash'] + LENGTHS['namespace_id'] + LENGTHS['tokens_burnt']].encode('hex')
    scratch_area = bin_payload[LENGTHS['consensus_hash'] + LENGTHS['namespace_id'] + LENGTHS['tokens_burnt']: ].encode('hex')

    tokens_sent = int(amount_str, 16)
    token_units = token_type.strip('\x00')

    return {
        'opcode': 'TOKEN_TRANSFER',
        'consensus_hash': consensus_hash,
        'token_units': token_units,
        'token_fee': tokens_sent,
        'scratch_area': scratch_area
    }
Parse a token transfer
    NOTE: bin_payload *excludes* the leading 3 bytes (magic + op) returned by build.

    Record format:
   
    0     2  3              19         38          46                        80
    |-----|--|--------------|----------|-----------|-------------------------|
    magic op  consensus_hash token_type amount (BE) scratch area
                             (ns_id)

    Returns a parsed payload on success
    Returns None on error