Skip to content

Commit

Permalink
🐛 Do not parse empty HTTP payload
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Apr 28, 2024
1 parent f37d361 commit f6ef110
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions electrumx/server/http_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ def __init__(self, session_mgr, db, mempool, peer_mgr, kind):
self.MAX_CHUNK_SIZE = 2016
self.hashX_subs = {}

async def format_params(self, request):
async def format_params(self, request: web.Request):
params: list
if request.method == "GET":
params = json.loads(request.query.get("params", "[]"))
else:
elif request.content_length:
json_data = await request.json()
params = json_data.get("params", [])
else:
params = []
return dict(zip(range(len(params)), params))

async def get_rpc_server(self):
Expand Down Expand Up @@ -860,11 +863,8 @@ async def transaction_broadcast(self, request):
# verified
async def scripthash_get_history(self, request):
'''Return the confirmed and unconfirmed history of a scripthash.'''
try:
params = await self.format_params(request)
scripthash = params.get(0, "")
except Exception as e:
scripthash = request
params = await self.format_params(request)
scripthash = params.get(0)

hashX = scripthash_to_hashX(scripthash)
return await self.confirmed_and_unconfirmed_history(hashX)
Expand Down

0 comments on commit f6ef110

Please sign in to comment.