https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblockhashandindex

        :param bhash: Block hash
        :type bhash: str

        :param index: Index position (optional)
        :type index: int
189443
def eth_getTransactionByBlockHashAndIndex(self, bhash, index=0):
        
        result = yield from self.rpc_call('eth_getTransactionByBlockHashAndIndex',
                                          [bhash, hex(index)])
        # TODO: Update result response
        return result
358455
func (rpc *EthRPC) EthGetTransactionByBlockHashAndIndex(blockHash string, transactionIndex int) (*Transaction, error) {
	return rpc.getTransaction("eth_getTransactionByBlockHashAndIndex", blockHash, IntToHex(transactionIndex))
}
1160278
def GET_blockchain_ops( self, path_info, blockchain_name, blockheight ):
        
        try:
            blockheight = int(blockheight)
            assert check_block(blockheight)
        except:
            return self._reply_json({'error': 'Invalid block'}, status_code=400)

        if blockchain_name != 'bitcoin':
            # not supported
            return self._reply_json({'error': 'Unsupported blockchain'}, status_code=404)
        
        blockstackd_url = get_blockstackd_url()
        nameops = blockstackd_client.get_blockstack_transactions_at(int(blockheight), hostport=blockstackd_url)
        if json_is_error(nameops):
            # error
            status_code = nameops.get('http_status', 502)
            return self._reply_json({'error': nameops['error']}, status_code=status_code)

        self._reply_json(nameops)
        return
1021445
def _get_block_number(self, block_hash):
        
        number_key = block_hash_prefix + block_hash
        return self.db.get(number_key)
744581
def _checkAndConvertIndex(self, index):
        
        if index < 0:
            index = len(self) + index
        if index < 0 or index >= self._doc.blockCount():
            raise IndexError('Invalid block index', index)
        return index
655116
def get_consensus_hashes(block_heights, hostport=None, proxy=None):
    
    assert proxy or hostport, 'Need proxy or hostport'
    if proxy is None:
        proxy = connect_hostport(hostport)

    consensus_hashes_schema = {
        'type': 'object',
        'properties': {
            'consensus_hashes': {
                'type': 'object',
                'patternProperties': {
                    '^([0-9]+)$': {
                        'type': 'string',
                        'pattern': OP_CONSENSUS_HASH_PATTERN,
                    },
                },
            },
        },
        'required': [
            'consensus_hashes',
        ],
    }

    resp_schema = json_response_schema( consensus_hashes_schema )
    resp = {}
    try:
        resp = proxy.get_consensus_hashes(block_heights)
        resp = json_validate(resp_schema, resp)
        if json_is_error(resp):
            log.error('Failed to get consensus hashes for {}: {}'.format(block_heights, resp['error']))
            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 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

    consensus_hashes = resp['consensus_hashes']

    # hard to express as a JSON schema, but the format is thus:
    # { block_height (str): consensus_hash (str) }
    # need to convert all block heights to ints

    try:
        ret = {int(k): v for k, v in consensus_hashes.items()}
        log.debug('consensus hashes: {}'.format(ret))
        return ret
    except ValueError:
        return {'error': 'Server returned invalid data: expected int', 'http_status': 503}
135392
def tx_for_tx_hash(self, tx_hash):
        
        try:
            url_append = "?token=%s&includeHex=true" % self.api_key
            url = self.base_url("txs/%s%s" % (b2h_rev(tx_hash), url_append))
            result = json.loads(urlopen(url).read().decode("utf8"))
            tx = Tx.parse(io.BytesIO(h2b(result.get("hex"))))
            return tx
        except Exception:
            raise Exception
649096
def parity_get_pending_transaction_hash_by_nonce(
            self,
            address: AddressHex,
            nonce: Nonce,
    ) -> Optional[TransactionHash]:
        
        assert self.eth_node is constants.EthClient.PARITY
        # https://wiki.parity.io/JSONRPC-parity-module.html?q=traceTransaction#parity_alltransactions
        transactions = self.web3.manager.request_blocking('parity_allTransactions', [])
        log.debug('RETURNED TRANSACTIONS', transactions=transactions)
        for tx in transactions:
            address_match = to_checksum_address(tx['from']) == address
            if address_match and int(tx['nonce'], 16) == nonce:
                return tx['hash']
        return None
378867
def get_prev_block_hash(block_representation, coin_symbol='btc', api_key=None):
    '''
    
    '''
    return get_block_overview(block_representation=block_representation,
            coin_symbol=coin_symbol, txn_limit=1, api_key=api_key)['prev_block']
1253860
def query(self, out_trade_no, bill_type='MCHT'):
        
        data = {
            'mch_billno': out_trade_no,
            'bill_type': bill_type,
            'appid': self.appid,
        }
        return self._post('mmpaymkttransfers/gethbinfo', data=data)
1169907
def namedb_get_value_hash_txids(cur, value_hash):
    
    query = 'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;'
    args = (value_hash,)

    rows = namedb_query_execute(cur, query, args)
    txids = []
    
    for r in rows:
        # present
        txid = str(r['txid'])
        txids.append(txid)

    return txids
803596
def getBlock(self, block_identifier, full_transactions=False):
        
        method = select_method_for_block_identifier(
            block_identifier,
            if_predefined='eth_getBlockByNumber',
            if_hash='eth_getBlockByHash',
            if_number='eth_getBlockByNumber',
        )

        result = self.web3.manager.request_blocking(
            method,
            [block_identifier, full_transactions],
        )
        if result is None:
            raise BlockNotFound(f"Block with id: {block_identifier} not found.")
        return result
1126427
def get_current_block_hash(self, is_full: bool = False) -> str:
        
        payload = self.generate_json_rpc_payload(RpcMethod.GET_CURRENT_BLOCK_HASH)
        response = self.__post(self.__url, payload)
        if is_full:
            return response
        return response['result']
362088
def get_hash(self, handle):
        
        response = self.open_url(url=handle, suffix='.hash')
        try:
            return response.read()
        finally:
            response.close()
201932
def getUncleByBlock(self, block_identifier, uncle_index):
        
        method = select_method_for_block_identifier(
            block_identifier,
            if_predefined='eth_getUncleByBlockNumberAndIndex',
            if_hash='eth_getUncleByBlockHashAndIndex',
            if_number='eth_getUncleByBlockNumberAndIndex',
        )
        result = self.web3.manager.request_blocking(
            method,
            [block_identifier, uncle_index],
        )
        if result is None:
            raise BlockNotFound(
                f"Uncle at index: {uncle_index} of block with id: {block_identifier} not found."
            )
        return result
401167
def tx_for_tx_hash(self, tx_hash):
        ""
        url = self.base_url("get_tx", b2h_rev(tx_hash))
        r = json.loads(urlopen(url).read().decode("utf8"))
        tx = Tx.parse(io.BytesIO(h2b(r.get("data").get("tx_hex"))))
        return tx
682213
def token(cls: Type[XHXType], sha_hash: str) -> XHXType:
        
        xhx = cls()
        xhx.sha_hash = sha_hash
        return xhx