namespace_cost
    Returns the namespace cost info on success.
    Returns {'amount': ..., 'units': ...} on success (optionally with 'satoshis': ... if the namespace is priced in BTC)
    Returns {'error': ...} on error

def get_namespace_cost(namespace_id, proxy=None, hostport=None):
    """
    namespace_cost
    Returns the namespace cost info on success.
    Returns {'amount': ..., 'units': ...} on success (optionally with 'satoshis': ... if the namespace is priced in BTC)
    Returns {'error': ...} on error
    """
    assert proxy or hostport, 'Need proxy or hostport'
    if proxy is None:
        proxy = connect_hostport(hostport)

    cost_schema_v1 = {
        'type': 'object',
        'properties': {
            'satoshis': {
                'type': 'integer',
                'minimum': 0,
            },
        },
        'required': [
            'satoshis'
        ],
    }

    cost_schema_v2 = {
        'type': 'object',
        'properties': {
            'units': {
                'type': 'string',
                'pattern': '^BTC$|^{}$'.format(TOKEN_TYPE_STACKS),
            },
            'amount': {
                'type': 'integer',
                'minimum': 0,
            },
        },
        'required': [
            'units',
            'amount',
        ],
    }

    schema_v1 = json_response_schema(cost_schema_v1)
    schema_v2 = json_response_schema(cost_schema_v2)

    resp = {}
    try:
        resp = proxy.get_namespace_cost(namespace_id)
        try:
            resp = json_validate(cost_schema_v2, resp)
        except:
            resp = json_validate(cost_schema_v1, resp)
            if not json_is_error(resp):
                resp = {'units': 'BTC', 'amount': resp['satoshis']}

        if json_is_error(resp):
            return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except ValidationError as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return resp