Merge branch 'master' into fix-logger
This commit is contained in:
commit
9bc66d13a8
4 changed files with 133 additions and 63 deletions
70
README.md
70
README.md
|
|
@ -8,11 +8,15 @@
|
|||
|
||||
### Don't just run a Lightning Node, run a Lightning Pub.
|
||||
|
||||
"Pub" is a `nostr` native account system that makes connecting your node to apps and websites super easy.
|
||||
"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.
|
||||
|
||||
Using Nostr relays as transport for encrypted RPCs, Pub eliminates the complexity of WebServer and SSL configurations.
|
||||
It may come as a surprise that the biggest hurdle to more Uncle Jim nodes hasn't been with Bitcoin/Lightning node management itself, since even in bad patterns like mobile nodes, that is easily automated.
|
||||
|
||||
By solving the networking and programability hurdles, Pub enables node-runners and Uncle Jim's to bring their Friends, Family and Customers into Bitcoin's permissionless circular economy. All while keeping the Lightning Network decentralized, and custodial scaling free of fiat shitcoin rails and large banks.
|
||||
It's the legacy baggage of traditional web infrastructure, things like IP4, reverse proxies, DNS, Firewalls and SSL certificates, all of which require a personal configuration that is a hurdle for most. The slow and unreliable nature of things like Tor have proven to be dead-ends, and Bolt12 being a re-implementation of Tor is destined for the same fate.
|
||||
|
||||
Pub solves these network challenges with a Full RPC that is Nostr-native. Being Nostr-native eliminates the complexity of legacy server configuration by using completely commoditized and trustless Nostr relays. Additionally, some optional services are integrated for backward compatibility with LNURL and Lightning Address.
|
||||
|
||||
By solving the networking and programability hurdles, Pub's provide a 3rd Lightning Layer that enables node-runners and Uncle Jims to more easily bring their personal network into Bitcoin's permissionless economy. In doing so, Pub can keep the Lightning Network decentralized, with custodial scaling free of fiat rails, large banks, and other forms of high-time-preference shitcoinery.
|
||||
|
||||
#### Features:
|
||||
|
||||
|
|
@ -24,59 +28,69 @@ By solving the networking and programability hurdles, Pub enables node-runners a
|
|||

