diff --git a/config.go b/config.go index af9261b..7855caf 100644 --- a/config.go +++ b/config.go @@ -1,34 +1,90 @@ package main type NodeConfig struct { - Name string `json:name,omitempty` - NodePubkey string `json:nodePubkey,omitempty` - LspdPrivateKey string `json:"lspdPrivateKey"` - Token string `json:"token"` - Host string `json:"host"` - PublicChannelAmount int64 `json:"publicChannelAmount,string"` - ChannelAmount uint64 `json:"channelAmount,string"` - ChannelPrivate bool `json:"channelPrivate"` - TargetConf uint32 `json:"targetConf,string"` - MinHtlcMsat uint64 `json:"minHtlcMsat,string"` - BaseFeeMsat uint64 `json:"baseFeeMsat,string"` - FeeRate float64 `json:"feeRate,string"` - TimeLockDelta uint32 `json:"timeLockDelta,string"` - ChannelFeePermyriad int64 `json:"channelFeePermyriad,string"` - ChannelMinimumFeeMsat int64 `json:"channelMinimumFeeMsat,string"` - AdditionalChannelCapacity int64 `json:"additionalChannelCapacity,string"` - MaxInactiveDuration uint64 `json:"maxInactiveDuration,string"` - Lnd *LndConfig `json:"lnd,omitempty"` - Cln *ClnConfig `json:"cln,omitempty"` + // Name of the LSP. If empty, the node's alias will be taken instead. + Name string `json:name,omitempty` + + // The public key of the lightning node. + NodePubkey string `json:nodePubkey,omitempty` + + // Hex encoded private key of the LSP. This is used to decrypt traffic from + // clients. + LspdPrivateKey string `json:"lspdPrivateKey"` + + // Token used to authenticate to lspd. This token must be unique for each + // configured node, so it's obvious which node an rpc call is meant for. + Token string `json:"token"` + + // The network location of the lightning node, e.g. `12.34.56.78:9012` or + // `localhost:10011` + Host string `json:"host"` + + // Public channel amount is a reserved amount for public channels. If a + // zero conf channel is opened, it will never have this exact amount. + PublicChannelAmount int64 `json:"publicChannelAmount,string"` + + // The capacity of opened channels through the OpenChannel rpc. + ChannelAmount uint64 `json:"channelAmount,string"` + + // Value indicating whether channels opened through the OpenChannel rpc + // should be private. + ChannelPrivate bool `json:"channelPrivate"` + + // Number of blocks after which an opened channel is considered confirmed. + TargetConf uint32 `json:"targetConf,string"` + + // Smallest htlc amount routed over channels opened with the OpenChannel + // rpc call. + MinHtlcMsat uint64 `json:"minHtlcMsat,string"` + + // The base fee for routing payments over the channel. It is configured on + // the node itself, but this value is returned in the ChannelInformation rpc. + BaseFeeMsat uint64 `json:"baseFeeMsat,string"` + + // The fee rate for routing payments over the channel. It is configured on + // the node itself, but this value is returned in the ChannelInformation rpc. + FeeRate float64 `json:"feeRate,string"` + + // Minimum timelock delta required for opening a zero conf channel. + TimeLockDelta uint32 `json:"timeLockDelta,string"` + + // Fee for opening a zero conf channel in satoshi per 10000 satoshi based + // on the incoming payment amount. + ChannelFeePermyriad int64 `json:"channelFeePermyriad,string"` + + // Minimum fee for opening a zero conf channel in millisatoshi. + ChannelMinimumFeeMsat int64 `json:"channelMinimumFeeMsat,string"` + + // Channel capacity that is added on top of the incoming payment amount + // when a new zero conf channel is opened. In satoshi. + AdditionalChannelCapacity int64 `json:"additionalChannelCapacity,string"` + + // The channel can be closed if not used this duration in seconds. + MaxInactiveDuration uint64 `json:"maxInactiveDuration,string"` + + // Set this field to connect to an LND node. + Lnd *LndConfig `json:"lnd,omitempty"` + + // Set this field to connect to a CLN node. + Cln *ClnConfig `json:"cln,omitempty"` } type LndConfig struct { - Address string `json:"address"` - Cert string `json:"cert"` + // Address to the grpc api. + Address string `json:"address"` + + // tls cert for the grpc api. + Cert string `json:"cert"` + + // macaroon to use. Macaroon string `json:"macaroon"` } type ClnConfig struct { + // The address to the cln htlc acceptor grpc api shipped with lspd. PluginAddress string `json:"pluginAddress"` - SocketPath string `json:"socketPath"` + + // File path to the cln lightning-roc socket file. Find the path in + // cln-dir/mainnet/lightning-rpc + SocketPath string `json:"socketPath"` } diff --git a/sample.env b/sample.env index 5df5352..4a2d7ad 100644 --- a/sample.env +++ b/sample.env @@ -1,10 +1,23 @@ +# LISTEN_ADDRESS defines the host:port for the lspd grpc server. The best way is +# to use a local host:port and run lspd behind a reverse proxy like +# haproxy/nginx/caddy/traefik LISTEN_ADDRESS= -### If you define a domain here, the server will use certmagic to obtain -### a certificate from Let's Encrypt + +# You can also define a domain in CERTMAGIC_DOMAIN, and lspd will use certmagic +# to obtain a certificate from Let's Encrypt #CERTMAGIC_DOMAIN= +# DATABASE_URL is the postgresql db url in the form: +# postgres://username:password@host:port/dbname +# You can create the db and user with the following commands: +#CREATE ROLE ; +#ALTER ROLE WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD ''; +#CREATE DATABASE WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8'; +#ALTER DATABASE OWNER TO ; DATABASE_URL= +# These variables are needed to send email using SES and the AWS_ACCESS_KEY_ID +# has to have the permission to send emails. AWS_REGION= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= @@ -17,6 +30,27 @@ CHANNELMISMATCH_NOTIFICATION_TO='["Name1 "]' CHANNELMISMATCH_NOTIFICATION_CC='["Name2 ","Name3 "]' CHANNELMISMATCH_NOTIFICATION_FROM="Name4 " +# By default lspd uses the fee estimation from the lightning node it is connected +# to for opening new channels. You can use mempool fee estimation instead by +# setting below variables. USE_MEMPOOL_FEE_ESTIMATION=true MEMPOOL_API_BASE_URL=https://mempool.space/api/v1/ + +# lspd can be connected to multiple nodes at once. The NODES variable takes an +# array of nodes. Each node is either a cln or an lnd node and should have the +# corresponding "cln" or "lnd" key set. +# +# TOKEN is a secret shared between the LSP (the lspd instance) and breez-server +# and is put in the header of each request. It should be unique for each node. +# You can generate it using for instance the command: openssl rand -base64 24 +# +# LSPD_PRIVATE_KEY is a key generated and printed in the console when you run +# ./lspd genkey". +# When sending the lspd information to the client (the app), lspd adds the +# public key corresponding to this private key and the client encrypt all the +# messages sent to the LSP using this public key. +# The goal is to hide anything from breez-server which is the pass "opaque" data +# from the app to lspd. +# +# For other specific settings see the fields in `config.go` NodeConfig struct. NODES='[ { "name": "", "nodePubkey": "", "lspdPrivateKey": "", "token": "", "host": "", "publicChannelAmount": "1000183", "channelAmount": "100000", "channelPrivate": false, "targetConf": "6", "minHtlcMsat": "600", "baseFeeMsat": "1000", "feeRate": "0.000001", "timeLockDelta": "144", "channelFeePermyriad": "40", "channelMinimumFeeMsat": "2000000", "additionalChannelCapacity": "100000", "maxInactiveDuration": "3888000", "lnd": { "address": "", "cert": "", "macaroon": "" } }, { "name": "", "nodePubkey": "", "lspdPrivateKey": "", "token": "", "host": "", "publicChannelAmount": "1000183", "channelAmount": "100000", "channelPrivate": false, "targetConf": "6", "minHtlcMsat": "600", "baseFeeMsat": "1000", "feeRate": "0.000001", "timeLockDelta": "144", "channelFeePermyriad": "40", "channelMinimumFeeMsat": "2000000", "additionalChannelCapacity": "100000", "maxInactiveDuration": "3888000", "cln": { "pluginAddress": "
", "socketPath": "" } } ]'