From ab06bccc82078a30a7adfa0730e33730d50d556c Mon Sep 17 00:00:00 2001 From: Shroominic Date: Thu, 12 Jun 2025 12:56:49 +0200 Subject: [PATCH] fix --- router/cashu.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/router/cashu.py b/router/cashu.py index c2919d48..4f9f57ed 100644 --- a/router/cashu.py +++ b/router/cashu.py @@ -17,16 +17,17 @@ NSEC = os.environ["NSEC"] # Nostr private key for the wallet WALLET = Wallet(nsec=NSEC, mint_urls=[MINT]) + async def init_wallet(): global WALLET WALLET = await Wallet.create(nsec=NSEC, mint_urls=[MINT]) - + + async def close_wallet(): global WALLET await WALLET.aclose() - async def pay_out() -> None: """ Calculates the pay-out amount based on the spent balance, profit, and donation rate. @@ -93,7 +94,7 @@ async def credit_balance(cashu_token: str, key: ApiKey, session: AsyncSession) - stmt = ( update(ApiKey) .where(col(ApiKey.hashed_key) == key.hashed_key) - .values(balance=col(ApiKey.balance) + amount) + .values(balance=col(ApiKey.balance) + amount_msats) ) await session.exec(stmt) # type: ignore[call-overload] await session.commit() @@ -101,7 +102,6 @@ async def credit_balance(cashu_token: str, key: ApiKey, session: AsyncSession) - return amount_msats - async def check_for_refunds() -> None: """ Periodically checks for API keys that are eligible for refunds and processes them.