|
||||
|
||||
#### Planned
|
||||
- [ ] Management Dashboard is being integrated into [ShockWallet](https://github.com/shocknet/wallet2)
|
||||
- [ ] Management Dashboard is actively being integrated into [ShockWallet](https://github.com/shocknet/wallet2)
|
||||
- [ ] Nostr native "offers"
|
||||
- [ ] Channel Automation
|
||||
- [ ] Bootstarp Peering (Passive "LSP")
|
||||
- [ ] Subscriptions / Notifications
|
||||
- [ ] Automated Channels
|
||||
- [ ] Bootstrap Peering (Passive "LSP")
|
||||
- [ ] Event Notifications
|
||||
- [ ] Submarine Swaps
|
||||
- [ ] High-Availabilty / Clustering
|
||||
|
||||
Dashboard:
|
||||
Dashboard Wireframe:
|
||||
|
||||
<img src="https://shockwallet.b-cdn.net/pub_home_ss.png" alt="Pub Dashboard" width="240">
|
||||
|
||||
#### ShockWallet and Lightning.Pub are free software. If you would like to see continued development, please show your [support](https://github.com/sponsors/shocknet) :)
|
||||
> [!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) 😊
|
||||
|
||||
> [!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**.
|
||||
|
||||
> **WARNING:** While this software has been used in production for many months, it is still bleeding edge and security or reliabilty is not guaranteed.
|
||||
## Umbrel Installation
|
||||
|
||||
## Manual Installation
|
||||
Coming Soon
|
||||
|
||||
## Desktop Installation
|
||||
|
||||
Coming Soon
|
||||
|
||||
## Manual CLI Installation
|
||||
|
||||
#### Notes:
|
||||
* The service defaults to port `8080`
|
||||
* Use of a reverse proxy is only required if you wish to serve LNURLs
|
||||
* The service defaults to port `8080`
|
||||
* 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) - *Example mainnet startup*:
|
||||
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.connect=neutrino.shock.network --routing.assumechanvalid --accept-keysend --allow-circular-route --feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json
|
||||
./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) `cp env.example .env`
|
||||
* `git clone https://github.com/shocknet/Lightning.Pub`
|
||||
|
||||
4) Add values to env file
|
||||
* `cd Lightning.Pub && npm i`
|
||||
|
||||
|
||||
3) Configure values to env file as desired
|
||||
* `cp env.example .env && nano .env`
|
||||
|
||||
5) `npm start`
|
||||
|
||||
6) Create an Application Pool
|
||||
- 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'`
|
||||
|
||||
A default "wallet" pool will be automatically created and keys generated automatically, if you wish to create something other:
|
||||
|
||||
```
|
||||
curl -XPOST -H 'Authorization: Bearer defined_in_constants.ts' -H "Content-type: application/json" -d '{"name":"ExampleApplicationPoolName"}' 'http://localhost:8080/api/admin/app/add'
|
||||
```
|
||||
|
||||
7) Connect with [wallet2](https://github.com/shocknet/wallet2) using the npub response in step 6 or the the wallet application nprofile logged at startup.
|
||||
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
|
||||
|
||||
|
||||
|
|
|
|||
101
env.example
101
env.example
|
|
@ -1,7 +1,13 @@
|
|||
#LND
|
||||
LND_ADDRESS=127.0.0.1:10009
|
||||
LND_CERT_PATH=/root/.lnd/tls.cert
|
||||
LND_MACAROON_PATH=/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
||||
# Example configuration for Lightning.Pub
|
||||
# Copy this file as .env in the Pub folder and uncomment the desired settings to override defaults
|
||||
# Alternatively, these settings can be passed as environment variables at startup
|
||||
|
||||
#LND_CONNECTION
|
||||
# Defaults typical for straight Linux
|
||||
# Containers, Mac and Windows may need more detailed paths
|
||||
#LND_ADDRESS=127.0.0.1:10009
|
||||
#LND_CERT_PATH=~/.lnd/tls.cert
|
||||
#LND_MACAROON_PATH=~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
||||
|
||||
#DB
|
||||
DATABASE_FILE=db.sqlite
|
||||
|
|
@ -10,46 +16,73 @@ LOGS_DIR=logs
|
|||
|
||||
LOG_LEVEL=DEBUG
|
||||
|
||||
#LOCAL
|
||||
ADMIN_TOKEN=
|
||||
PORT=8080
|
||||
JWT_SECRET=bigsecrethere
|
||||
#LOCALHOST
|
||||
#ADMIN_TOKEN=
|
||||
#PORT=8080
|
||||
#JWT_SECRET=
|
||||
|
||||
#LIGHTNING
|
||||
OUTBOUND_MAX_FEE_BPS=60
|
||||
OUTBOUND_MAX_FEE_EXTRA_SATS=100
|
||||
# Maximum amount in network fees passed to LND when it pays an external invoice
|
||||
# BPS are basis points, 100 BPS = 1%
|
||||
#OUTBOUND_MAX_FEE_BPS=60
|
||||
#OUTBOUND_MAX_FEE_EXTRA_SATS=100
|
||||
# If the back-end doesn't have adequate channel capacity, buy one from an LSP
|
||||
# Will execute when it costs less than 1% of balance and uses a trusted peer
|
||||
#BOOTSTRAP=1
|
||||
|
||||
#ROOT_FEES
|
||||
INCOMING_CHAIN_FEE_ROOT_BPS=0
|
||||
INCOMING_INVOICE_FEE_ROOT_BPS=0
|
||||
OUTGOING_CHAIN_FEE_ROOT_BPS=60 #applied to application debits
|
||||
OUTGOING_INVOICE_FEE_ROOT_BPS=60 #applied to application debits
|
||||
TX_FEE_INTERNAL_ROOT_BPS=60 #applied to inter-application txns
|
||||
#ROOT_FEES
|
||||
# Applied to either debits or credits and sent to an admin account
|
||||
# BPS are basis points, 100 BPS = 1%
|
||||
#INCOMING_CHAIN_FEE_ROOT_BPS=0
|
||||
#INCOMING_INVOICE_FEE_ROOT_BPS=0
|
||||
# Chain spends are currently unstable and thus disabled, do not use until further notice
|
||||
#OUTGOING_CHAIN_FEE_ROOT_BPS=60
|
||||
# Outgoing Invoice Fee must be >= Lightning Outbound Max Fee so admins don't incur losses on spends
|
||||
#OUTGOING_INVOICE_FEE_ROOT_BPS=60
|
||||
# Internal user fees bugged, do not use until further notice
|
||||
#TX_FEE_INTERNAL_ROOT_BPS=0 #applied to inter-application txns
|
||||
|
||||
#APP_FEES
|
||||
INCOMING_INVOICE_FEE_USER_BPS=0 #app default
|
||||
OUTGOING_INVOICE_FEE_USER_BPS=60 #app default
|
||||
TX_FEE_INTERNAL_USER_BPS=60 #intra-application tx default
|
||||
# An extra fee applied at the app level and sent to the application owner
|
||||
#INCOMING_INVOICE_FEE_USER_BPS=0
|
||||
#OUTGOING_INVOICE_FEE_USER_BPS=0
|
||||
#TX_FEE_INTERNAL_USER_BPS=0
|
||||
|
||||
#NOSTR
|
||||
NOSTR_RELAYS=wss://strfry.shock.network
|
||||
# Default relay may become rate-limited without a paid subscription
|
||||
#NOSTR_RELAYS=wss://strfry.shock.network
|
||||
|
||||
#LNURL
|
||||
#Note that a reachable https endpoint for the service to handle lnurl requests is required for lightning address bridges
|
||||
SERVICE_URL=https://test.lightning.pub
|
||||
# Optional
|
||||
# If undefined, LNURLs (including Lightning Address) will be disabled
|
||||
# To enable, add a reachable https endpoint for requests (or purchase a subscription)
|
||||
# You also need an SSL reverse proxy from the domain to this local host
|
||||
# Read more at https://docs.shock.network
|
||||
#SERVICE_URL=https://yourdomainhere.xyz
|
||||
|
||||
#DEV
|
||||
MOCK_LND=false
|
||||
ALLOW_BALANCE_MIGRATION=false
|
||||
MIGRATE_DB=false
|
||||
#SUBSCRIPTION_SERVICES
|
||||
# Opt-in to cloud relays for LNURL and Nostr
|
||||
# A small monthly fee supports the developers
|
||||
# Read more at https://docs.shock.network
|
||||
#SUBSCRIBER=1
|
||||
|
||||
#DEV_OPTS
|
||||
#MOCK_LND=false
|
||||
#ALLOW_BALANCE_MIGRATION=false
|
||||
#MIGRATE_DB=false
|
||||
|
||||
#METRICS
|
||||
RECORD_PERFORMANCE=true
|
||||
SKIP_SANITY_CHECK=false
|
||||
DISABLE_EXTERNAL_PAYMENTS=false
|
||||
#RECORD_PERFORMANCE=true
|
||||
#SKIP_SANITY_CHECK=false
|
||||
# A read-only token that can be used with dashboard to view reports
|
||||
#METRICS_TOKEN=
|
||||
# Disable outbound payments aka honeypot mode
|
||||
#DISABLE_EXTERNAL_PAYMENTS=false
|
||||
|
||||
# Max difference between users balance and LND balance since beginning of app execution
|
||||
WATCHDOG_MAX_DIFF_SATS=10000
|
||||
|
||||
# Max difference between users balance and LND balance after each payment
|
||||
WATCHDOG_MAX_UPDATE_DIFF_SATS=1000
|
||||
#WATCHDOG SECURITY
|
||||
# A last line of defense against 0-day drainage attacks
|
||||
# This will monitor LND separately and terminate sends if a balance discrepency is detected
|
||||
# This setting defaults to 0 meaning no discrepency will be tolerated
|
||||
# Increase this values to add a spending buffer for non-Pub services sharing LND
|
||||
# Max difference between users balance and LND balance at Pub startup
|
||||
#WATCHDOG_MAX_DIFF_SATS=0
|
||||
|
|
|
|||
|
|
@ -285,7 +285,21 @@ export default class {
|
|||
return `${this.settings.serviceUrl}/api/guest/lnurl_withdraw/info?k1=${k1}`
|
||||
}
|
||||
|
||||
isDefaultServiceUrl(): boolean {
|
||||
if (
|
||||
this.settings.serviceUrl.includes("localhost")
|
||||
||
|
||||
this.settings.serviceUrl.includes("127.0.0.1")
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async GetLnurlWithdrawLink(ctx: Types.UserContext): Promise<Types.LnurlLinkResponse> {
|
||||
if(this.isDefaultServiceUrl()) {
|
||||
throw new Error("Lnurl not enabled. Make sure to set SERVICE_URL env variable")
|
||||
}
|
||||
const app = await this.storage.applicationStorage.GetApplication(ctx.app_id)
|
||||
const key = await this.storage.paymentStorage.AddUserEphemeralKey(ctx.user_id, 'balanceCheck', app)
|
||||
return {
|
||||
|
|
@ -331,6 +345,9 @@ export default class {
|
|||
}
|
||||
|
||||
async GetLnurlPayLink(ctx: Types.UserContext): Promise<Types.LnurlLinkResponse> {
|
||||
if(this.isDefaultServiceUrl()) {
|
||||
throw new Error("Lnurl not enabled. Make sure to set SERVICE_URL env variable")
|
||||
}
|
||||
getLogger({})("getting lnurl pay link")
|
||||
const app = await this.storage.applicationStorage.GetApplication(ctx.app_id)
|
||||
const key = await this.storage.paymentStorage.AddUserEphemeralKey(ctx.user_id, 'pay', app)
|
||||
|
|
@ -343,6 +360,9 @@ export default class {
|
|||
}
|
||||
|
||||
async GetLnurlPayInfoFromUser(userId: string, linkedApplication: Application, baseUrl?: string): Promise<Types.LnurlPayInfoResponse> {
|
||||
if(this.isDefaultServiceUrl()) {
|
||||
throw new Error("Lnurl not enabled. Make sure to set SERVICE_URL env variable")
|
||||
}
|
||||
const payK1 = await this.storage.paymentStorage.AddUserEphemeralKey(userId, 'pay', linkedApplication)
|
||||
const url = baseUrl ? baseUrl : `${this.settings.serviceUrl}/api/guest/lnurl_pay/handle`
|
||||
const { remote } = await this.lnd.ChannelBalance()
|
||||
|
|
@ -358,6 +378,9 @@ export default class {
|
|||
}
|
||||
|
||||
async GetLnurlPayInfo(payInfoK1: string): Promise<Types.LnurlPayInfoResponse> {
|
||||
if(this.isDefaultServiceUrl()) {
|
||||
throw new Error("Lnurl not enabled. Make sure to set SERVICE_URL env variable")
|
||||
}
|
||||
const key = await this.storage.paymentStorage.UseUserEphemeralKey(payInfoK1, 'pay', true)
|
||||
if (!key.linkedApplication) {
|
||||
throw new Error("invalid lnurl request")
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export const LoadMainSettingsFromEnv = (): MainSettings => {
|
|||
outgoingAppUserInvoiceFee: EnvMustBeInteger("OUTGOING_INVOICE_FEE_USER_BPS") / 10000,
|
||||
userToUserFee: EnvMustBeInteger("TX_FEE_INTERNAL_USER_BPS") / 10000,
|
||||
appToUserFee: EnvMustBeInteger("TX_FEE_INTERNAL_ROOT_BPS") / 10000,
|
||||
serviceUrl: EnvMustBeNonEmptyString("SERVICE_URL"),
|
||||
serviceUrl: process.env.SERVICE_URL || `http://localhost:${EnvMustBeInteger("PORT")}`,
|
||||
servicePort: EnvMustBeInteger("PORT"),
|
||||
recordPerformance: process.env.RECORD_PERFORMANCE === 'true' || false,
|
||||
skipSanityCheck: process.env.SKIP_SANITY_CHECK === 'true' || false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue