Compare commits

...
Author SHA1 Message Date
Tiago Vasconcelos 139bd96639 chore: bundle 2026-07-14 16:25:28 +01:00
Tiago Vasconcelos f6114fc33a update i18n 2026-07-14 16:12:08 +01:00
Tiago Vasconcelos 399e01c6a8 reduce ui inline conditionals 2026-07-14 16:12:08 +01:00
Tiago Vasconcelos abe1e2fb27 display expiry on ACL tokens 2026-07-14 16:12:08 +01:00
43900dd6da feat: add emailConfigured to PublicSettings (#4047)
Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
2026-07-13 15:28:28 +02:00
Riccardo BalboandGitHub 06c553219a Merge commit from fork
* fix: daily withdrawal limit

* feat: unit tests for cumulative daily withdrawal
2026-07-13 11:59:49 +03:00
fc73d83bd9 feat: optimise Uvicorn Settings for heavy web socket use (#4028)
Co-authored-by: dadofsambonzuki <dadofsambonzuki@users.noreply.github.com>
Co-authored-by: dni <office@dnilabs.com>
2026-07-13 10:28:34 +02:00
Riccardo BalboandGitHub 4cb743d952 Merge commit from fork 2026-07-13 11:25:08 +03:00
dni ⚡andGitHub 3b6e87b060 fix: docker image dont rebuild after restart (#4057) 2026-07-13 11:17:28 +03:00
15 changed files with 105 additions and 14 deletions
+1 -1
View File
@@ -43,4 +43,4 @@ ENV LNBITS_HOST="0.0.0.0"
EXPOSE 5000
CMD ["sh", "-c", "uv --offline run lnbits --port $LNBITS_PORT --host $LNBITS_HOST --forwarded-allow-ips='*'"]
CMD ["sh", "-c", "uv --offline run --no-sync lnbits --port $LNBITS_PORT --host $LNBITS_HOST --forwarded-allow-ips='*'"]
+1
View File
@@ -41,6 +41,7 @@ class SimpleStatus(BaseModel):
class SimpleItem(BaseModel):
id: str
name: str
expires_at: int | None = None
class DbVersion(BaseModel):
+2 -3
View File
@@ -17,7 +17,7 @@ from lnbits.db import Connection, Filters
from lnbits.decorators import check_user_extension_access
from lnbits.exceptions import InvoiceError, PaymentError, UnsupportedError
from lnbits.fiat import get_fiat_provider
from lnbits.helpers import check_callback_url
from lnbits.helpers import check_callback_url, daystart_timestamp
from lnbits.settings import settings
from lnbits.task_manager import task_manager
from lnbits.utils.crypto import fake_privkey, random_secret_and_hash, verify_preimage
@@ -557,10 +557,9 @@ async def check_wallet_daily_withdraw_limit(
raise ValueError("It is not allowed to spend funds from this server.")
payments = await get_payments(
since=int(time.time()) - 60 * 60 * 24,
since=daystart_timestamp(),
outgoing=True,
wallet_id=wallet_id,
limit=1,
conn=conn,
)
if len(payments) == 0:
+4 -1
View File
@@ -295,7 +295,10 @@ async def api_create_user_api_token(
account.username, api_token_id, data.expiration_time_minutes
)
acl.token_id_list.append(SimpleItem(id=api_token_id, name=data.token_name))
expires_at = int(time()) + data.expiration_time_minutes * 60
acl.token_id_list.append(
SimpleItem(id=api_token_id, name=data.token_name, expires_at=expires_at)
)
await update_user_access_control_list(acls)
return ApiTokenResponse(id=api_token_id, api_token=api_token)
+5 -4
View File
@@ -158,10 +158,6 @@ async def api_update_user(
async def api_users_delete_user(
user_id: str, account: Account = Depends(check_admin)
) -> SimpleStatus:
wallets = await get_wallets(user_id, deleted=False)
for wallet in wallets:
await delete_wallet_by_id(wallet.id)
if user_id == settings.super_user:
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,
@@ -173,6 +169,11 @@ async def api_users_delete_user(
status_code=HTTPStatus.BAD_REQUEST,
detail="Only super_user can delete admin user.",
)
wallets = await get_wallets(user_id, deleted=False)
for wallet in wallets:
await delete_wallet_by_id(wallet.id)
await delete_account(user_id)
return SimpleStatus(success=True, message="User deleted.")
+10
View File
@@ -372,3 +372,13 @@ def sha256s(value: str) -> str:
Returns the hex as a string.
"""
return hashlib.sha256(value.encode("utf-8")).hexdigest()
def daystart_timestamp(dt: datetime | None = None) -> int:
"""
Returns the timestamp of the start of the day for the given
datetime (or now in UTC if not provided).
"""
dt = dt or datetime.now(timezone.utc)
day_start = dt.replace(hour=0, minute=0, second=0, microsecond=0)
return int(day_start.timestamp())
+6
View File
@@ -27,6 +27,8 @@ from lnbits.settings import set_cli_settings, settings
@click.option(
"--reload", is_flag=True, default=False, help="Enable auto-reload for development"
)
@click.option("--ws-max-queue", default=128, help="Websocket max queue size")
@click.option("--ws-ping-timeout", default=60.0, help="Websocket ping timeout")
def main(
port: int,
host: str,
@@ -34,6 +36,8 @@ def main(
ssl_keyfile: str,
ssl_certfile: str,
reload: bool,
ws_max_queue: int,
ws_ping_timeout: float,
):
"""Launched with `uv run lnbits` at root level"""
@@ -58,6 +62,8 @@ def main(
ssl_keyfile=ssl_keyfile,
ssl_certfile=ssl_certfile,
reload=reload or False,
ws_ping_timeout=ws_ping_timeout,
ws_max_queue=ws_max_queue,
)
server = uvicorn.Server(config=config)
+7
View File
@@ -496,6 +496,11 @@ class NotificationsSettings(LNbitsSettings):
and self.lnbits_telegram_notifications_access_token is not None
)
def is_email_notifications_configured(self) -> bool:
return self.lnbits_email_notifications_enabled and bool(
self.lnbits_email_notifications_email
)
class FakeWalletFundingSource(LNbitsSettings):
fake_wallet_secret: str = Field(default="ToTheMoon1")
@@ -1295,6 +1300,7 @@ class PublicSettings(BaseModel):
extensions_reviews_url: str = Field(alias="extensionsReviewsUrl")
ext_builder: bool = Field(alias="extBuilder")
nostr_configured: bool = Field(alias="nostrConfigured")
email_configured: bool = Field(alias="emailConfigured")
telegram_configured: bool = Field(alias="telegramConfigured")
wallet_featured_button_label: str | None = Field(alias="walletFeaturedButtonLabel")
wallet_featured_button_url: str | None = Field(alias="walletFeaturedButtonUrl")
@@ -1359,6 +1365,7 @@ class PublicSettings(BaseModel):
extensionsReviewsUrl=settings.lnbits_extensions_reviews_url,
extBuilder=settings.lnbits_extensions_builder_activate_non_admins,
nostrConfigured=settings.is_nostr_notifications_configured(),
emailConfigured=settings.is_email_notifications_configured(),
telegramConfigured=settings.is_telegram_notifications_configured(),
walletFeaturedButtonLabel=settings.lnbits_wallet_featured_button_label,
walletFeaturedButtonUrl=settings.lnbits_wallet_featured_button_url,
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -482,6 +482,8 @@ window.localisation.en = {
access_control_list_admin_warning:
'This is an admin account. The generated tokens will have admin privileges.',
new_api_acl: 'New Access Control List',
acl_token_active: 'Active',
acl_token_expired: 'Expired',
api_token_id: 'Token Id',
toggle_gradient: 'Toggle Gradient',
gradient_background: 'Gradient Background',
+29
View File
@@ -217,6 +217,35 @@ window.PageAccount = {
computed: {
isUserTouched() {
return !_.isEqual(this.g.user, this.untouchedUser)
},
selectedApiToken() {
return this.selectedApiAcl.token_id_list.find(
token => token.id === this.apiAcl.selectedTokenId
)
},
expiryAt() {
if (this.selectedApiToken.expires_at) {
return `${this.$t('expiry')}: ${LNbits.utils.formatTimestamp(this.selectedApiToken.expires_at)}`
} else {
return ''
}
},
tokenStatus() {
if (this.selectedApiToken.expires_at) {
const now = new Date()
const expiresAt = new Date(this.selectedApiToken.expires_at * 1000)
let status = ''
let badgeColor = 'positive'
if (expiresAt < now) {
status = this.$t('acl_token_expired')
badgeColor = 'negative'
} else {
status = this.$t('acl_token_active')
}
return {status, badgeColor}
} else {
return ''
}
}
},
methods: {
+11
View File
@@ -889,6 +889,17 @@
></q-btn>
</div>
</div>
<div
v-if="selectedApiToken && selectedApiToken.expires_at"
class="row items-center q-mb-md q-gutter-sm"
>
<span v-text="expiryAt"></span>
<span v-text="$t('status') + ':'"></span>
<q-badge
:color="tokenStatus.badgeColor"
:label="tokenStatus.status"
></q-badge>
</div>
<div v-if="apiAcl.apiToken" class="row q-mb-md">
<div class="col-12">
<q-badge>
+7 -3
View File
@@ -1745,10 +1745,14 @@ async def test_api_create_user_api_token_success(
), "Expiration time should be 60 minutes from now."
token_id = payload["api_token_id"]
assert any(
token_id in [token.id for token in acl.token_id_list]
stored_token = next(
token
for acl in acls.access_control_list
), "API token should be part of at least one ACL."
for token in acl.token_id_list
if token.id == token_id
)
assert stored_token.expires_at is not None
assert abs(stored_token.expires_at - expiration_time) <= 1
@pytest.mark.anyio
+18
View File
@@ -27,6 +27,7 @@ from lnbits.core.services.payments import (
check_pending_payments,
check_time_limit_between_transactions,
check_transaction_status,
check_wallet_daily_withdraw_limit,
check_wallet_limits,
create_payment_request,
get_payments_daily_stats,
@@ -248,6 +249,23 @@ async def test_check_wallet_limits_and_time_limit(
settings.lnbits_wallet_limit_secs_between_trans = original_limit
@pytest.mark.anyio
async def test_check_wallet_daily_limit_counts_all_daily_payments(settings: Settings):
wallet = await _create_wallet()
await _create_payment(wallet, amount_msat=-2_000, status=PaymentState.SUCCESS)
await _create_payment(wallet, amount_msat=-3_000, status=PaymentState.SUCCESS)
original_limit = settings.lnbits_wallet_limit_daily_max_withdraw
try:
settings.lnbits_wallet_limit_daily_max_withdraw = 5
with pytest.raises(
ValueError, match="Daily withdrawal limit of 5 sats reached."
):
await check_wallet_daily_withdraw_limit(wallet.id, 1_000)
finally:
settings.lnbits_wallet_limit_daily_max_withdraw = original_limit
@pytest.mark.anyio
async def test_calculate_fiat_amounts_handles_conversion_and_errors(
mocker: MockerFixture,