From c4acb449887cdbbd0f6965e0dde7933be8c06069 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:50:56 +0100 Subject: [PATCH] respect MINT_MAX_PEG_IN MINT_MAX_PEG_OUT settings --- cashu/mint/router.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/cashu/mint/router.py b/cashu/mint/router.py index a9de4689..50c41c7f 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -42,21 +42,31 @@ async def info() -> GetInfoResponse: logger.trace("> GET /v1/info") # determine all method-unit pairs - method_settings: List[MintMeltMethodSetting] = [] - for method, unit_dict in ledger.backends.items(): - for unit in unit_dict.keys(): - method_settings.append( - MintMeltMethodSetting(method=method.name, unit=unit.name) - ) + method_settings: Dict[int, List[MintMeltMethodSetting]] = {} + for nut in [4, 5]: + method_settings[nut] = [] + for method, unit_dict in ledger.backends.items(): + for unit in unit_dict.keys(): + setting = MintMeltMethodSetting(method=method.name, unit=unit.name) + + if nut == 4 and settings.mint_max_peg_in: + setting.max_amount = settings.mint_max_peg_in + setting.min_amount = 0 + elif nut == 5 and settings.mint_max_peg_out: + setting.max_amount = settings.mint_max_peg_out + setting.min_amount = 0 + + method_settings[nut].append(setting) + supported_dict = dict(supported=True) mint_features: Dict[int, Dict[str, Any]] = { 4: dict( - methods=method_settings, - disabled=False, + methods=method_settings[4], + disabled=settings.mint_peg_out_only, ), 5: dict( - methods=method_settings, + methods=method_settings[5], disabled=False, ), 7: supported_dict,