Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/0.12.11 #44

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM lnbits/lnbits:0.12.10 AS builder
FROM lnbits/lnbits:v0.12.11 AS builder

# arm64 or amd64
ARG PLATFORM

RUN apt-get update && apt-get install -y bash curl sqlite3 tini --no-install-recommends
RUN curl -sS https://webi.sh/yq | sh

FROM lnbits/lnbits:0.12.10 AS final
FROM lnbits/lnbits:v0.12.11 AS final

COPY --from=builder /usr/bin/tini /usr/bin/tini
COPY --from=builder /usr/bin/sqlite3 /usr/bin/sqlite3
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ lnbits-startos contains the [lnbits](https://github.com/lnbits/lnbits) software

## Dependencies

- [deno](https://deno.land/)
- [docker](https://docs.docker.com/get-docker)
- [docker-buildx](https://docs.docker.com/buildx/working-with-buildx/)
- [yq](https://mikefarah.gitbook.io/yq)
- [deno](https://deno.land/)
- [make](https://www.gnu.org/software/make/)
- [start-sdk](https://github.com/Start9Labs/start-os/tree/sdk)
- [start-sdk](https://github.com/Start9Labs/start-os/blob/v0.3.5.1/core/install-sdk.sh)
- [yq](https://mikefarah.gitbook.io/yq)

## Build environment

Expand Down
128 changes: 62 additions & 66 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,18 @@ if [ -f $FILE ]; then
echo "Deleting previous LN implementation data"
rm $FILE
rm /app/data/start9/stats.yaml
else
echo "Looking for existing accounts and wallets..."
sqlite3 ./data/database.sqlite3 'select id from accounts;' >>account.res
mapfile -t LNBITS_ACCOUNTS <account.res
echo "Found ${#LNBITS_ACCOUNTS[*]} existing LNBits account(s)."
fi
# Create flag for Auth Initilization
if ! [ -f '/app/data/start9/auth_initialized' ]; then
touch /app/data/start9/auth_initialized
fi
fi

if [ -f $FILE ]; then
echo "Looking for existing accounts and wallets..."
sqlite3 ./data/database.sqlite3 'select id from accounts;' >>account.res
mapfile -t LNBITS_ACCOUNTS <account.res
echo "Found ${#LNBITS_ACCOUNTS[*]} existing LNBits account(s)."
echo "Navigate to the following URLs to access these accounts:"
for USER_ID in "${LNBITS_ACCOUNTS[@]}"; do
ACCOUNT_URL="http://$TOR_ADDRESS/wallet?usr=$USER_ID"
printf "$ACCOUNT_URL\n"
done
else
echo 'No LNBits accounts found.'
echo "No existing database found. Starting LNbits with a new database using $LNBITS_BACKEND_WALLET_CLASS"
fi

if [ $LNBITS_BACKEND_WALLET_CLASS == "LndRestWallet" ]; then
Expand All @@ -73,6 +66,7 @@ configurator() {
ADMIN_PASS=$(cat /app/data/start9/admin_password.txt)
LNBITS_SETTINGS=$(sqlite3 ./data/database.sqlite3 'select editable_settings from settings;')
PUBLIC_UI=$(echo "$LNBITS_SETTINGS" | jq ".lnbits_public_node_ui")
USER_ID_ONLY=$(sqlite3 ./data/database.sqlite3 'select editable_settings from settings;' | jq '.auth_allowed_methods | any(index("user-id-only"))')

echo 'version: 2' >/app/data/start9/stats.yaml
echo 'data:' >>/app/data/start9/stats.yaml
Expand Down Expand Up @@ -104,60 +98,62 @@ configurator() {
echo ' qr: true' >>/app/data/start9/stats.yaml
fi

echo " Superuser Account: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$SUPERUSER_ACCOUNT_URL_PROP\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Superuser Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml
echo " (Tor) Superuser Account: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$SUPERUSER_ACCOUNT_URL_TOR\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Superuser Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml

sqlite3 ./data/database.sqlite3 'select id from accounts;' >account.res
mapfile -t LNBITS_ACCOUNTS <account.res
# Iterate over the indices of the array in reverse order
for i in $(seq $((${#LNBITS_ACCOUNTS[@]} - 1)) -1 0); do {
# Access the array element at the current index
USER_ID=${LNBITS_ACCOUNTS[$i]}
# get wallets for this user account
sqlite3 ./data/database.sqlite3 'select id from wallets where user="'$USER_ID'";' >wallet.res
mapfile -t LNBITS_WALLETS <wallet.res
# Iterate over the indices of the array in reverse order
for j in $(seq $((${#LNBITS_WALLETS[@]} - 1)) -1 0); do {
# Access the array element at the current index

export WALLET_ID=${LNBITS_WALLETS[$j]}
export ACCOUNT_URL_PROP="https://$LAN_ADDRESS/wallet?usr=$USER_ID&wal=$WALLET_ID"
export ACCOUNT_URL_TOR="http://$TOR_ADDRESS/wallet?usr=$USER_ID&wal=$WALLET_ID"
export LNBITS_WALLET_NAME=$(sqlite3 ./data/database.sqlite3 'select name from wallets where id="'$WALLET_ID'";')
export LNBITS_WALLET_DELETED=$(sqlite3 ./data/database.sqlite3 'select deleted from wallets where id="'$WALLET_ID'";')

if ! [ "$SUPERUSER_ACCOUNT" = "$USER_ID" ] && [ $LNBITS_WALLET_DELETED = 0 ]; then
echo " LNBits Account $USER_ID - Wallet $LNBITS_WALLET_NAME: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$ACCOUNT_URL_PROP\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml
echo " (Tor) LNBits Account $USER_ID - Wallet $LNBITS_WALLET_NAME: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$ACCOUNT_URL_TOR\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml
fi
}; done
}; done
if [ "$USER_ID_ONLY" == "true" ]; then
echo " Superuser Account: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$SUPERUSER_ACCOUNT_URL_PROP\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Superuser Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml
echo " (Tor) Superuser Account: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$SUPERUSER_ACCOUNT_URL_TOR\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Superuser Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml

sqlite3 ./data/database.sqlite3 'select id from accounts;' >account.res
mapfile -t LNBITS_ACCOUNTS <account.res
# Iterate over the indices of the array in reverse order
for i in $(seq $((${#LNBITS_ACCOUNTS[@]} - 1)) -1 0); do {
# Access the array element at the current index
USER_ID=${LNBITS_ACCOUNTS[$i]}
# get wallets for this user account
sqlite3 ./data/database.sqlite3 'select id from wallets where user="'$USER_ID'";' >wallet.res
mapfile -t LNBITS_WALLETS <wallet.res
# Iterate over the indices of the array in reverse order
for j in $(seq $((${#LNBITS_WALLETS[@]} - 1)) -1 0); do {
# Access the array element at the current index

export WALLET_ID=${LNBITS_WALLETS[$j]}
export ACCOUNT_URL_PROP="https://$LAN_ADDRESS/wallet?usr=$USER_ID&wal=$WALLET_ID"
export ACCOUNT_URL_TOR="http://$TOR_ADDRESS/wallet?usr=$USER_ID&wal=$WALLET_ID"
export LNBITS_WALLET_NAME=$(sqlite3 ./data/database.sqlite3 'select name from wallets where id="'$WALLET_ID'";')
export LNBITS_WALLET_DELETED=$(sqlite3 ./data/database.sqlite3 'select deleted from wallets where id="'$WALLET_ID'";')

if ! [ "$SUPERUSER_ACCOUNT" = "$USER_ID" ] && [ $LNBITS_WALLET_DELETED = 0 ]; then
echo " LNBits Account $USER_ID - Wallet $LNBITS_WALLET_NAME: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$ACCOUNT_URL_PROP\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml
echo " (Tor) LNBits Account $USER_ID - Wallet $LNBITS_WALLET_NAME: " >>/app/data/start9/stats.yaml
echo ' type: string' >>/app/data/start9/stats.yaml
echo " value: \"$ACCOUNT_URL_TOR\"" >>/app/data/start9/stats.yaml
echo ' description: LNBits Account' >>/app/data/start9/stats.yaml
echo ' copyable: true' >>/app/data/start9/stats.yaml
echo ' masked: true' >>/app/data/start9/stats.yaml
echo ' qr: true' >>/app/data/start9/stats.yaml
fi
}; done
}; done
fi
else
echo 'No accounts to populate'
echo 'No existing database found.'
fi
sleep 10
}; done
Expand Down
7 changes: 3 additions & 4 deletions instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ LNbits is a robust and versatile platform, serving as a comprehensive hub for Li

## Using LNbits

To use LNbits, simply click `LAUNCH UI` where you will be prompted to login or register. StartOS automatically saves your wallet URLs and displays them in the `Properties` page of your LNbits service dashboard. If an existing LNbits account is already logged in, `LAUNCH UI` will open that account instead of prompting the user to login or register. If an account is already logged in and you would like to register another account, you will first need to log out of the logged in account. As a corollary, only one LNbits account can be logged into the same browser at a time. If a LNbits account is already logged in and the URL for a different account is opened you may encounter the error `Wallet not found` or the previously logged in account may be displayed - in either case hard refreshing the page will log in the account of the URL entered and log out the other account.

To use LNbits, simply click `LAUNCH UI` where you will be prompted to login or register. If `user-id-only` is enabled as an 'Authorization Method' (not recommended for security) StartOS will automatically save your wallet URLs and display them in the `Properties` page of your LNbits service dashboard. If an existing LNbits account is already logged in, `LAUNCH UI` will open that account instead of prompting the user to login or register. If an account is already logged in and you would like to register another account, you will first need to log out of the logged in account. As a corollary, only one LNbits account can be logged into a given browser at a time. If a LNbits account is already logged in and the URL for a different account is opened you may encounter the error `Wallet not found` or the previously logged in account may be displayed - in either case hard refreshing the page will log in the account of the URL entered and log out the other account.

## Superuser
LNbits includes a `Superuser Account` which can also be found in `Properties` along with the default username and password. This account can be used to manage the server, allowing the user to add extensions, topup wallets, etc.

The `Superuser Account` can also change the authentication required to access accounts. By default authentication is not required for users updating to 0.12.2, meaning accounts remain accessible via the URLs found in properties; accounts can also be accessed using username/password (provided these have been set). For fresh installations of 0.12.2 username and password are required by default. Allowed authentication methods can be updated by opening the Superuser account and navivating to `Server` > `Security`.
The `Superuser Account` can also change the authentication required to access accounts. By default authentication is not required for users who updated to 0.12.2 from an earlier version, meaning accounts remain accessible via the URLs found in properties; accounts can also be accessed using username/password (provided these have been set). For fresh installations >= 0.12.2 username and password are required by default. Allowed authentication methods can be updated by opening the Superuser account and navivating to `Server` > `Security`.

**Warning** If authentication is updated to only allow the `username-password` method, this will make any accounts which have not yet setup a username and password *inaccessible* until authentication is reverted to include the `user-id-only` method. Before changing the allowed authentication methods, it is highly recommended to ensure any existing accounts have been updated to include both a username and a password; login credentials should be stored securely (i.e. within Vaultwarden).
**Warning** If authentication previously allowed the `user-id-only` method is updated to disallow this method, any accounts which have not yet setup a username and password will be *inaccessible* until authentication is reverted to include the `user-id-only` method. Before changing the allowed authentication methods, it is highly recommended to ensure any existing accounts have been updated to include both a username and a password; login credentials should be stored securely (i.e. within Vaultwarden).

**If the Superuser password is updated via the LNbits UI, make sure this password is stored securely as it will *NOT* be updated in `Properties`**

Expand Down
6 changes: 4 additions & 2 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
id: lnbits
title: "LNBits"
version: 0.12.10
version: 0.12.11
release-notes: |
* Update LNbits to 0.12.10 - Full release notes available [here](https://github.com/lnbits/lnbits/releases/tag/0.12.10).
* Update LNbits to 0.12.11 - Full release notes available [here](https://github.com/lnbits/lnbits/releases/tag/v0.12.11).
* Optimizations and refactoring
* Update README and Instructions
license: MIT
wrapper-repo: "https://github.com/Start9Labs/lnbits-startos"
upstream-repo: "https://github.com/lnbits/lnbits"
Expand Down
2 changes: 1 addition & 1 deletion scripts/services/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const migration: T.ExpectedExports.migration = compat.migrations
),
},
},
"0.12.10",
"0.12.11",
);