diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index ba80e792e..dc157c8ec 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -71,7 +71,7 @@ from lnbits.helpers import generate_filter_params_openapi, url_for from lnbits.lnurl import decode as lnurl_decode from lnbits.settings import settings from lnbits.utils.exchange_rates import ( - currencies, + allowed_currencies, fiat_amount_as_satoshis, satoshis_amount_as_fiat, ) @@ -722,14 +722,8 @@ async def api_perform_lnurlauth( @api_router.get("/api/v1/currencies") -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()) +async def api_list_currencies_available() -> List[str]: + return allowed_currencies() @api_router.post("/api/v1/conversion") diff --git a/lnbits/core/views/generic.py b/lnbits/core/views/generic.py index fc939986a..f34c8d572 100644 --- a/lnbits/core/views/generic.py +++ b/lnbits/core/views/generic.py @@ -21,7 +21,7 @@ from lnbits.settings import settings from lnbits.wallets import get_wallet_class from ...extension_manager import InstallableExtension, get_valid_extensions -from ...utils.exchange_rates import currencies +from ...utils.exchange_rates import allowed_currencies, currencies from ..crud import ( create_account, create_wallet, @@ -216,6 +216,7 @@ async def wallet( "request": request, "user": user.dict(), "wallet": user_wallet.dict(), + "currencies": allowed_currencies(), "service_fee": settings.lnbits_service_fee, "service_fee_max": settings.lnbits_service_fee_max, "web_manifest": f"/manifest/{user.id}.webmanifest", diff --git a/lnbits/static/js/wallet.js b/lnbits/static/js/wallet.js index bdf48c951..dfc0b0084 100644 --- a/lnbits/static/js/wallet.js +++ b/lnbits/static/js/wallet.js @@ -818,8 +818,10 @@ new Vue({ } }, watch: { - payments: function () { - this.fetchBalance() + payments: function (_, oldVal) { + if (oldVal && oldVal.length !== 0) { + this.fetchBalance() + } }, 'paymentsChart.group': function () { this.showChart() @@ -837,18 +839,11 @@ new Vue({ this.mobileSimple = true } this.fetchPayments() + this.balance = Math.floor(window.wallet.balance_msat / 1000) this.update.name = this.g.wallet.name this.update.currency = this.g.wallet.currency - - LNbits.api - .request('GET', '/api/v1/currencies') - .then(response => { - this.receive.units = ['sat', ...response.data] - }) - .catch(err => { - LNbits.utils.notifyApiError(err) - }) + this.receive.units = ['sat', ...window.currencies] }, mounted: function () { // show disclaimer diff --git a/lnbits/templates/macros.jinja b/lnbits/templates/macros.jinja index 5f3c96f06..5daaed3d2 100644 --- a/lnbits/templates/macros.jinja +++ b/lnbits/templates/macros.jinja @@ -1,6 +1,9 @@ {% macro window_vars(user, wallet) -%}