Skip to content

Commit

Permalink
Assert tx hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
wizz-wallet-dev committed Oct 4, 2024
1 parent 05ac927 commit 00a6141
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions electrumx/server/session/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from electrumx.server.session import BAD_REQUEST, DAEMON_ERROR
from electrumx.server.session.http_session import HttpSession
from electrumx.server.session.rpc_session import LocalRPC
from electrumx.server.session.util import SESSION_PROTOCOL_MAX, non_negative_integer
from electrumx.server.session.util import SESSION_PROTOCOL_MAX, assert_tx_hash, non_negative_integer
from electrumx.version import electrumx_version

if TYPE_CHECKING:
Expand Down Expand Up @@ -991,7 +991,7 @@ async def transaction_decode_raw_tx_blueprint(
# Analysis the transaction detail by txid.
# See BlockProcessor.op_list for the complete op list.
async def get_transaction_detail(self, tx_id: str, height=None, tx_num=-1):
tx_hash = hex_str_to_hash(tx_id)
tx_hash = assert_tx_hash(tx_id)
res = self._tx_detail_cache.get(tx_hash)
if res:
# txid maybe the same, this key should add height add key prefix
Expand Down Expand Up @@ -1177,7 +1177,7 @@ def make_transfer_outputs(
return auto_encode_bytes_elements(res)

async def get_transaction_detail_batch(self, tx_ids: str):
tasks = [self.get_transaction_detail(txid) for txid in tx_ids.split(',')]
tasks = [self.get_transaction_detail(assert_tx_hash(tx_id)) for tx_id in tx_ids.split(',')]
details = await asyncio.gather(*tasks)
return details

Expand Down
2 changes: 1 addition & 1 deletion electrumx/server/session/shared_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ async def transaction_get(self, tx_hash, verbose=False):
tx_hash: the transaction hash as a hexadecimal string
verbose: passed on to the daemon
"""
assert_tx_hash(tx_hash)
tx_hash = assert_tx_hash(tx_hash)
if verbose not in (True, False):
raise RPCError(BAD_REQUEST, '"verbose" must be a boolean')

Expand Down

0 comments on commit 00a6141

Please sign in to comment.