Find out how many tokens were paid for this nameop, if any.
    You need to have called state_create_put_preorder() *before* calling this on a NAME_REGISTRATION.

    Return {'status': True, 'token_units': ..., 'tokens_paid': ...} on success
    Return {'status': False} on error (i.e. this is not the right kind of namespace, there is not enough balance, there were no tokens paid, etc.)
    Throw exception on fatal error

def get_stacks_payment(state_engine, nameop, state_op_type):
    """
    Find out how many tokens were paid for this nameop, if any.
    You need to have called state_create_put_preorder() *before* calling this on a NAME_REGISTRATION.

    Return {'status': True, 'token_units': ..., 'tokens_paid': ...} on success
    Return {'status': False} on error (i.e. this is not the right kind of namespace, there is not enough balance, there were no tokens paid, etc.)
    Throw exception on fatal error
    """
    token_units = None
    tokens_paid = None
    name = nameop['name']
    token_fee = nameop.get('token_fee', None)
    tokens_paid = None

    assert token_fee is None or isinstance(token_fee, (int,long)), 'Invalid token fee {} ({})'.format(token_fee, type(token_fee))
    
    namespace_id = get_namespace_from_name(name)
    name_without_namespace = get_name_from_fq_name(name)
    namespace = state_engine.get_namespace(namespace_id)

    if state_op_type == 'NAME_REGISTRATION':
        # STACKs would already have been paid by a preorder.
        # find out how much, if any
        preorder = state_create_get_preorder(nameop)
        assert preorder, 'BUG: no preorder set'
        assert 'token_fee' in preorder, 'BUG: no token_fee set in preorder'
        assert 'token_units' in preorder, 'BUG: no token_units set in preorder'

        token_units = preorder['token_units']
        tokens_paid = preorder['token_fee']

        # must have paid STACKs
        if token_units != TOKEN_TYPE_STACKS:
            return {'status': False, 'error': 'Name {} paid for in {}, not {}'.format(name, token_units, TOKEN_TYPE_STACKS)}

    elif state_op_type == 'NAME_RENEWAL':
        # will have paid in Stacks in the nameop (but not yet debited the account, so we'll need to 
        # check the account balance later on in check_renewal())
        if token_fee is None or token_fee == 0:
            return {'status': False, 'error': 'No token fee given for {}'.format(name)}

        token_units = TOKEN_TYPE_STACKS
        tokens_paid = token_fee

    else:
        raise Exception("Unknown state operation type {}".format(state_op_type))

    return {'status': True, 'tokens_paid': tokens_paid, 'token_units': token_units}