This commit is contained in:
Shroominic
2025-06-12 12:56:49 +02:00
parent 77ab50fe79
commit ab06bccc82
+4 -4
View File
@@ -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.