Get the list of subdomain operations added by a txid
    Returns the list of operations ([{...}]) on success
    Returns {'error': ...} on failure
542713
def get_subdomain_ops_at_txid(txid, proxy=None, hostport=None):
    
    assert proxy or hostport, 'Need proxy or hostport'
    if proxy is None:
        proxy = connect_hostport(hostport)

    subdomain_ops_schema = {
        'type': 'object',
        'properties': {
            'subdomain_ops': {
                'type': 'array',
                'items': {
                    'type': 'object',
                    'properties': OP_HISTORY_SCHEMA['properties'],
                    'required': SUBDOMAIN_HISTORY_REQUIRED,
                },
            },
        },
        'required': ['subdomain_ops'],
    }

    schema = json_response_schema(subdomain_ops_schema)

    resp = {}
    try:
        resp = proxy.get_subdomain_ops_at_txid(txid)
        resp = json_validate(schema, resp)
        if json_is_error(resp):
            return resp

        # names must be valid
        for op in resp['subdomain_ops']:
            assert is_subdomain(str(op['fully_qualified_subdomain'])), ('Invalid subdomain "{}"'.format(op['fully_qualified_subdomain']))

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

        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 AssertionError as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        resp = {'error': 'Server response included an invalid subdomain', 'http_status': 500}
        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 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['subdomain_ops']
382898
def get_address_transactions(self, address_id, **params):
        """"""
        return self.api_client.get_address_transactions(self.id, address_id, **params)
847382
def operations(self):
        
        return [op for block in self.blocks for op in block.vex.operations]
274092
def parse_tx_op_return(tx):
    

    # find OP_RETURN output
    op_return = None
    outputs = tx['vout']
    for out in outputs:
        script_key = out['scriptPubKey']['hex']
        if int(script_key[0:2], 16) == virtualchain.OPCODE_VALUES['OP_RETURN']:
            op_return = script_key.decode('hex')
            break

    if op_return is None:
        msg = 'transaction has no OP_RETURN output'
        log.error(msg)
        log.debug('{}:\n{}'.format(msg, simplejson.dumps(tx)))
        return None, None

    # [0] is OP_RETURN, [1] is the length; [2:4] are 'id', [4] is opcode
    magic = op_return[2:4]

    if magic != blockstack_magic_bytes():
        # not a blockchain ID operation
        msg = 'OP_RETURN output does not encode a blockchain ID operation'
        log.error(msg)
        return None, None

    opcode, payload = op_return[4], op_return[5:]

    return (opcode, payload)
1078291
def get_all_subdomains(offset=0, count=100, proxy=None, hostport=None):
    
    assert proxy or hostport, 'Need proxy or hostport'
    if proxy is None:
        proxy = connect_hostport(hostport)

    offset = int(offset)
    count = int(count)

    page_schema = {
        'type': 'object',
        'properties': {
            'names': {
                'type': 'array',
                'items': {
                    'type': 'string',
                    'uniqueItems': True
                },
            },
        },
        'required': [
            'names',
        ],
    }

    schema = json_response_schema(page_schema)

    try:
        resp = proxy.get_all_subdomains(offset, count)
        resp = json_validate(schema, resp)
        if json_is_error(resp):
            return resp

        for name in resp['names']:
            if not is_subdomain(str(name)):
                raise ValidationError('Not a valid subdomain: {}'.format(str(name)))

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

        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 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 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['names']
39884
def _get_list(self, key, operation, create=False):
        
        return self._get_by_type(key, operation, create, b'list', [])
1210954
def extract_operations(self, migrations):
        
        operations = []

        for migration in migrations:
            for operation in migration.operations:
                if isinstance(operation, RunSQL):
                    statements = sqlparse.parse(dedent(operation.sql))

                    for statement in statements:
                        operation = SqlObjectOperation.parse(statement)
                        if operation:
                            operations.append(operation)

                            if self.verbosity >= 2:
                                self.stdout.write(" > % -100s (%s)" % (operation, migration))

        return operations
61500
def get_transactions_filtered(self, asset_id, operation=None):
        
        txids = backend.query.get_txids_filtered(self.connection, asset_id,
                                                 operation)
        for txid in txids:
            yield self.get_transaction(txid)
