Ability to limit available fiat currencies (#1748)
* feat: limit number of available fiat currencies
* feat: Add allowed currency selector to Admin UI
* motorinas suggestions
---------
Co-authored-by: dni ⚡ <office@dnilabs.com>
This commit is contained in:
parent
150a33009d
commit
48fc73d9d4
5 changed files with 26 additions and 0 deletions
|
|
@ -52,6 +52,9 @@ LNBITS_RESERVE_FEE_MIN=2000
|
||||||
# value in percent
|
# value in percent
|
||||||
LNBITS_RESERVE_FEE_PERCENT=1.0
|
LNBITS_RESERVE_FEE_PERCENT=1.0
|
||||||
|
|
||||||
|
# Limit fiat currencies allowed to see in UI
|
||||||
|
# LNBITS_ALLOWED_CURRENCIES="EUR, USD"
|
||||||
|
|
||||||
# Change theme
|
# Change theme
|
||||||
LNBITS_SITE_TITLE="LNbits"
|
LNBITS_SITE_TITLE="LNbits"
|
||||||
LNBITS_SITE_TAGLINE="free and open-source lightning wallet"
|
LNBITS_SITE_TAGLINE="free and open-source lightning wallet"
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,20 @@
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row q-col-gutter-md">
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
<p>Allowed currencies</p>
|
||||||
|
<q-select
|
||||||
|
filled
|
||||||
|
v-model="formData.lnbits_allowed_currencies"
|
||||||
|
multiple
|
||||||
|
hint="Limit the number of available fiat currencies"
|
||||||
|
label="Allowed currencies"
|
||||||
|
:options="{{ currencies | safe }}"
|
||||||
|
></q-select>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row q-col-gutter-md">
|
<div class="row q-col-gutter-md">
|
||||||
<div class="col-12 col-md-6">
|
<div class="col-12 col-md-6">
|
||||||
<p>Admin Extensions</p>
|
<p>Admin Extensions</p>
|
||||||
|
|
|
||||||
|
|
@ -672,6 +672,12 @@ async def api_perform_lnurlauth(
|
||||||
|
|
||||||
@core_app.get("/api/v1/currencies")
|
@core_app.get("/api/v1/currencies")
|
||||||
async def api_list_currencies_available():
|
async def api_list_currencies_available():
|
||||||
|
if len(settings.lnbits_allowed_currencies) > 0:
|
||||||
|
return [
|
||||||
|
item
|
||||||
|
for item in currencies.keys()
|
||||||
|
if item.upper() in settings.lnbits_allowed_currencies
|
||||||
|
]
|
||||||
return list(currencies.keys())
|
return list(currencies.keys())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ from lnbits.helpers import template_renderer, url_for
|
||||||
from lnbits.settings import get_wallet_class, settings
|
from lnbits.settings import get_wallet_class, settings
|
||||||
|
|
||||||
from ...extension_manager import InstallableExtension, get_valid_extensions
|
from ...extension_manager import InstallableExtension, get_valid_extensions
|
||||||
|
from ...utils.exchange_rates import currencies
|
||||||
from ..crud import (
|
from ..crud import (
|
||||||
create_account,
|
create_account,
|
||||||
create_wallet,
|
create_wallet,
|
||||||
|
|
@ -400,6 +401,7 @@ async def index(request: Request, user: User = Depends(check_admin)):
|
||||||
"user": user.dict(),
|
"user": user.dict(),
|
||||||
"settings": settings.dict(),
|
"settings": settings.dict(),
|
||||||
"balance": balance,
|
"balance": balance,
|
||||||
|
"currencies": list(currencies.keys()),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ class ThemesSettings(LNbitsSettings):
|
||||||
default="https://shop.lnbits.com/;/static/images/lnbits-shop-light.png;/static/images/lnbits-shop-dark.png"
|
default="https://shop.lnbits.com/;/static/images/lnbits-shop-light.png;/static/images/lnbits-shop-dark.png"
|
||||||
) # sneaky sneaky
|
) # sneaky sneaky
|
||||||
lnbits_ad_space_enabled: bool = Field(default=False)
|
lnbits_ad_space_enabled: bool = Field(default=False)
|
||||||
|
lnbits_allowed_currencies: List[str] = Field(default=[])
|
||||||
|
|
||||||
|
|
||||||
class OpsSettings(LNbitsSettings):
|
class OpsSettings(LNbitsSettings):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue