swaps: more robust parsing

This commit is contained in:
SomberNight
2025-08-19 12:57:23 +00:00
parent 5b8569e814
commit 81be0554a3
3 changed files with 96 additions and 53 deletions
+4
View File
@@ -333,8 +333,12 @@ class NWCServer(Logger, EventListener):
try:
content = our_connection_secret.decrypt_message(event.content, event.pubkey)
content = json.loads(content)
if not isinstance(content, dict):
raise Exception("malformed content, not dict")
event.content = content
params: dict = content['params']
if not isinstance(params, dict):
raise Exception("malformed params, not dict")
except Exception:
self.logger.debug(f"Invalid request event content: {event.content}", exc_info=True)
continue
@@ -210,6 +210,8 @@ class CosignerWallet(Logger):
continue
try:
message = json_decode(message)
if not isinstance(message, dict):
raise Exception("malformed message, not dict")
tx_hex = message.get('tx')
label = message.get('label', '')
tx = tx_from_any(tx_hex)