Skip to content

Commit

Permalink
Setup LNbits superuser
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Oct 1, 2024
1 parent 7745f2c commit aacd2df
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ docker-compose.*.yml

# nostr wallet connect
scripts/nwc-keys.json

# lnbits
docker/lnbits/data
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ services:
- '0'
cpu_shares: "${CPU_SHARES_LOW}"
lnbits:
image: lnbits/lnbits:0.12.5
build:
context: ./docker/lnbits
container_name: lnbits
profiles:
- wallets
Expand All @@ -562,14 +563,14 @@ services:
depends_on:
- stacker_lnd
environment:
- LNBITS_ADMIN_UI=true
- LNBITS_BACKEND_WALLET_CLASS=LndWallet
- LND_GRPC_ENDPOINT=stacker_lnd
- LND_GRPC_PORT=10009
- LND_GRPC_CERT=/app/.lnd/tls.cert
- LND_GRPC_MACAROON=/app/.lnd/regtest/admin.macaroon
volumes:
- ./docker/lnd/stacker:/app/.lnd
- ./docker/lnbits/database.sqlite3:/app/data/database.sqlite3
labels:
CONNECT: "localhost:${LNBITS_WEB_PORT}"
cpu_shares: "${CPU_SHARES_LOW}"
Expand Down
5 changes: 5 additions & 0 deletions docker/lnbits/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM lnbits/lnbits:0.12.5


COPY ["./data/database.sqlite3", "/app/data/database.sqlite3"]
COPY ["./data/.super_user", "/app/data/.super_user"]
1 change: 1 addition & 0 deletions docker/lnbits/data/.super_user
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e46288268b67457399a5fca81809573e
Binary file not shown.
49 changes: 22 additions & 27 deletions wallets/lnbits/ATTACH.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
For testing LNbits, you need to create a LNbits account first via the web interface.

By default, you can access it at `localhost:5001` (see `LNBITS_WEB_PORT` in .env.development).

After you created a wallet, you should find the invoice and admin key under `Node URL, API keys and API docs`.

> [!IMPORTANT]
>
> Since your browser is running on your host machine but the server is running inside a docker container, the server will not be able to reach LNbits with `localhost:5001` to create invoices. This makes it hard to test send+receive at the same time.
>
> For now, you need to patch the `_createInvoice` function in wallets/lnbits/server.js to always use `lnbits:5000` as the URL:
>
> ```diff
> diff --git a/wallets/lnbits/server.js b/wallets/lnbits/server.js
> index 39949775..e3605c45 100644
> --- a/wallets/lnbits/server.js
> +++ b/wallets/lnbits/server.js
> @@ -11,6 +11,7 @@ async function _createInvoice ({ url, invoiceKey, amount, expiry }, { me }) {
> const memo = me.hideInvoiceDesc ? undefined : 'autowithdraw to LNbits from SN'
> const body = JSON.stringify({ amount, unit: 'sat', expiry, memo, out: false })
>
> + url = 'http://lnbits:5000'
> const res = await fetch(url + path, { method: 'POST', headers, body })
> if (!res.ok) {
> const errBody = await res.json()
> ```
>
LNbits' database is seeded with a superuser (see https://docs.lnbits.org/guide/admin_ui.html).

The following credentials were used:

- username: `stackernews`
- password: `stackernews`

To get access to the superuser, you need to visit the admin UI:

http://localhost:5001/wallet?usr=e46288268b67457399a5fca81809573e

After that, the cookies will be set to access this wallet:

http://localhost:5001/wallet?&wal=15ffe06c74cc4082a91f528d016d9028

Or simply copy the keys from here:

* admin key: `640cc7b031eb427c891eeaa4d9c34180`

* invoice key: `5deed7cd634e4306bb5e696f4a03cdac`

These keys can be found under `Node URL, API keys and API docs`.

0 comments on commit aacd2df

Please sign in to comment.