From c6f236494ff8f131fb93721de4ff18db32d6ada1 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:38:19 +0200 Subject: [PATCH] Fix NUT-17 settings entry for NUT-06 (#587) * Fix NUT-17 settings entry for NUT-06 * Wallet: fix mint info deserialization --- cashu/mint/features.py | 14 ++++++++------ cashu/wallet/mint_info.py | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cashu/mint/features.py b/cashu/mint/features.py index 494033e..1a3285b 100644 --- a/cashu/mint/features.py +++ b/cashu/mint/features.py @@ -76,12 +76,14 @@ class LedgerFeatures(SupportsBackends): # specify which websocket features are supported # these two are supported by default - websocket_features: List[Dict[str, Union[str, List[str]]]] = [] + websocket_features: Dict[str, List[Dict[str, Union[str, List[str]]]]] = { + "supported": [] + } # we check the backend to see if "bolt11_mint_quote" is supported as well for method, unit_dict in self.backends.items(): if method == Method["bolt11"]: for unit in unit_dict.keys(): - websocket_features.append( + websocket_features["supported"].append( { "method": method.name, "unit": unit.name, @@ -90,11 +92,11 @@ class LedgerFeatures(SupportsBackends): ) if unit_dict[unit].supports_incoming_payment_stream: supported_features: List[str] = list( - websocket_features[-1]["commands"] + websocket_features["supported"][-1]["commands"] + ) + websocket_features["supported"][-1]["commands"] = ( + supported_features + ["bolt11_mint_quote"] ) - websocket_features[-1]["commands"] = supported_features + [ - "bolt11_mint_quote" - ] if websocket_features: mint_features[WEBSOCKETS_NUT] = websocket_features diff --git a/cashu/wallet/mint_info.py b/cashu/wallet/mint_info.py index 734425a..760f43c 100644 --- a/cashu/wallet/mint_info.py +++ b/cashu/wallet/mint_info.py @@ -43,9 +43,10 @@ class MintInfo(BaseModel): if not self.nuts or not self.supports_nut(WEBSOCKETS_NUT): return False websocket_settings = self.nuts[WEBSOCKETS_NUT] - if not websocket_settings: + if not websocket_settings or "supported" not in websocket_settings: return False - for entry in websocket_settings: + websocket_supported = websocket_settings["supported"] + for entry in websocket_supported: if entry["method"] == method.name and entry["unit"] == unit.name: if "bolt11_mint_quote" in entry["commands"]: return True