Skip to content

Commit

Permalink
respect MINT_MAX_PEG_IN MINT_MAX_PEG_OUT settings
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Mar 21, 2024
1 parent d82ad2f commit c4acb44
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions cashu/mint/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c4acb44

Please sign in to comment.