Skip to content

Instantly share code, notes, and snippets.

@petzsch
Last active April 6, 2024 14:47
Show Gist options
  • Save petzsch/2995d2ca25cf598b6b95f1f6fe39e5bf to your computer and use it in GitHub Desktop.
Save petzsch/2995d2ca25cf598b6b95f1f6fe39e5bf to your computer and use it in GitHub Desktop.
LNBits Fragment for BTCPay Server
HOST=0.0.0.0
PORT=80
# uvicorn variable, allow https behind a proxy
FORWARDED_ALLOW_IPS="*"
DEBUG=false
# Allow users and admins by user IDs (comma separated list)
#LNBITS_ALLOWED_USERS="UID"
#LNBITS_ADMIN_USERS="UID"
# Extensions only admin can access
LNBITS_ADMIN_EXTENSIONS="ngrok, admin"
# Enable Admin GUI, available for the first user in LNBITS_ADMIN_USERS if available
# Warning: Enabling this will make LNbits ignore this configuration file. Your settings will
# be stored in your database and you will be able to change them only through the Admin UI.
# Disable this to make LNbits use this config file again.
LNBITS_ADMIN_UI=true
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
# Ad space description
# LNBITS_AD_SPACE_TITLE="Supported by"
# csv ad space, format "<url>;<img-light>;<img-dark>, <url>;<img-light>;<img-dark>", extensions can choose to honor
# LNBITS_AD_SPACE=""
# Hides wallet api, extensions can choose to honor
LNBITS_HIDE_API=false
# Disable extensions for all users, use "all" to disable all extensions
LNBITS_DISABLED_EXTENSIONS="amilk"
# Database: to use SQLite, specify LNBITS_DATA_FOLDER
# to use PostgreSQL, specify LNBITS_DATABASE_URL=postgres://...
# to use CockroachDB, specify LNBITS_DATABASE_URL=cockroachdb://...
# for both PostgreSQL and CockroachDB, you'll need to install
# psycopg2 as an additional dependency
#LNBITS_DATA_FOLDER="./data"
LNBITS_DATABASE_URL="postgres://postgres@postgres/lnbits2"
LNBITS_FORCE_HTTPS=true
LNBITS_SERVICE_FEE="0.0"
# value in millisats
LNBITS_RESERVE_FEE_MIN=2000
# value in percent
LNBITS_RESERVE_FEE_PERCENT=1.0
# Change theme
LNBITS_SITE_TITLE="Lightning Service"
LNBITS_SITE_TAGLINE="free and open-source lightning wallet"
LNBITS_SITE_DESCRIPTION="Custodial Wallets for domain.tld merchants"
# Choose from bitcoin, mint, flamingo, freedom, salvador, autumn, monochrome, classic
LNBITS_THEME_OPTIONS="classic, bitcoin, flamingo, freedom, mint, autumn, monochrome, salvador"
# LNBITS_CUSTOM_LOGO="https://lnbits.com/assets/images/logo/logo.svg"
# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, ClicheWallet, LnTipsWallet
# LndRestWallet, CoreLightningWallet, LNbitsWallet, SparkWallet, FakeWallet, EclairWallet
LNBITS_BACKEND_WALLET_CLASS=LndRestWallet
# VoidWallet is just a fallback that works without any actual Lightning capabilities,
# just so you can see the UI before dealing with this file.
# Set one of these blocks depending on the wallet kind you chose above:
# ClicheWallet
#CLICHE_ENDPOINT=ws://127.0.0.1:12000
# SparkWallet
#SPARK_URL=http://localhost:9737/rpc
#SPARK_TOKEN=myaccesstoken
# CoreLightningWallet
#CORELIGHTNING_RPC="/data/.lightning/lightning-rpc"
# LnbitsWallet
#LNBITS_ENDPOINT=https://legend.lnbits.com
#LNBITS_KEY=LNBITS_ADMIN_KEY
# LndRestWallet
LND_REST_ENDPOINT=http://lnd_bitcoin:8080/
#LND_REST_CERT="/data/.lightning/tls.cert"
LND_REST_MACAROON="/data/.lightning/admin.macaroon"
# To use an AES-encrypted macaroon, set
# LND_REST_MACAROON_ENCRYPTED="eNcRyPtEdMaCaRoOn"
# LNPayWallet
#LNPAY_API_ENDPOINT=https://api.lnpay.co/v1/
# Secret API Key under developers tab
#LNPAY_API_KEY=LNPAY_API_KEY
# Wallet Admin in Wallet Access Keys
#LNPAY_WALLET_KEY=LNPAY_ADMIN_KEY
# LntxbotWallet
#LNTXBOT_API_ENDPOINT=https://lntxbot.com/
#LNTXBOT_KEY=LNTXBOT_ADMIN_KEY
# OpenNodeWallet
#OPENNODE_API_ENDPOINT=https://api.opennode.com/
#OPENNODE_KEY=OPENNODE_ADMIN_KEY
# FakeWallet
#FAKE_WALLET_SECRET="ToTheMoon1"
LNBITS_DENOMINATION=sats
# EclairWallet
#ECLAIR_URL=http://127.0.0.1:8283
#ECLAIR_PASS=eclairpw
# LnTipsWallet
# Enter /api in LightningTipBot to get your key
#LNTIPS_API_KEY=LNTIPS_ADMIN_KEY
#LNTIPS_API_ENDPOINT=https://ln.tips
# Cashu Mint
# Use a long-enough random (!) private key.
# Once set, you cannot change this key as for now.
CASHU_PRIVATE_KEY="SuperSecretPrivateKey"

