fix: always create default wallet for user (#2580)

* fix: always create default wallet for user

* no assert in api

---------

Co-authored-by: dni  <office@dnilabs.com>
This commit is contained in:
Vlad Stan 2024-07-15 13:34:26 +03:00 committed by GitHub
parent 1bee84d419
commit 7d1e22c7de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -785,6 +785,7 @@ async def create_user_account(
email: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
wallet_name: Optional[str] = None,
user_config: Optional[UserConfig] = None,
) -> User:
if not settings.new_accounts_allowed:
@ -805,6 +806,8 @@ async def create_user_account(
password = pwd_context.hash(password) if password else None
account = await create_account(user_id, username, email, password, user_config)
wallet = await create_wallet(user_id=account.id, wallet_name=wallet_name)
account.wallets = [wallet]
for ext_id in settings.lnbits_user_default_extensions:
await update_user_extension(user_id=account.id, extension=ext_id, active=True)

View File

@ -36,9 +36,6 @@ from lnbits.utils.exchange_rates import (
satoshis_amount_as_fiat,
)
from ..crud import (
create_wallet,
)
from ..services import create_user_account, perform_lnurlauth
# backwards compatibility for extension
@ -69,8 +66,8 @@ async def api_create_account(data: CreateWallet) -> Wallet:
status_code=HTTPStatus.FORBIDDEN,
detail="Account creation is disabled.",
)
account = await create_user_account()
return await create_wallet(user_id=account.id, wallet_name=data.name)
account = await create_user_account(wallet_name=data.name)
return account.wallets[0]
@api_router.get("/api/v1/lnurlscan/{code}")