async def blockchain_transaction_get(self, writer, query): # pylint: disable=W0613 """Method: blockchain.transaction.get Return a raw transaction. """ if "params" not in query or len(query["params"]) < 1: return JsonRPCError.invalidparams() tx_hash = query["params"][0] verbose = query["params"][1] if len(query["params"]) > 1 else False # _ec, rawtx = await self.bx.fetch_blockchain_transaction(tx_hash) _ec, rawtx = await self.bx.fetch_mempool_transaction(tx_hash) if _ec and _ec != 0: self.log.debug("Got error: %s", repr(_ec)) return JsonRPCError.internalerror() # Behaviour is undefined in spec if not rawtx: return {"result": None} if verbose: # TODO: Help needed return JsonRPCError.invalidrequest() return {"result": bh2u(rawtx)}
async def handle_query(self, writer, query): # pylint: disable=R0915,R0912,R0911 """Electrum protocol method handler mapper""" if "method" not in query or "id" not in query: return await self._send_reply(writer, JsonRPCError.invalidrequest(), None) method = query["method"] func = self.methodmap.get(method) if not func: self.log.error("Unhandled method %s, query=%s", method, query) return await self._send_reply(writer, JsonRPCError.methodnotfound(), query) resp = await func(writer, query) return await self._send_reply(writer, resp, query)
async def scripthash_get_mempool(self, writer, query): # pylint: disable=W0613 """Method: blockchain.scripthash.get_mempool Return the unconfirmed transactions of a script hash. """ # TODO: Implement return JsonRPCError.invalidrequest()