This Gist is obsoleted with this PR.

You can now simply checkout the above PR and run lnbits as a docker fragment within BTCPay Server.

Here are the old steps of howto deploy it, in case someone still needs it:

  1. git clone https://github.com/lnbits/lnbits.git
  2. cd lnbits
  3. docker build -t lnbits:latest .
  4. customize the .env file and place it in /root/BTCPayServer/btcpayserver-docker/Generated/
  5. customize the opt-add-lnbits.custom.yml file and place it in /root/BTCPayServer/btcpayserver-docker/docker-compose-generator/docker-fragments/
  6. enable the fragment with: export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-lnbits.custom"
  7. and run: . btcpay-setup.sh -i
version: '3'
services:
lnbits:
image: lnbits:latest
restart: unless-stopped
environment:
LETSENCRYPT_HOST: lnbits.domain.tld
LETSENCRYPT_EMAIL: [email protected]
VIRTUAL_HOST: lnbits.domain.tld
VIRTUAL_HOST_NAME: "lnbits"
expose:
- "5000"
# depends_on:
# - postgres
# - clightning_bitcoin
links:
- postgres
- lnd_bitcoin
volumes:
- "lnd_bitcoin_datadir:/data/.lightning"
- .env:/app/.env
- ./data/:/app/data
@smartbrain
Copy link

Thank you, that was great help!

Because of postgres erroor messages, I had to change to LNBITS_DATA_FOLDER="./data" I also change PORT=80 to PORT=5000 (but I think it is ignored anyway.

I also did a new DNS Entry with new subdomain "lnbits" with same IP as "btcpay" DNS Entry. LETSENCRYPT_HOST: lnbits.mydomain.com LETSENCRYPT_EMAIL: [email protected] VIRTUAL_HOST: lnbits.mydomain.com VIRTUAL_HOST_NAME: "lnbits"

Now it works on https://lnbits.mydomain.com

Thank you again!

  • Peter.

Peter. Did you get the same bug that I'm now facing- user manager doesn't show any users and adding users in user manager doesn't add them to LNBits. Other than that everything is working fine on my fresh install. I have a funny feeling that user manager is hard coded to use postgres.

@pjw65
Copy link

pjw65 commented Jan 24, 2024

Peter. Did you get the same bug that I'm now facing- user manager doesn't show any users and adding users in user manager doesn't add them to LNBits. Other than that everything is working fine on my fresh install. I have a funny feeling that user manager is hard coded to use postgres.

I can add a (random) user-ID as Admin, save and restart. But when lnbits is called using that userid creating a new wallet, it says:
Error
User not authorized.
If you believe this shouldn't be an error please bring it up on https://t.me/lnbits

@normandmickey
Copy link

Installed this last night. Works great!

@petzsch
Copy link
Author

petzsch commented Mar 23, 2024

FYI: I've worked on getting this into the btcpayserver-docker repo: btcpayserver/btcpayserver-docker#873

It's probably better to deploy it this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment