Beispiel #1
0
    def call_signed_contract(self, signed_tx, pre=True, node_index=None):
        sendrawtxtask = Task(Config.BASEAPI_PATH +
                             "/rpc/sendrawtransaction.json")
        if pre:
            sendrawtxtask.request()["params"] = [signed_tx, 1]
        else:
            sendrawtxtask.request()["params"] = [signed_tx]

        if node_index != None:
            sendrawtxtask.data()["NODE_INDEX"] = node_index

        (result,
         response) = TaskRunner.run_single_task(sendrawtxtask, True, False)

        sendrawtxtask.data()["RESPONSE"] = response

        if not response is None and ("result" in response and "Result"
                                     in response["result"]) and not isinstance(
                                         response["result"]["Result"], list):
            response["result"]["Result String"] = HexToByte(
                response["result"]["Result"]).decode('iso-8859-1')

        logger.print("[ CALL CONTRACT ] " +
                     json.dumps(sendrawtxtask.data(), indent=4))

        return (result, response)
	def getblocktxsbyheight(self, height):
		task = Task(Config.BASEAPI_PATH + "/restful/get_blk_txs_by_height.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/block/transactions/height/" + str(height)
		task.set_request(taskrequest)
		return run_single_task(task)
Beispiel #3
0
 def getblockbyheight(self, height):
     task = Task(Config.BASEAPI_PATH + "/restful/get_blk_by_height.json")
     task.set_type("restful")
     taskrequest = task.request()
     taskrequest["api"] = "/api/v1/block/details/height/" + str(height)
     task.set_request(taskrequest)
     return TaskRunner.run_single_task(task)
	def gettransactionbytxhash(self, _hash, raw = 0):
		task = Task(Config.BASEAPI_PATH + "/restful/get_tx.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/transaction/" + str(_hash) + "?raw=" + str(raw)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getmerkleproofbytxhash(self, _hash):
		task = Task(Config.BASEAPI_PATH + "/restful/get_merkle_proof.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/merkleproof/"+ str(_hash)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getstorage(self, script_hash, key):
		task = Task(Config.BASEAPI_PATH + "/restful/get_storage.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/storage/"+ str(script_hash) + "/" + str(key)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getsmartcodeeventbyhash(self, txhash):
		task = Task(Config.BASEAPI_PATH + "/restful/get_smtcode_evts.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/smartcode/event/txhash/"+ str(txhash)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getblockheightbytxhash(self, txhash):
		task = Task(Config.BASEAPI_PATH + "/restful/get_blk_hgt_by_txhash.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/block/height/txhash/"+ str(txhash)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getcontract(self, script_hash):
		task = Task(Config.BASEAPI_PATH + "/restful/get_contract_state.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/contract/"+ str(script_hash)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getsmartcodeeventbyheight(self, height):
		task = Task(Config.BASEAPI_PATH + "/restful/get_smtcode_evt_txs.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/smartcode/event/transactions/"+ str(height)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getbalance(self, addr):
		task = Task(Config.BASEAPI_PATH + "/restful/get_balance.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/balance/"+ str(addr)
		task.set_request(taskrequest)
		return run_single_task(task)
Beispiel #12
0
 def getbestblockhash(self):
     task = Task(Config.BASEAPI_PATH + "/rpc/getbestblockhash.json")
     taskrequest = task.request()
     params = []
     taskrequest["params"] = params
     task.set_request(taskrequest)
     return run_single_task(task)
	def getblockhashbyheight(self, height):
		task = Task(Config.BASEAPI_PATH + "/restful/get_blk_hash.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/block/hash/" + str(height)
		task.set_request(taskrequest)
		return run_single_task(task)
	def getblockbyhash(self, _hash, raw = 0):
		task = Task(Config.BASEAPI_PATH + "/restful/get_blk_by_hash.json")
		task.set_type("restful")
		taskrequest = task.request()
		taskrequest["api"] = "/api/v1/block/details/hash/" + str(_hash) + "?raw="  + str(raw)
		task.set_request(taskrequest)
		return run_single_task(task)
Beispiel #15
0
 def getmerkleproof(self, tx_hash):
     task = Task(Config.BASEAPI_PATH + "/rpc/getmerkleproof.json")
     taskrequest = task.request()
     params = []
     if tx_hash != None:
         params.append(tx_hash)
     taskrequest["params"] = params
     return run_single_task(task)
Beispiel #16
0
 def getbalance(self, address):
     task = Task(Config.BASEAPI_PATH + "/rpc/getbalance.json")
     taskrequest = task.request()
     params = []
     if address != None:
         params.append(address)
     taskrequest["params"] = params
     return run_single_task(task)
Beispiel #17
0
 def test_normal_095_getmerkleproof(self):
     try:
         task = Task(testpath + "/resource/rpc/95_getmerkleproof.json")
         task.request()["params"] = [test_config.m_txhash_right]
         (process, response) = TaskRunner.run_single_task(task)
         self.ASSERT(process, "")
     except Exception as e:
         logger.print(e.args[0])
Beispiel #18
0
    def getsmartcodeeventbyheight(self, height):
        task = Task(Config.BASEAPI_PATH + "/ws/getsmartcodeeventbyheight.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Height"] = height
        task.set_request(taskrequest)
        return TaskRunner.run_single_task(task)
    def getmerkleproof(self, _hash):
        task = Task(Config.BASEAPI_PATH + "/ws/getmerkleproof.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Hash"] = _hash
        task.set_request(taskrequest)
        return run_single_task(task)
    def getblocktxsbyheight(self, height):
        task = Task(Config.BASEAPI_PATH + "/ws/getblocktxsbyheight.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Height"] = height
        task.set_request(taskrequest)
        return run_single_task(task)
    def getsmartcodeeventbyhash(self, _hash):
        task = Task(Config.BASEAPI_PATH + "/ws/getsmartcodeeventbyhash.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Hash"] = _hash
        task.set_request(taskrequest)
        return run_single_task(task)
    def getblockheightbytxhash(self, _hash):
        task = Task(Config.BASEAPI_PATH + "/ws/getblockheightbytxhash.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Hash"] = _hash
        task.set_request(taskrequest)
        return run_single_task(task)
Beispiel #23
0
    def getcontract(self, _hash):
        task = Task(Config.BASEAPI_PATH + "/ws/getcontract.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Hash"] = _hash
        task.set_request(taskrequest)
        return TaskRunner.run_single_task(task)
    def getbalancebyaddr(self, addr):
        task = Task(Config.BASEAPI_PATH + "/ws/getbalance.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Addr"] = addr
        task.set_request(taskrequest)
        return run_single_task(task)
    def getblockbyhash(self, _hash, raw=0):
        task = Task(Config.BASEAPI_PATH + "/ws/getblockbyhash.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Raw"] = raw
        taskrequest["Hash"] = _hash
        task.set_request(taskrequest)
        return run_single_task(task)
    def getstorage(self, _hex, key):
        task = Task(Config.BASEAPI_PATH + "/ws/getstorage.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Hash"] = _hex
        taskrequest["Key"] = key
        task.set_request(taskrequest)
        return run_single_task(task)
    def sendrawtransaction(self, _hex, pre=0):
        task = Task(Config.BASEAPI_PATH + "/ws/sendrawtransaction.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Data"] = _hex
        taskrequest["PreExec"] = pre
        task.set_request(taskrequest)
        return run_single_task(task)
Beispiel #28
0
    def getblockheightbytxhash(self, tx_hash):
        task = Task(Config.BASEAPI_PATH + "/rpc/getblockheightbytxhash.json")
        taskrequest = task.request()
        params = []
        if tx_hash != None:
            params.append(tx_hash)
        taskrequest["params"] = params

        return run_single_task(task)
Beispiel #29
0
    def gettransaction(self, _hash, raw=0):
        task = Task(Config.BASEAPI_PATH + "/ws/gettransaction.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Hash"] = _hash
        taskrequest["Raw"] = raw
        task.set_request(taskrequest)
        return TaskRunner.run_single_task(task)
Beispiel #30
0
    def getblockbyheight(self, height, raw=0):
        task = Task(Config.BASEAPI_PATH + "/ws/getblockbyheight.json")
        task.set_type("ws")

        taskrequest = task.request()
        taskrequest["Raw"] = raw
        taskrequest["Height"] = height
        task.set_request(taskrequest)
        return TaskRunner.run_single_task(task)