Look up a name's zonefile, address, and last TXID
        Reply status, zonefile, zonefile hash, address, and last TXID.
        'status' can be 'available', 'registered', 'revoked', or 'pending'

def GET_name_info( self, path_info, name ):
        """
        Look up a name's zonefile, address, and last TXID
        Reply status, zonefile, zonefile hash, address, and last TXID.
        'status' can be 'available', 'registered', 'revoked', or 'pending'
        """
        if not check_name(name) and not check_subdomain(name):
            return self._reply_json({'error': 'Invalid name or subdomain'}, status_code=400)

        blockstackd_url = get_blockstackd_url()

        name_rec = None
        try:
            name_rec = blockstackd_client.get_name_record(name, include_history=False, hostport=blockstackd_url)
        except ValueError:
            return self._reply_json({'error': 'Invalid argument: not a well-formed name or subdomain'}, status_code=400)

        if 'error' in name_rec:
            if 'not found' in name_rec['error'].lower():
                return self._reply_json({'status': 'available'}, status_code=404)

            elif 'failed to load subdomain' in name_rec['error'].lower():

                # try to redirect to resolver, if given
                _, _, domain_name = blockstackd_scripts.is_address_subdomain(name)
                domain_rec = blockstackd_client.get_name_record(domain_name, include_history=False, hostport=blockstackd_url)

                if 'error' in domain_rec:
                    # no resolver known for on-chain name
                    return self._reply_json({'status': 'available', 'more': 'failed to look up parent domain'}, status_code=404)

                resolver_target = domain_rec.get('resolver', None)
                if resolver_target is None:
                    # no _resolver
                    return self._reply_json({'status': 'available',  'more': 'failed to find parent domain\'s resolver'}, status_code=404)

                redirect_location = resolver_target + '/v1/names/' + name
                log.debug("Redirect lookup on {} to {}".format(name, redirect_location))

                self._send_headers(status_code=301, more_headers={ 'Location': redirect_location })
                return self.wfile.write(json.dumps({'status': 'redirect'}))

            elif 'expired' in name_rec['error'].lower():
                return self._reply_json({'error': name_rec['error']}, status_code=404)

            else:
                return self._reply_json({'error': 'Blockstack daemon error: {}'.format(name_rec['error'])}, status_code=name_rec.get('http_status', 502))


        zonefile_txt = None

        if 'zonefile' in name_rec:
            zonefile_txt = base64.b64decode(name_rec['zonefile'])

        ret = {}

        if blockstackd_scripts.is_subdomain(name):
            # subdomain
            address = name_rec['address']
            if address:
                address = virtualchain.address_reencode(str(address))

            log.debug("{} is registered_subdomain".format(name))
            ret = {
                'status': 'registered_subdomain',
                'zonefile': zonefile_txt,
                'zonefile_hash': name_rec['value_hash'],
                'address': name_rec['address'],
                'blockchain': 'bitcoin',
                'last_txid': name_rec['txid'],
                'did': name_rec.get('did', {'error': 'Not supported for this name'})
            }

        else:
            status = 'revoked' if name_rec['revoked'] else 'registered'
            address = name_rec['address']
            if address:
                address = virtualchain.address_reencode(str(address))

            log.debug("{} is {}".format(name, status))
            ret = {
                'status': status,
                'zonefile': zonefile_txt,
                'zonefile_hash': name_rec['value_hash'],
                'address': address,
                'last_txid': name_rec['txid'],
                'blockchain': 'bitcoin',
                'expire_block': name_rec['expire_block'],      # expire_block is what blockstack.js expects
                'renewal_deadline': name_rec['renewal_deadline'],
                'grace_period': name_rec.get('grace_period', False),
                'resolver': name_rec.get('resolver', None),
                'did': name_rec.get('did', {'error': 'Not supported for this name'})
            }

        return self._reply_json(ret)