What is Phoenixd
Phoenixd is a daemon that can run on your infrastructure and provides you with a non-custodial node (so we own the private keys), with built-in liquidity management. You therefore do not have to worry about opening and/or closing channels and any other "thing" inherent to the node.
Find more details on the phoenixd website https://phoenix.acinq.co/server/ .
In this tutorial we are going to install the phoenixd daemon and integrate LNBits to be able to operate directly from the web interface.
- Requirements:
VPS;
Domain (optional for LN address);
More or less 20 minutes of your time;
Let's proceed by carrying out the security steps you find in this article of mine 👉🏻 https://medium.com/@giuxfila/come-rendere-sicuro-il-proprio-server-vps-a3a99c9fb3db
Installing phoenixd
Before proceeding with the installation of the node we must download the unzip and wget packages by running the command:
sudo apt-get install -y unzip wgetget install -y unzip wget
Let's now proceed by downloading the phoneixd daemon by running the command:
wget https://github.com/ACINQ/phoenixd/releases/download/v0.1.3/phoenix-0.1.3-linux-x64.zip
(let's remember to always download the latest version available in the official phoenixd repository 👉🏻 https://github.com/ACINQ/phoenixd/releases/ ).
Once the phoenixd .zip file has been downloaded, let's unzip it:
unzip phoenix-0.3.1-linux-x64.zip && sudo rm -r phoenix-0.3.1-linux-x64.zip0.3 .1 -linux-x64. zip && sudo rm -r phoenix- 0.3 .1 -linux-x64. zip
(the file name changes depending on the version you downloaded).
With the rm -r command we then delete the .zip file;
Once the file has been downloaded and unzipped, we will find the " phoenix-0.3.1-linux-x64 " directory (always specifying that the numbers relate to the version and therefore could change in your case), just enter this directory :
cd phoenix-0.3.1-linux-x64
and then launch the command
./phoenixd
2024-07-27 10:26:12 datadir: /home/users/.phoenix
2024-07-27 10:26:12 chain: Mainnet
2024-07-27 10:26:12 autoLiquidity: 2000000 sat
2024-07- 27 10:26:12 nodeid: STRINGHE_DI_NUMERI
2024-07-27 10:26:12 offer: STRINGHE_DI_NUMERI
2024-07-27 10:26:12 connecting to lightning peer...
2024-07-27 10:26:12 connected to lightning peer
2024-07-27 10:26:12 listening on http://127.0.0.1:9740
2024-07-27 10:26:12 fee credit: 0 sat
At this moment we have successfully started our daemon.
To make sure that everything is working correctly, open another shell and start the ssh connection with our server again, then head to the phoenix folder
cd phoenix-0.3.1-linux-x64
./phoenix-cli getinfo
You will receive a response like this:
./phoenix-cli getinfo
{
"nodeId": "iltuonodoid","nodeId" : "iltuonodoid" ,
"channels" : [
],
"chain" : "mainnet" ,
"blockHeight" : 854479,
"version" : "0.3.1-b735020"
Our node is fully functional and ready to use.
Integration with systemd, for automatic startup
Once our VPS is closed and restarted we should relaunch the “./phoneixd” code to start the node again etc etc.
Given that we want to receive payment 24 hours a day, without having any kind of hassle, we are going to create a service that starts AUTOMATICALLY.
First let's create a file in the systemd directory:
sudo nano /etc/systemd/system/phoenixd.service
let's copy this code changing the affected items
[Unit]
Description =phonenixd
After =network.target
[Service]
ExecStart =/home/giuseppe/phoenix- 0.3 . 1 -linux-x64/phoenixd --agree-to-terms-of-service
Restart =always
User =root
[Install]
WantedBy =multi-user.target
At this point we save the file, CTRL+X and "Y" to confirm, launch these two commands to enable and start the phoenixd server
sudo systemctl enable phoenixd.serviceenable phoenixd.service
sudo systemctl start phoenixd.service
REMEMBER TO MAKE A BACKUP OF THE SEED!
To back up our 12 (twelve) words we go to the hidden ./phoenix folder and view the seed.
cat .phoenix/seed.dat
Installation and integration with LNBits
The tool made available by ACINQ, phoenixd, is truly VERY powerful, because it allows us to run a node with 3 commands, and have managed the entire balancing part and a thousand other "things" which, especially for newbies, can be difficult and complex .
To make everything simpler and more pleasant with a WebUI we will connect the previously set phoenixd node with an instance of LNBits.
LNbits can be defined as an account system for your Lightning Network node, with the ability to add many extensions. Typically a Lightning Network node can manage only one Lightning wallet.
Installing LNBits
To install LNBits in this guide we will use (poetry), to do this we are going to download and install python
sudo apt updateupdate
sudo apt install software - properties - common
sudo add - apt - repository ppa:deadsnakes / ppa
sudo apt install python3 .9 python3 .9 - distutils
Once python has been confirmed and installed, let's install poetry
curl -sSL https://install.python-poetry.org | python3 -
Once the poetry installation is complete, we use the installation path printed on the terminal and replace it in the following command:
export PATH= "/home/user/.local/bin: $PATH "
Let's copy the lnbits repository, then enter the folder and then change the current working context to the "main" branch.
git clone https://github.com/lnbits/lnbits.gitclone https://github.com/lnbits/lnbits.git
cd lnbits
git checkout main
Now, we need to check our version of python, run the command:
python3 --version--version
let's write down our version and then move on to downloading the libraries (in my case the python3 version is 3.10.12, change the command based on your version), before proceeding with this command we log in again:
poetry env use python3.1010
poetry install --only main
Next, we create a “data” folder and create a file with all the variables with the name “.env”
mkdir data
Database creation with PostgreSQL
Let's download and install postgresql
sudo apt-get -y install postgresqlget -y install postgresql
We access the postgresql user shell and then launch the psql command
sudo -i -u postgresi -u postgres
psql
In this screen we are going to add a new database with a strong password!!:
ALTER USER postgres PASSWORD '!UnaPasswordBellaStrong!' ;
Now let's go out
We create the lnbits database and then exit
createdb lnbits
exit
Now let's make sure we are in the main lnbits folder and create an .env file
nano .envenv
Let's copy these basic configurations for LNBits:
LNBITS_ADMIN_UI = true
Change themeChange theme
LNBITS_SITE_TITLE = "LNbits"
LNBITS_SITE_TAGLINE = "free and open-source lightning wallet"
LNBITS_SITE_DESCRIPTION = "The world's most powerful suite of bitcoin tools. Run for yourself, for others, or as part of a stack."
Choose from bitcoin, mint, flamingo, freedom, salvador, autumn, monochrome, classic, cyberChoose from bitcoin, mint, flamingo, freedom, salvador, autumn, monochrome, classic, cyber
LNBITS_THEME_OPTIONS = "classic, bitcoin, flamingo, freedom, mint, autumn, monochrome, salvador, cyber"
LNBITS_CUSTOM_LOGO="https://lnbits .com/assets/images/logo/logo.svg"LNBITS_CUSTOM_LOGO="https://lnbits .com/assets/images/logo/logo.svg"
HOST = 127.0 . 0.1
PORT = 5000
########################################
######## ## Funding Source ############
#################################### ####
which fundingsources are allowed in the admin uiwhich fundingsources are allowed in the admin ui
LNBITS_ALLOWED_FUNDING_SOURCES = "PhoenixdWallet"
LNBITS_BACKEND_WALLET_CLASS =PhoenixdWallet
PhoenixdWalletPhoenixdWallet
PHOENIXD_API_ENDPOINT =http:// 127.0 . 0.1 : 9740 /
PHOENIXD_API_PASSWORD =THE PASSWORD OF PHOENIXD
########################################
## Auth Configurations## Auth Configurations
###################################### ##
Secret Key: will default to the hash of the super user. It is strongly recommended that you set your own value.Secret Key: will default to the hash of the super user. It is strongly recommended that you set your own value.
AUTH_SECRET_KEY = ""
AUTH_TOKEN_EXPIRE_MINUTES = 525600
Possible authorization methods: user-id-only, username-password, google-auth, github-auth, keycloak-authPossible authorization methods: user-id-only, username-password, google-auth, github-auth, keycloak-auth
AUTH_ALLOWED_METHODS = "user-id-only, username-password"
Set this flag if HTTP is used for OAuthSet this flag if HTTP is used for OAuth
OAUTHLIB_INSECURE_TRANSPORT="1"OAUTHLIB_INSECURE_TRANSPORT="1"
Google OAuth ConfigGoogle OAuth Config
Make sure that the authorized redirect URIs contain https://{domain}/api/v1/auth/google/tokenMake sure that the authorized redirect URIs contain https://{domain}/api/v1/auth/google/token
GOOGLE_CLIENT_ID = ""
GOOGLE_CLIENT_SECRET = ""
GitHub OAuth ConfigGitHub OAuth Config
Make sure that the authorization callback URL is set to https://{domain}/api/v1/auth/github/tokenMake sure that the authorization callback URL is set to https://{domain}/api/v1/auth/github/token
GITHUB_CLIENT_ID = ""
GITHUB_CLIENT_SECRET = ""
Keycloak OAuth ConfigKeycloak OAuth Config
Make sure that the valid redirect URIs contain https://{domain}/api/v1/auth/keycloak/tokenMake sure that the valid redirect URIs contain https://{domain}/api/v1/auth/keycloak/token
KEYCLOAK_CLIENT_ID = ""
KEYCLOAK_CLIENT_SECRET = ""
KEYCLOAK_DISCOVERY_URL = ""
######################################
uvicorn variable, uncomment to allow https behind a proxyuvicorn variable, uncomment to allow https behind a proxy
IMPORTANT: this also needs the webserver to be configured to forward the headersIMPORTANT: this also needs the webserver to be configured to forward the headers
http://docs.lnbits.org/guide/installation.html#running-behind-an-apache2-reverse-proxy-over-httpshttp://docs.lnbits.org/guide/installation.html#running-behind-an-apache2-reverse-proxy-over-https
FORWARDED_ALLOW_IPS="*"FORWARDED_ALLOW_IPS="*"
Server security, rate limiting ips, blocked ips, allowed ipsServer security, rate limiting ips, blocked ips, allowed ips
LNBITS_RATE_LIMIT_NO = "200"
LNBITS_RATE_LIMIT_UNIT = "minute"
LNBITS_ALLOWED_IPS = ""
LNBITS_BLOCKED_IPS = ""
Allow users and admins by user IDs (comma separated list)Allow users and admins by user IDs (comma separated list)
if set new users will not be able to create accountsif set new users will not be able to create accounts
LNBITS_ALLOWED_USERS = ""
LNBITS_ADMIN_USERS = ""
ID of the super user. The user ID must exist.ID of the super user. The user ID must exist.
SUPER_USER=""SUPER_USER=""
Extensions only admin can accessExtensions only admin can access
LNBITS_ADMIN_EXTENSIONS = "ngrok, admin"
Extensions enabled by default when a user is createdExtensions enabled by default when a user is created
LNBITS_USER_DEFAULT_EXTENSIONS = "lnurlp"
Start LNbits core only. The extensions are not loaded.Start LNbits core only. The extensions are not loaded.
LNBITS_EXTENSIONS_DEACTIVATE_ALL=trueLNBITS_EXTENSIONS_DEACTIVATE_ALL=true
Disable account creation for new usersDisable account creation for new users
LNBITS_ALLOW_NEW_ACCOUNTS=falseLNBITS_ALLOW_NEW_ACCOUNTS=false
Enable Node Management without activating the LNBITS Admin GUIEnable Node Management without activating the LNBITS Admin GUI
by setting the following variables to true.by setting the following variables to true.
LNBITS_NODE_UI = false
LNBITS_PUBLIC_NODE_UI = false
Enabling the transactions tab can cause crashes on large Core Lightning nodes.Enabling the transactions tab can cause crashes on large Core Lightning nodes.
LNBITS_NODE_UI_TRANSACTIONS = false
LNBITS_DEFAULT_WALLET_NAME = "LNbits wallet"
Ad space descriptionAd space description
LNBITS_AD_SPACE_TITLE="Supported by"LNBITS_AD_SPACE_TITLE="Supported by"
csv ad space, format "<url>;<img-light>;<img-dark>, <url>;<img- light>;<img-dark>", extensions can choose to honorcsv ad space, format "<url>;<img-light>;<img-dark>, <url>;<img- light>;<img-dark>", extensions can choose to honor
LNBITS_AD_SPACE="https://shop.lnbits.com/;https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits/static/ images/lnbits-shop-light.png;https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits/static/images/lnbits-shop-dark.png"LNBITS_AD_SPACE="https://shop.lnbits.com/;https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits/static/ images/lnbits-shop-light.png;https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits/static/images/lnbits-shop-dark.png"
LNBITS_SHOW_HOME_PAGE_ELEMENTS=true # if set to true, the ad space will be displayed on the home pageLNBITS_SHOW_HOME_PAGE_ELEMENTS=true # if set to true, the ad space will be displayed on the home page
LNBITS_CUSTOM_BADGE="USE WITH CAUTION - LNbits wallet is still in BETA"LNBITS_CUSTOM_BADGE="USE WITH CAUTION - LNbits wallet is still in BETA"
LNBITS_CUSTOM_BADGE_COLOR="warning"LNBITS_CUSTOM_BADGE_COLOR="warning"
Hides wallet api,extensions can choose to honorHides wallet api,extensions can choose to honor
LNBITS_HIDE_API = false
LNBITS_EXTENSIONS_MANIFESTS="https://raw.githubusercontent.com/lnbits/lnbits-extensions/main/extensions.json,https://raw.githubusercontent.com/lnbits/lnbits-extensions/main/extensions-trial.json"LNBITS_EXTENSIONS_MANIFESTS="https://raw.githubusercontent.com/lnbits/lnbits-extensions/main/extensions.json,https://raw.githubusercontent.com/lnbits/lnbits-extensions/main/extensions-trial.json"
GitHub has rate-limits for its APIs. The limit can be increased by specifying a GITHUB_TOKENGitHub has rate-limits for its APIs. The limit can be increased by specifying a GITHUB_TOKEN
LNBITS_EXT_GITHUB_TOKEN=github_pat_xxxxxxxxxxxxxxxxxxLNBITS_EXT_GITHUB_TOKEN=github_pat_xxxxxxxxxxxxxxxxxx
Path where extensions will be installed (defaults to ./lnbits/).Path where extensions will be installed (defaults to ./lnbits/).
Inside this directory the extensions and upgrades sub-directories will be created.Inside this directory the extensions and upgrades sub-directories will be created.
LNBITS_EXTENSIONS_PATH="/path/to/some/dir"LNBITS_EXTENSIONS_PATH="/path/to/some/dir"
Extensions to be installed by default. If an extension from this list is uninstalled then it will be re-installed on the next restart.Extensions to be installed by default. If an extension from this list is uninstalled then it will be re-installed on the next restart.
The extension must be removed from this list in order not to be re-installed.The extension must be removed from this list in order not to be re-installed.
LNBITS_EXTENSIONS_DEFAULT_INSTALL = "tpos"
Database: to use SQLite, specify LNBITS_DATA_FOLDERDatabase: to use SQLite, specify LNBITS_DATA_FOLDER
to use PostgreSQL, specify LNBITS_DATABASE_URL=postgres://...to use PostgreSQL, specify LNBITS_DATABASE_URL=postgres://...
to use CockroachDB, specify LNBITS_DATABASE_URL=cockroachdb://...to use CockroachDB, specify LNBITS_DATABASE_URL=cockroachdb://...
for both PostgreSQL and CockroachDB , you'll need to installfor both PostgreSQL and CockroachDB , you'll need to install
psycopg2 as an additional dependencypsycopg2 as an additional dependency
LNBITS_DATA_FOLDER = "./data"
LNBITS_DATABASE_URL = "postgres://user:password@host:port/databasename"
the service fee (in percent)the service fee (in percent)
LNBITS_SERVICE_FEE = 0.0
the wallet where fees go tothe wallet where fees go to
LNBITS_SERVICE_FEE_WALLET=LNBITS_SERVICE_FEE_WALLET=
the maximum fee per transaction (in satoshis)the maximum fee per transaction (in satoshis)
LNBITS_SERVICE_FEE_MAX=1000LNBITS_SERVICE_FEE_MAX=1000
disable fees for internal transactionsdisable fees for internal transactions
LNBITS_SERVICE_FEE_IGNORE_INTERNAL=trueLNBITS_SERVICE_FEE_IGNORE_INTERNAL=true
value in millisatsvalue in millisats
LNBITS_RESERVE_FEE_MIN = 2000
value in percentvalue in percent
PERCENT = 1.0
limit the maximum balance for each walletlimit the maximum balance for each wallet
throw an error if the wallet attempts to create a new invoicethrow an error if the wallet attempts to create a new invoice
LNBITS_WALLET_LIMIT_MAX_BALANCE=1000000LNBITS_WALLET_LIMIT_MAX_BALANCE=1000000
LNBITS_WALLET_LIMIT_DAILY_MAX_WITHDRAW=1000000LNBITS_WALLET_LIMIT_DAILY_MAX_WITHDRAW=1000000
LNBITS_WALLET_LIMIT_SECS_BETWEEN_TRANS=60LNBITS_WALLET_LIMIT_SECS_BETWEEN_TRANS=60
Limit fiat currencies allowed to see in UILimit fiat currencies allowed to see in UI
LNBITS_ALLOWED _CURRENCIES="EUR, USD"LNBITS_ALLOWED _CURRENCIES="EUR, USD"
Logging and DevelopmentLogging and Development
########################################
DEBUG = false
DEBUG_DATABASE = false
BUNDLE_ASSETS = true
logging into LNBITS_DATA_FOLDER/logs/logging into LNBITS_DATA_FOLDER/logs/
ENABLE_LOG_TO_FILE = true
https://loguru.readthedocs.io/en/stable/api/logger.html#filehttps://loguru.readthedocs.io/en/stable/api/logger.html#file
LOG_ROTATION = "100 MB"
LOG_RETENTION = "3 months"
for database cleanup commandsfor database cleanup commands
CLEANUP_WALLETS_DAYS=90CLEANUP_WALLETS_DAYS=90
The fields to modify are:
PHOENIXD_API_PASSWORD= insert the password that we find in the hidden .phoenix folder in the main directory, under the http-password entry:
LNBITS_DATABASE_URL= insert the username and password of our database, following the example in this tutorial it's like this, “postgres://postgres:!UnaPasswordBellaStrong!@postgres:5432/lnbits”
nano .phoenix/phoenix.conf
We execute the LNBits startup command, at the first startup having specified the variable LNBITS_ADMIN_UI=true we must create the SuperUser account, choose a nice STRONG password!
poetry run lnbits --port 5000 --host 0.0.0.0--port 5000 --host 0.0 . 0.0
By connecting now from IPADDRESS:5000 we will have our LNBits instance connected to the phoenixd node.
Integration with systemd, for automatic startup
Even for LNbits like Phoenixd, to access your instance we should launch the above command every time. So let's now create a service via systemd to start lnbits every time the server starts.
Let's create a new service in the systemd directory
sudo nano /etc/systemd/system/lnbits.service
we copy the following code changing the variables:
ExecStart=/home/lnbits/.local/bin/poetry run (change the variable with the directory where you downloaded the lnbits repo)
User=lnbits (change the variable with your username)
[Unit]
Description =LNbits
[Service]
WorkingDirectory =/home/lnbits/lnbits
ExecStart =/home/lnbits/.local/bin/poetry run lnbits --port 5000 --host 0.0 . 0.0
User =lnbits
Restart =always
TimeoutSec = 120
RestartSec = 30
Environment =PYTHONUNBUFFERED= 1
[Install]
WantedBy =multi-user.target
At this point we save with CTRL+X and "y" to confirm, then enable the service and start it:
sudo systemctl enable lnbits.serviceenable lnbits.service
sudo systemctl start lnbits.service
At this point all we have to do is check that everything is working, send us some sats and make a payment!
**Translated from Italian to English:**https://medium.com/@giuxfila/guida-allinstallazione-di-un-nodo-cloud-non-custodial-con-lnbits-7d9acdb2f00f