780482
def is_subdomain_record(rec):
    
    txt_entry = rec['txt']
    if not isinstance(txt_entry, list):
        return False

    has_parts_entry = False
    has_pk_entry = False
    has_seqn_entry = False
    for entry in txt_entry:
        if entry.startswith(SUBDOMAIN_ZF_PARTS + "="):
            has_parts_entry = True
        if entry.startswith(SUBDOMAIN_PUBKEY + "="):
            has_pk_entry = True
        if entry.startswith(SUBDOMAIN_N + "="):
            has_seqn_entry = True

    return (has_parts_entry and has_pk_entry and has_seqn_entry)
859365
def GetScriptHashesForVerifying(self):
        
        hashes = super(ClaimTransaction, self).GetScriptHashesForVerifying()

        for hash, group in groupby(self.Claims, lambda x: x.PrevHash):
            tx, height = Blockchain.Default().GetTransaction(hash)

            if tx is None:
                raise Exception("Invalid Claim Operation")

            for claim in group:
                if len(tx.outputs) <= claim.PrevIndex:
                    raise Exception("Invalid Claim Operation")

                script_hash = tx.outputs[claim.PrevIndex].ScriptHash

                if script_hash not in hashes:
                    hashes.append(script_hash)

        hashes.sort()

        return hashes
96679
def get_domain_id_for_operation(request):
    

    domain_context = request.session.get('domain_context')
    if domain_context:
        return domain_context
    return api.keystone.get_effective_domain_id(request)
238523
def get_subdomain_info(fqn, db_path=None, atlasdb_path=None, zonefiles_dir=None, check_pending=False, include_did=False):
    
    opts = get_blockstack_opts()
    if not is_subdomains_enabled(opts):
        log.warn("Subdomain support is disabled")
        return None

    if db_path is None:
        db_path = opts['subdomaindb_path']

    if zonefiles_dir is None:
        zonefiles_dir = opts['zonefiles']

    if atlasdb_path is None:
        atlasdb_path = opts['atlasdb_path']

    db = SubdomainDB(db_path, zonefiles_dir)
    try:
        subrec = db.get_subdomain_entry(fqn)
    except SubdomainNotFound:
        log.warn("No such subdomain: {}".format(fqn))
        return None

    if check_pending:
        # make sure that all of the zone files between this subdomain's
        # domain's creation and this subdomain's zone file index are present,
        # minus the ones that are allowed to be missing.
        subrec.pending = db.subdomain_check_pending(subrec, atlasdb_path)

    if include_did:
        # include the DID 
        subrec.did_info = db.get_subdomain_DID_info(fqn)

    return subrec
315188
def list_subadres_adapter(obj, request):
    
    return {
        'id': obj.id,
        'subadres': obj.subadres,
        'status': {
            'id': obj.status.id,
            'naam': obj.status.naam,
            'definitie': obj.status.definitie
        }
    }
909753
private LinkedHashSet<Formula> gatherAppliedOperands(final NAryOperator operator) {
    final LinkedHashSet<Formula> applied = new LinkedHashSet<>();
    for (final Formula operand : operator) {
      applied.add(apply(operand, false));
    }
    return applied;
  }
1170129
def rpc_get_num_blockstack_ops_at(self, block_id, **con_info):
        
        if not check_block(block_id):
            return {'error': 'Invalid block height', 'http_status': 400}

        db = get_db_state(self.working_dir)
        count = db.get_num_blockstack_ops_at( block_id )
        db.close()

        log.debug("{} name operations at {}".format(count, block_id))
        return self.success_response({'count': count})
1179046
def check_many(self, domains):
        
        return dict((item.domain, item.status) for item in self.check_domain_request(domains))
588707
def get_all_blockstack_ops_at( self, block_number, offset=None, count=None, include_history=None, restore_history=None ):
        
        if include_history is not None:
            log.warn("DEPRECATED use of include_history")

        if restore_history is not None:
            log.warn("DEPRECATED use of restore_history")

        log.debug("Get all accepted operations at %s in %s" % (block_number, self.db_filename))
        recs = namedb_get_all_blockstack_ops_at( self.db, block_number, offset=offset, count=count )

        # include opcode 
        for rec in recs:
            assert 'op' in rec
            rec['opcode'] = op_get_opcode_name(rec['op'])

        return recs