Skip to content

Commit

Permalink
Fix NUT-17 settings entry for NUT-06 (#587)
Browse files Browse the repository at this point in the history
* Fix NUT-17 settings entry for NUT-06

* Wallet: fix mint info deserialization
  • Loading branch information
callebtc authored Jul 16, 2024
1 parent 21f339c commit c6f2364
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions cashu/mint/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ def mint_features(self) -> Dict[int, Union[List[Any], Dict[str, Any]]]:

# 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,
Expand All @@ -90,11 +92,11 @@ def mint_features(self) -> Dict[int, Union[List[Any], Dict[str, Any]]]:
)
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
Expand Down
5 changes: 3 additions & 2 deletions cashu/wallet/mint_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def supports_websocket_mint_quote(self, method: Method, unit: Unit) -> bool:
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
Expand Down

0 comments on commit c6f2364

Please sign in to comment.