From 5bec5f9c5f2f0bfbae45685710d8fb069802a4de Mon Sep 17 00:00:00 2001 From: padreug Date: Sat, 3 Jan 2026 18:11:27 +0100 Subject: [PATCH 1/6] update events to v0.0.2 --- extensions.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extensions.json b/extensions.json index 48918bc8..04512ccf 100644 --- a/extensions.json +++ b/extensions.json @@ -34,6 +34,16 @@ "archive": "https://git.atitlan.io/aiolabs/events/archive/v0.0.1.zip", "hash": "410ac9c340551aabe88e0dc7393ed30dc7f4703f1345af5e6b02b0ebc5337d52" }, + { + "id": "events", + "repo": "https://git.atitlan.io/aiolabs/events", + "name": "AIO Events", + "version": "0.0.2", + "short_description": "AIO fork of aiolabs/events", + "icon": "https://git.atitlan.io/aiolabs/events/raw/branch/main/static/image/events.png", + "archive": "https://git.atitlan.io/aiolabs/events/archive/v0.0.2.zip", + "hash": "4ac140b97b164f81c482cc19da07a79e961685ae146dc89cba6d12e7d5e80716" + }, { "id": "nostrclient", "repo": "https://git.atitlan.io/aiolabs/nostrclient", From 41c0dcfdcd96671a86f8fb7201306f29826bf0f7 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 5 Jan 2026 11:34:06 +0100 Subject: [PATCH 2/6] updated satmachineadmin v0.0.2 important fix for 1.4 --- extensions.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/extensions.json b/extensions.json index 04512ccf..bf0d21f3 100644 --- a/extensions.json +++ b/extensions.json @@ -14,6 +14,17 @@ "archive": "https://git.atitlan.io/aiolabs/satmachineadmin/archive/v0.0.1.zip", "hash": "e9b61de40e940f05aca460a0560cd3cc8b98f2f0d861e37cef13b046eaec0b7c" }, + { + "id": "satmachineadmin", + "repo": "https://git.atitlan.io/aiolabs/satmachineadmin", + "name": "Satoshi Machine Admin", + "min_lnbits_version": "1.4.0", + "version": "0.0.2", + "short_description": "Admin Dashboard for Satoshi Machine", + "icon": "https://git.atitlan.io/aiolabs/satmachineadmin/raw/branch/main/static/image/aio.png", + "archive": "https://git.atitlan.io/aiolabs/satmachineadmin/archive/v0.0.2.zip", + "hash": "83119ddf6c6d7fc345e3514518bf073c0582bb4dc259297fee5361d102836791" + }, { "id": "satmachineclient", "repo": "https://git.atitlan.io/aiolabs/satmachineclient", From 1074ca4d9ac316b62dc0c47d27e7bda62ba79a27 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 5 Jan 2026 12:19:05 +0100 Subject: [PATCH 3/6] update satmachineadmin to v0.0.3 to fix --- extensions.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions.json b/extensions.json index bf0d21f3..aff968e4 100644 --- a/extensions.json +++ b/extensions.json @@ -19,11 +19,11 @@ "repo": "https://git.atitlan.io/aiolabs/satmachineadmin", "name": "Satoshi Machine Admin", "min_lnbits_version": "1.4.0", - "version": "0.0.2", + "version": "0.0.3", "short_description": "Admin Dashboard for Satoshi Machine", "icon": "https://git.atitlan.io/aiolabs/satmachineadmin/raw/branch/main/static/image/aio.png", - "archive": "https://git.atitlan.io/aiolabs/satmachineadmin/archive/v0.0.2.zip", - "hash": "83119ddf6c6d7fc345e3514518bf073c0582bb4dc259297fee5361d102836791" + "archive": "https://git.atitlan.io/aiolabs/satmachineadmin/archive/v0.0.3.zip", + "hash": "0cf520ee62037298320d8c0caa6f15d89858447d826af53472cb369023eda46d" }, { "id": "satmachineclient", From b3817959a04e434ac390858e880d5a9e156506d4 Mon Sep 17 00:00:00 2001 From: padreug Date: Tue, 6 Jan 2026 23:13:17 +0100 Subject: [PATCH 4/6] update nostrrelay to v0.0.2 this fixes critical bug stopping order invoices from beings sent following purchase --- extensions.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions.json b/extensions.json index aff968e4..5ef33282 100644 --- a/extensions.json +++ b/extensions.json @@ -79,11 +79,11 @@ "id": "nostrrelay", "repo": "https://git.atitlan.io/aiolabs/nostrrelay", "name": "AIO Nostrrelay", - "version": "0.0.1", + "version": "0.0.2", "short_description": "AIO fork of aiolabs/nostrrelay", "icon": "https://git.atitlan.io/aiolabs/nostrrelay/raw/branch/main/static/image/nostrrelay.png", - "archive": "https://git.atitlan.io/aiolabs/nostrrelay/archive/v0.0.1.zip", - "hash": "2b1ba6a3b7a79f6595f075c332b82a0ba64c608637ad5bcf23182e40fdf7f68f" + "archive": "https://git.atitlan.io/aiolabs/nostrrelay/archive/v0.0.2.zip", + "hash": "6e353358314b740679e55e2ff98c7024a97c6df8bf27d1784e8cee448407bebd" }, { "id": "castle", From 359e9d8b295c8576c78cb8fd8dcc8c03283f0853 Mon Sep 17 00:00:00 2001 From: padreug Date: Wed, 7 Jan 2026 00:12:07 +0100 Subject: [PATCH 5/6] fix(lndrest): use boolean for allow_self_payment instead of integer LND's /v2/router/send endpoint expects allow_self_payment to be a JSON boolean, not an integer. Sending 1 instead of true causes a 400 error: 'proto: invalid value for bool type: 1' Fixes payments failing when lnd_rest_allow_self_payment is enabled. --- lnbits/wallets/lndrest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/wallets/lndrest.py b/lnbits/wallets/lndrest.py index 861448d6..da72a61f 100644 --- a/lnbits/wallets/lndrest.py +++ b/lnbits/wallets/lndrest.py @@ -178,7 +178,7 @@ class LndRestWallet(Wallet): "no_inflight_updates": True, } if settings.lnd_rest_allow_self_payment: - req["allow_self_payment"] = 1 + req["allow_self_payment"] = True try: r = await self.client.post( From e062743e5a23bff66ea90b37817bbe19e9d4cd46 Mon Sep 17 00:00:00 2001 From: padreug Date: Wed, 15 Oct 2025 00:56:14 +0200 Subject: [PATCH 6/6] feat: implement automatic crediting of new accounts with 1 million satoshis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modified the user account creation process to automatically credit new accounts with 1,000,000 satoshis upon creation. - Updated the `create_user_account_no_ckeck` function to include error handling and logging for the credit operation. - Enhanced tests to verify the balance for newly registered users, ensuring the correct credit amount is applied. - Documented affected account creation paths and testing instructions in the new `AUTO_CREDIT_CHANGES.md` file. fix: pass db connection to update_wallet_balance to prevent SQLite deadlock The auto-credit feature was causing a deadlock on SQLite because update_wallet_balance was opening a new database connection while already inside a transaction. By passing conn=conn, we reuse the existing connection and avoid the deadlock. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- AUTO_CREDIT_CHANGES.md | 88 +++++++++++++++++++++++++++++++++++ lnbits/core/services/users.py | 9 ++++ tests/api/test_auth.py | 8 ++++ 3 files changed, 105 insertions(+) create mode 100644 AUTO_CREDIT_CHANGES.md diff --git a/AUTO_CREDIT_CHANGES.md b/AUTO_CREDIT_CHANGES.md new file mode 100644 index 00000000..408f6987 --- /dev/null +++ b/AUTO_CREDIT_CHANGES.md @@ -0,0 +1,88 @@ +# LNBits Auto-Credit Changes + +## Overview +Modified LNBits server to automatically credit new accounts with 1 million satoshis (1,000,000 sats) when they are created. + +## Changes Made + +### 1. Modified `lnbits/core/services/users.py` + +**Added imports:** +- `get_wallet` from `..crud` +- `update_wallet_balance` from `.payments` + +**Modified `create_user_account_no_ckeck` function:** +- Changed `create_wallet` call to capture the returned wallet object +- Added automatic credit of 1,000,000 sats after wallet creation +- Added error handling and logging for the credit operation + +**Code changes:** +```python +# Before: +await create_wallet( + user_id=account.id, + wallet_name=wallet_name or settings.lnbits_default_wallet_name, +) + +# After: +wallet = await create_wallet( + user_id=account.id, + wallet_name=wallet_name or settings.lnbits_default_wallet_name, +) + +# Credit new account with 1 million satoshis +try: + await update_wallet_balance(wallet, 1_000_000) + logger.info(f"Credited new account {account.id} with 1,000,000 sats") +except Exception as e: + logger.error(f"Failed to credit new account {account.id} with 1,000,000 sats: {e}") +``` + +### 2. Updated Tests in `tests/api/test_auth.py` + +**Modified test functions:** +- `test_register_ok`: Added balance verification for regular user registration +- `test_register_nostr_ok`: Added balance verification for Nostr authentication + +**Added assertions:** +```python +# Check that the wallet has 1 million satoshis +wallet = user.wallets[0] +assert wallet.balance == 1_000_000, f"Expected 1,000,000 sats balance, got {wallet.balance} sats" +``` + +## Affected Account Creation Paths + +The automatic credit will be applied to all new accounts created through: + +1. **Regular user registration** (`/api/v1/auth/register`) +2. **Nostr authentication** (`/api/v1/auth/nostr`) +3. **SSO login** (when new account is created) +4. **API account creation** (`/api/v1/account`) +5. **Admin user creation** (via admin interface) + +## Excluded Paths + +- **Superuser/Admin account creation** (`init_admin_settings`): This function creates the admin account directly and bypasses the user creation flow, so it won't receive the automatic credit. + +## Testing + +To test the changes: + +1. Install dependencies: `poetry install` +2. Run the modified tests: `poetry run pytest tests/api/test_auth.py::test_register_ok -v` +3. Run Nostr test: `poetry run pytest tests/api/test_auth.py::test_register_nostr_ok -v` + +## Logging + +The system will log: +- Success: `"Credited new account {account.id} with 1,000,000 sats"` +- Failure: `"Failed to credit new account {account.id} with 1,000,000 sats: {error}"` + +## Notes + +- The credit uses the existing `update_wallet_balance` function which creates an internal payment record +- The credit is applied after wallet creation but before user extensions are set up +- Error handling ensures that account creation continues even if the credit fails +- The credit amount is hardcoded to 1,000,000 sats (1MM sats) + diff --git a/lnbits/core/services/users.py b/lnbits/core/services/users.py index d21a8aff..16d6884c 100644 --- a/lnbits/core/services/users.py +++ b/lnbits/core/services/users.py @@ -26,6 +26,7 @@ from ..crud import ( get_super_settings, get_user_extensions, get_user_from_account, + get_wallet, update_account, update_super_user, update_user_extension, @@ -37,6 +38,7 @@ from ..models import ( UserExtra, ) from .settings import update_cached_settings +from .payments import update_wallet_balance async def create_user_account( @@ -80,6 +82,13 @@ async def create_user_account_no_ckeck( conn=conn, ) + # Credit new account with 1 million satoshis + try: + await update_wallet_balance(wallet, 1_000_000, conn=conn) + logger.info(f"Credited new account {account.id} with 1,000,000 sats") + except Exception as e: + logger.error(f"Failed to credit new account {account.id} with 1,000,000 sats: {e}") + user_extensions = (default_exts or []) + settings.lnbits_user_default_extensions for ext_id in user_extensions: try: diff --git a/tests/api/test_auth.py b/tests/api/test_auth.py index 57cacd03..8b1e7ba2 100644 --- a/tests/api/test_auth.py +++ b/tests/api/test_auth.py @@ -295,6 +295,10 @@ async def test_register_ok(http_client: AsyncClient): assert ( len(user.wallets) == 1 ), f"Expected 1 default wallet, not {len(user.wallets)}." + + # Check that the wallet has 1 million satoshis + wallet = user.wallets[0] + assert wallet.balance == 1_000_000, f"Expected 1,000,000 sats balance, got {wallet.balance} sats" @pytest.mark.anyio @@ -588,6 +592,10 @@ async def test_register_nostr_ok(http_client: AsyncClient, settings: Settings): assert ( len(user.wallets) == 1 ), f"Expected 1 default wallet, not {len(user.wallets)}." + + # Check that the wallet has 1 million satoshis + wallet = user.wallets[0] + assert wallet.balance == 1_000_000, f"Expected 1,000,000 sats balance, got {wallet.balance} sats" @pytest.mark.anyio