diff --git a/.gitignore b/.gitignore index 0af635d4..3c6e77e2 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ data/ .wallet_secret .wallet_password .admin_enroll -admin.npub \ No newline at end of file +admin.npub +app.nprofile diff --git a/Dockerfile b/Dockerfile index 77d8a5f6..6001419a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,9 @@ RUN npm i COPY . /app +EXPOSE 1776 +EXPOSE 1777 + +VOLUME ["/app/data"] + CMD [ "npm", "start" ] diff --git a/README.md b/README.md index de3eb13e..32cc709e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# Lightning.Pub + ![Lightning.Pub](https://github.com/shocknet/Lightning.Pub/raw/master/pub_logo.png) ![GitHub last commit](https://img.shields.io/github/last-commit/shocknet/Lightning.Pub?style=flat-square) @@ -5,7 +7,6 @@ [![Chat](https://img.shields.io/badge/chat-on%20Telegram-blue?style=flat-square)](https://t.me/ShockBTC) ![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ShockBTC?style=flat-square&logo=bitcoin) - ### Don't just run a Lightning Node, run a Lightning Pub. "Pub" is a [Nostr](https://nostr.info)-native account system designed to make running Lightning infrastructure for your friends/family/customers easier than previously thought possible. @@ -22,25 +23,36 @@ Additionally, support for optional services are integrated into Pub for operator By solving the networking and programability hurdles, Pub provides Lightning with a 3rd Layer that enables node-runners, Busineses, and Uncle Jims to more easily bring their personal network into Bitcoin's permissionless economy. In doing so, Pub runners can keep the Lightning Network decentralized, with custodial scaling that is free of fiat rails, large banks, and other forms of high-time-preference shitcoinery. -#### Features: +## Table of Contents +- [Features](#features) +- [Planned Features](#planned-features) +- [Installation](#installation) + - [One-Line Deployment](#one-line-deployment) + - [Docker Installation](#docker-installation) + - [Manual CLI Installation](#manual-cli-installation) +- [Usage Notes](#usage-notes) +- [Misc](#support-development) + +## Features - Wrapper for [`LND`](https://github.com/lightningnetwork/lnd/releases) that can serve accounts over LNURL and NOSTR - A growing number of [methods](https://github.com/shocknet/Lightning.Pub/blob/master/proto/autogenerated/client.md) - Automated Channels - - Receives quotes from multiple LSPs including Zeus, Voltage, and Flashsats + - Receives quotes from multiple LSPs including Zeus, Voltage, and Flashsats - Bootstrap Peering - - A pub node may trust another pub node until it can afford a channel + - A pub node may trust another pub node until it can afford a channel - Accounting SubLayers for Application Pools and Users - - A fee regime allows applications owners to monetize users, or node operators to host distinctly monetized applications. + - A fee regime allows applications owners to monetize users, or node operators to host distinctly monetized applications. + ![Accounts](https://github.com/shocknet/Lightning.Pub/raw/master/accounting_layers.png) - Connecting via ShockWallet is as easy as pasting an nprofile - Or use a link to share your nprofile with friends and family - Connect Wallet Invite Guests +Connect Wallet Invite Guests +## Planned Features -#### Planned - [ ] A management dashboard is actively being integrated into [ShockWallet](https://github.com/shocknet/wallet2) - [ ] Nostr native "offers" (successor to LNURL-Pay, Lightning Address, Bxlt12) - [ ] P2P "LSP" coordination for channel batching over Nostr @@ -50,74 +62,86 @@ By solving the networking and programability hurdles, Pub provides Lightning wit Dashboard Wireframe: - Pub Dashboard +Pub Dashboard + +## Installation + +### One-Line Deployment + +Experimental-ish, this installs all dependencies and creates systemd entries. It has been tested in Ubuntu/Debian x64 environments, but is general enough that it should work on most systems. Mac support is there also, but untested. Please report any issues. + +Run the following command: + +```ssh +sudo wget -qO- https://deploy.lightning.pub | sudo bash +``` + +> Note: Automatic updates are not implemented, but running the script a second time in the future will gracefully upgrade the existing installation. + +### Docker Installation + +1. Pull the Docker image: + +```ssh +docker pull ghcr.io/shocknet/lightning-pub:latest +``` + +2. Run the Docker container: + +```ssh +docker run -d \ + --name lightning-pub \ + --network host \ + -p 1776:1776 \ + -p 1777:1777 \ + -v /path/to/local/data:/app/data \ + -v $HOME/.lnd:/root/.lnd \ + ghcr.io/shocknet/lightning-pub:latest +``` +Network host is used so the service can reach a local LND via localhost. LND is assumed to be under the users home folder, update this location as needed. + +### Manual CLI Installation + +1. Run [LND](https://github.com/lightningnetwork/lnd/releases) if you aren't already: + +```ssh +./lnd --bitcoin.active --bitcoin.mainnet --bitcoin.node=neutrino --neutrino.addpeer=neutrino.shock.network --feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json +``` + +2. Download and Install Lightning.Pub: + +```ssh +git clone https://github.com/shocknet/Lightning.Pub && cd Lightning.Pub && npm i +``` + +3. Configure values in the env file: + +```ssh +cp env.example .env && nano .env +``` + +4. Start the service: + +```ssh +npm start +``` + +## Usage Notes + +Connect with [wallet2](https://github.com/shocknet/wallet2) using the wallet admin string that gets logged at startup. The nprofile of the node can also be used to send invitation links to guests. + +Note that connecting with wallet will create an account on the node, it will not show or have access to the full LND balance. + +Additional docs are WIP at [docs.shock.network](https://docs.shock.network) + +## Support Development > [!IMPORTANT] -> ShockWallet and Lightning.Pub are free software. If you would like to see continued development, please show your [**support**](https://github.com/sponsors/shocknet) 😊
+> ShockWallet and Lightning.Pub are free software. If you would like to see continued development, please show your [**support**](https://github.com/sponsors/shocknet) 😊 License -
+ +## Warning > [!WARNING] -> While this software has been used in a high-profile production environment for over a year, it should still be considered bleeding edge. Special care has been taken to mitigate the risk of drainage attacks, which is a common risk to all Lightning API's. An integrated Watchdog service will terminate spends if it detects a discrepency between LND and the database, for this reason **IT IS NOT RECOMMENDED TO USE PUB ALONGSIDE OTHER ACCOUNT SYSTEMS**. While we give the utmost care and attention to security, **the internet is an adversarial environment and SECURITY/RELIABILITY ARE NOT GUARANTEED- USE AT YOUR OWN RISK**. - -## One-Line Deployment - -Experimental-ish, it has been tested in Ubuntu/Debian x64 environments but is general enough that it should work on most systems. Mac support is there also, but untested. Please report any issues. - -`sudo wget -qO- https://deploy.lightning.pub | sudo bash` - -Automatic updates are not implemented, but running the script a second time in the future will gracefully upgrade the existing installation. - -## Umbrel Installation - -Coming Soon - -## Desktop Installation - -Coming Soon - -## Docker (testing) - -`docker pull ghcr.io/shocknet/lightning-pub:latest` - -## Manual CLI Installation - -#### Notes: -* Use of a reverse proxy is only required if you wish to serve LNURLs -* The service defaults to port `1776` -* Requires [Node.js](https://nodejs.org) >=18.x -* Commands for your specific OS may differ slightly, Ubuntu/Debian used for example - -#### Steps: -1) Run [LND](https://github.com/lightningnetwork/lnd/releases) if you aren't already - -*Example mainnet startup*: - - ``` - ./lnd --bitcoin.active --bitcoin.mainnet --bitcoin.node=neutrino --neutrino.addpeer=neutrino.shock.network --feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json - ``` - - -2) Download and Install Lightning.Pub - - - * `git clone https://github.com/shocknet/Lightning.Pub` - - * `cd Lightning.Pub && npm i` - - -3) Configure values to env file as desired - * `cp env.example .env && nano .env` - -5) `npm start` - -- A default "wallet" application pool will be automatically created, if you wish to create other app pools: - - * `curl -XPOST -H 'Authorization: Bearer defined_in_ADMIN_TOKEN_env' -H "Content-type: application/json" -d '{"name":"ExampleApplicationPoolName"}' 'http://localhost:8080/api/admin/app/add'` - -5) Connect with [wallet2](https://github.com/shocknet/wallet2) using the wallet nprofile that gets logged at startup. -> [!NOTE] -> Connecting with wallet will create an account on the node, it will not show or have access to the full LND balance - - +> While this software has been used in a high-profile production environment for over a year, it should still be considered bleeding edge. Special care has been taken to mitigate the risk of drainage attacks, which is a common risk to all Lightning API's. An integrated Watchdog service will terminate spends if it detects a discrepency between LND and the database, for this reason **IT IS NOT RECOMMENDED TO USE PUB ALONGSIDE OTHER ACCOUNT SYSTEMS**. While we give the utmost care and attention to security, **the internet is an adversarial environment and SECURITY/RELIABILITY ARE NOT GUARANTEED- USE AT YOUR OWN RISK**. \ No newline at end of file diff --git a/env.example b/env.example index 19a60331..8a36d59e 100644 --- a/env.example +++ b/env.example @@ -9,7 +9,11 @@ #LND_CERT_PATH=~/.lnd/tls.cert #LND_MACAROON_PATH=~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon -LIQUIDITY_PROVIDER_PUB= +#BOOTSTRAP_PEER +# A trusted peer that will hold a node-level account until channel automation becomes affordable +# The developer is used by default or you may specify your own +# To disable this feature entirely overwrite the env with "null" +#LIQUIDITY_PROVIDER_PUB=null #DB #DATABASE_FILE=db.sqlite @@ -57,7 +61,7 @@ LSP_MAX_FEE_BPS=100 #NOSTR # Default relay may become rate-limited without a paid subscription -#NOSTR_RELAYS=wss://strfry.shock.network +#NOSTR_RELAYS=wss://relay.lightning.pub #LNURL # Optional diff --git a/package.json b/package.json index 9887bf9d..81e52105 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "lightning.pub", + "name": "lnpub", "version": "1.0.0", - "description": "", + "description": "A Nostr based account system and management platform for nodes on Bitcoin's Lightning Network", "main": "index.js", "scripts": { "clean": "rimraf build", @@ -19,7 +19,7 @@ }, "author": "", "type": "module", - "license": "ISC", + "license": "Affero GPLv3", "bugs": { "url": "https://github.com/shocknet/Lightning.Pub/issues" }, diff --git a/scripts/install_lightning_pub.sh b/scripts/install_lightning_pub.sh index c82be736..c28f43e2 100755 --- a/scripts/install_lightning_pub.sh +++ b/scripts/install_lightning_pub.sh @@ -10,7 +10,7 @@ install_lightning_pub() { fi log "${PRIMARY_COLOR}Installing${RESET_COLOR} ${SECONDARY_COLOR}Lightning.Pub${RESET_COLOR}..." - REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/fix/bootstrap" + REPO_URL="https://github.com/shocknet/Lightning.Pub/tarball/master" sudo -u $USER_NAME wget $REPO_URL -O $USER_HOME/lightning_pub.tar.gz > /dev/null 2>&1 || { log "${PRIMARY_COLOR}Failed to download Lightning.Pub.${RESET_COLOR}" @@ -45,7 +45,7 @@ install_lightning_pub() { fi # Merge if upgrade - rsync -av --exclude='*.sqlite' --exclude='.env' --exclude='logs' --exclude='node_modules' lightning_pub_temp/ lightning_pub/ > /dev/null 2>&1 + rsync -av --exclude='*.sqlite' --exclude='.env' --exclude='logs' --exclude='node_modules' --exclude='.jwt_secret' --exclude='.wallet_secret' --exclude='admin.npub' --exclude='app.nprofile' --exclude='.admin_connect' --exclude='.admin_enroll' lightning_pub_temp/ lightning_pub/ > /dev/null 2>&1 rm -rf lightning_pub_temp # Load nvm and npm diff --git a/src/services/main/liquidityManager.ts b/src/services/main/liquidityManager.ts index 38160e8c..0d7efbda 100644 --- a/src/services/main/liquidityManager.ts +++ b/src/services/main/liquidityManager.ts @@ -13,7 +13,7 @@ export type LiquiditySettings = { } export const LoadLiquiditySettingsFromEnv = (): LiquiditySettings => { const lspSettings = LoadLSPSettingsFromEnv() - const liquidityProviderPub = process.env.LIQUIDITY_PROVIDER_PUB || "" + const liquidityProviderPub = process.env.LIQUIDITY_PROVIDER_PUB === "null" ? "" : (process.env.LIQUIDITY_PROVIDER_PUB || "76ed45f00cea7bac59d8d0b7d204848f5319d7b96c140ffb6fcbaaab0a13d44e") return { lspSettings, liquidityProviderPub, useOnlyLiquidityProvider: false } } export class LiquidityManager { diff --git a/src/services/nostr/index.ts b/src/services/nostr/index.ts index f7cf3a38..845cbbd2 100644 --- a/src/services/nostr/index.ts +++ b/src/services/nostr/index.ts @@ -8,7 +8,7 @@ const getEnvOrDefault = (name: string, defaultValue: string): string => { } export const LoadNosrtSettingsFromEnv = (test = false) => { - const relaysEnv = getEnvOrDefault("NOSTR_RELAYS", "wss://strfry.shock.network"); + const relaysEnv = getEnvOrDefault("NOSTR_RELAYS", "wss://relay.lightning.pub"); return { relays: relaysEnv.split(' ') } diff --git a/src/tests/.env.test b/src/tests/.env.test index 1c118bac..ebc37838 100644 --- a/src/tests/.env.test +++ b/src/tests/.env.test @@ -14,7 +14,7 @@ INCOMING_INVOICE_FEE_USER_BPS=0 #defined by app this is just default OUTGOING_INVOICE_FEE_USER_BPS=60 #defined by app this is just default TX_FEE_INTERNAL_ROOT_BPS=60 #this is applied only to withdrawls from application wallets TX_FEE_INTERNAL_USER_BPS=60 #defined by app this is just default -NOSTR_RELAYS=wss://strfry.shock.network +NOSTR_RELAYS=wss://relay.lightning.pub SERVICE_URL=http://localhost:8080 ADMIN_TOKEN=thisisadmin PORT=8080 diff --git a/static/backup.html b/static/backup.html index ac27dee4..14f87bdf 100644 --- a/static/backup.html +++ b/static/backup.html @@ -12,6 +12,7 @@ Lightning.Pub + diff --git a/static/connect.html b/static/connect.html index 2bd2381e..2b4eab16 100644 --- a/static/connect.html +++ b/static/connect.html @@ -12,6 +12,7 @@ Lightning.Pub + diff --git a/static/css/status.css b/static/css/status.css index 559e219a..9114dea3 100644 --- a/static/css/status.css +++ b/static/css/status.css @@ -138,4 +138,10 @@ var(--gradient) border-box; border-radius: 2rem; border: 1px solid transparent; +} + +#adminNpub { + font-size: 8px; /* Adjust font size to fit on one line */ + text-align: left; /* Left align the text */ + line-break: anywhere; /* Ensure long text breaks appropriately */ } \ No newline at end of file diff --git a/static/index.html b/static/index.html index 58a7351e..f59b1195 100644 --- a/static/index.html +++ b/static/index.html @@ -11,6 +11,7 @@ Lightning.Pub + diff --git a/static/liquidity.html b/static/liquidity.html index 3f406e75..253f541b 100644 --- a/static/liquidity.html +++ b/static/liquidity.html @@ -12,6 +12,7 @@ Lightning.Pub + diff --git a/static/seed.html b/static/seed.html index 646961eb..4b6eebaf 100644 --- a/static/seed.html +++ b/static/seed.html @@ -12,6 +12,7 @@ Lightning.Pub + diff --git a/static/status.html b/static/status.html index e878bb0b..2c6d8787 100644 --- a/static/status.html +++ b/static/status.html @@ -12,6 +12,7 @@ Lightning.Pub + @@ -36,7 +37,7 @@
Public Node Name:
-
+
@@ -114,9 +117,11 @@
Watchdog Status:
- + + +
@@ -143,7 +148,7 @@