File tree Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -191,14 +191,16 @@ async def create_config(user: str) -> Config:
191
191
192
192
async def update_config (config : Config , user : str ) -> Config :
193
193
_config = ConfigDb (user = user , json_data = config )
194
- await db .insert ("watchonly.config" , _config )
194
+ await db .update ("watchonly.config" , _config , """WHERE "user" = :user""" )
195
195
return config
196
196
197
197
198
- async def get_config (user : str ) -> Optional [ Config ] :
198
+ async def get_config (user : str ) -> Config :
199
199
_config = await db .fetchone (
200
200
"""SELECT * FROM watchonly.config WHERE "user" = :user""" ,
201
201
{"user" : user },
202
202
ConfigDb ,
203
203
)
204
+ if not _config :
205
+ return await create_config (user )
204
206
return _config .json_data
Original file line number Diff line number Diff line change 13
13
from lnbits .helpers import urlsafe_short_hash
14
14
15
15
from .crud import (
16
- create_config ,
17
16
create_fresh_addresses ,
18
17
create_watch_wallet ,
19
18
delete_addresses_for_wallet ,
@@ -117,9 +116,6 @@ async def api_wallet_create_or_update(
117
116
status_code = HTTPStatus .BAD_REQUEST , detail = str (exc )
118
117
) from exc
119
118
120
- config = await get_config (key_info .wallet .user )
121
- if not config :
122
- await create_config (user = key_info .wallet .user )
123
119
return wallet
124
120
125
121
@@ -408,7 +404,6 @@ async def api_update_config(
408
404
data : Config , key_info : WalletTypeInfo = Depends (require_admin_key )
409
405
) -> Config :
410
406
config = await update_config (data , user = key_info .wallet .user )
411
- assert config
412
407
return config
413
408
414
409
@@ -417,6 +412,4 @@ async def api_get_config(
417
412
key_info : WalletTypeInfo = Depends (require_invoice_key ),
418
413
) -> Config :
419
414
config = await get_config (key_info .wallet .user )
420
- if not config :
421
- config = await create_config (user = key_info .wallet .user )
422
415
return config
You can’t perform that action at this time.
0 commit comments