Compare commits

..

3 commits
demo ... main

Author SHA1 Message Date
Patrick Mulligan
12806995a5 CHORE update castle repo v0.0.5
Some checks failed
LNbits CI / test-api (, 3.10) (push) Has been cancelled
LNbits CI / test-api (, 3.11) (push) Has been cancelled
LNbits CI / test-api (, 3.12) (push) Has been cancelled
LNbits CI / openapi (push) Has been cancelled
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Has been cancelled
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Has been cancelled
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Has been cancelled
LNbits CI / test-wallets (, 3.10) (push) Has been cancelled
LNbits CI / test-wallets (, 3.11) (push) Has been cancelled
LNbits CI / test-wallets (, 3.12) (push) Has been cancelled
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Has been cancelled
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Has been cancelled
LNbits CI / regtest (BoltzWallet, 3.10) (push) Has been cancelled
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Has been cancelled
LNbits CI / test-unit (, 3.10) (push) Has been cancelled
LNbits CI / test-unit (, 3.11) (push) Has been cancelled
LNbits CI / test-unit (, 3.12) (push) Has been cancelled
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Has been cancelled
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Has been cancelled
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Has been cancelled
LNbits CI / migration (3.10) (push) Has been cancelled
LNbits CI / migration (3.11) (push) Has been cancelled
LNbits CI / migration (3.12) (push) Has been cancelled
LNbits CI / regtest (CoreLightningRestWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (CoreLightningWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (EclairWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (LNbitsWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (LndRestWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (LndWallet, 3.10) (push) Has been cancelled
LNbits CI / jmeter (3.10) (push) Has been cancelled
2026-01-19 07:20:18 -05:00
Patrick Mulligan
019e650bc2 CHORE: bump castle to v0.0.4
Some checks are pending
LNbits CI / migration (3.11) (push) Blocked by required conditions
LNbits CI / migration (3.12) (push) Blocked by required conditions
LNbits CI / openapi (push) Blocked by required conditions
LNbits CI / regtest (BoltzWallet, 3.10) (push) Blocked by required conditions
LNbits CI / test-api (, 3.11) (push) Blocked by required conditions
LNbits CI / test-api (, 3.12) (push) Blocked by required conditions
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Blocked by required conditions
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Blocked by required conditions
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Blocked by required conditions
LNbits CI / test-wallets (, 3.10) (push) Blocked by required conditions
LNbits CI / test-wallets (, 3.11) (push) Blocked by required conditions
LNbits CI / test-wallets (, 3.12) (push) Blocked by required conditions
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Blocked by required conditions
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Blocked by required conditions
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Blocked by required conditions
LNbits CI / test-unit (, 3.10) (push) Blocked by required conditions
LNbits CI / test-unit (, 3.11) (push) Blocked by required conditions
LNbits CI / test-unit (, 3.12) (push) Blocked by required conditions
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Blocked by required conditions
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Blocked by required conditions
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Blocked by required conditions
LNbits CI / migration (3.10) (push) Blocked by required conditions
LNbits CI / regtest (CoreLightningRestWallet, 3.10) (push) Blocked by required conditions
LNbits CI / regtest (CoreLightningWallet, 3.10) (push) Blocked by required conditions
LNbits CI / regtest (EclairWallet, 3.10) (push) Blocked by required conditions
LNbits CI / regtest (LNbitsWallet, 3.10) (push) Blocked by required conditions
LNbits CI / regtest (LndRestWallet, 3.10) (push) Blocked by required conditions
LNbits CI / regtest (LndWallet, 3.10) (push) Blocked by required conditions
LNbits CI / jmeter (3.10) (push) Blocked by required conditions
codeql / analyze (push) Waiting to run
2026-01-19 06:31:49 -05:00
a21ce4fd92 add satmachineadmi v0.0.4
Some checks failed
LNbits CI / test-unit (, 3.11) (push) Has been cancelled
LNbits CI / test-unit (, 3.12) (push) Has been cancelled
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Has been cancelled
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Has been cancelled
LNbits CI / test-unit (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Has been cancelled
LNbits CI / migration (3.10) (push) Has been cancelled
LNbits CI / migration (3.11) (push) Has been cancelled
LNbits CI / migration (3.12) (push) Has been cancelled
LNbits CI / openapi (push) Has been cancelled
LNbits CI / test-api (, 3.10) (push) Has been cancelled
LNbits CI / test-api (, 3.11) (push) Has been cancelled
LNbits CI / test-api (, 3.12) (push) Has been cancelled
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Has been cancelled
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Has been cancelled
LNbits CI / test-api (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Has been cancelled
LNbits CI / test-wallets (, 3.10) (push) Has been cancelled
LNbits CI / test-wallets (, 3.11) (push) Has been cancelled
LNbits CI / test-wallets (, 3.12) (push) Has been cancelled
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.10) (push) Has been cancelled
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.11) (push) Has been cancelled
LNbits CI / test-wallets (postgres://lnbits:lnbits@0.0.0.0:5432/lnbits, 3.12) (push) Has been cancelled
LNbits CI / test-unit (, 3.10) (push) Has been cancelled
LNbits CI / regtest (BoltzWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (CoreLightningRestWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (CoreLightningWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (EclairWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (LNbitsWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (LndRestWallet, 3.10) (push) Has been cancelled
LNbits CI / regtest (LndWallet, 3.10) (push) Has been cancelled
LNbits CI / jmeter (3.10) (push) Has been cancelled
2026-01-11 16:10:13 +01:00
4 changed files with 16 additions and 131 deletions

View file

@ -1,88 +0,0 @@
# 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)

View file

@ -4,16 +4,6 @@
"castle"
],
"extensions": [
{
"id": "satmachineadmin",
"repo": "https://git.atitlan.io/aiolabs/satmachineadmin",
"name": "Satoshi Machine Admin",
"version": "0.0.1",
"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.1.zip",
"hash": "e9b61de40e940f05aca460a0560cd3cc8b98f2f0d861e37cef13b046eaec0b7c"
},
{
"id": "satmachineadmin",
"repo": "https://git.atitlan.io/aiolabs/satmachineadmin",
@ -25,6 +15,16 @@
"archive": "https://git.atitlan.io/aiolabs/satmachineadmin/archive/v0.0.3.zip",
"hash": "0cf520ee62037298320d8c0caa6f15d89858447d826af53472cb369023eda46d"
},
{
"id": "satmachineadmin",
"repo": "https://git.atitlan.io/aiolabs/satmachineadmin",
"name": "Satoshi Machine Admin",
"version": "0.0.4",
"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.4.zip",
"hash": "f5a6e33e6379984964cd0a4b25225770c4356c5c8a62c8e811b712775a180615"
},
{
"id": "satmachineclient",
"repo": "https://git.atitlan.io/aiolabs/satmachineclient",
@ -89,31 +89,21 @@
"id": "castle",
"repo": "https://git.atitlan.io/aiolabs/castle",
"name": "Castle",
"version": "0.0.1",
"version": "0.0.4",
"short_description": "Castle Accounting",
"icon": "https://git.atitlan.io/aiolabs/castle/raw/branch/main/static/image/castle.png",
"archive": "https://git.atitlan.io/aiolabs/castle/archive/v0.0.1.zip",
"hash": "075a96a6f3151472302434fc50552346f7910f82b9ae1c6508d1bfd6db14607b"
"archive": "https://git.atitlan.io/aiolabs/castle/archive/v0.0.4.zip",
"hash": "a5169440c47265b6bb8cf1cc2466a6b743bab00d16e18bd3a97956fc8ea3a069"
},
{
"id": "castle",
"repo": "https://git.atitlan.io/aiolabs/castle",
"name": "Castle",
"version": "0.0.2",
"version": "0.0.5",
"short_description": "Castle Accounting",
"icon": "https://git.atitlan.io/aiolabs/castle/raw/branch/main/static/image/castle.png",
"archive": "https://git.atitlan.io/aiolabs/castle/archive/v0.0.2.zip",
"hash": "0653b7dbfa37da023c7f4fe976441fd6bef0d56fe6d08eb4ce6d4ec178632f4a"
},
{
"id": "castle",
"repo": "https://git.atitlan.io/aiolabs/castle",
"name": "Castle",
"version": "0.0.3",
"short_description": "Castle Accounting",
"icon": "https://git.atitlan.io/aiolabs/castle/raw/branch/main/static/image/castle.png",
"archive": "https://git.atitlan.io/aiolabs/castle/archive/v0.0.3.zip",
"hash": "b9640dbeec00274d8382b6d9e3b4250f356f002c047c8e380ff9acecb2058f39"
"archive": "https://git.atitlan.io/aiolabs/castle/archive/v0.0.5.zip",
"hash": "4c7c3683632cbdd6b1e810e5d1020ad6f03189414507c62d4dc9217813983c3c"
},
{
"id": "lnurlp",

View file

@ -26,7 +26,6 @@ from ..crud import (
get_super_settings,
get_user_extensions,
get_user_from_account,
get_wallet,
update_account,
update_super_user,
update_user_extension,
@ -38,7 +37,6 @@ from ..models import (
UserExtra,
)
from .settings import update_cached_settings
from .payments import update_wallet_balance
async def create_user_account(
@ -82,13 +80,6 @@ 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:

View file

@ -295,10 +295,6 @@ 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
@ -592,10 +588,6 @@ 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