mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
feat: specify max channel saturation power of half from env (#1430)
* feat: specify max channel saturation power of half from env * feat: add max path count ldk variable to env * fix: app config types * chore: change ldk max path count default to 5 * chore: add comment
This commit is contained in:
parent
90d802f277
commit
b260d5f925
3 changed files with 60 additions and 42 deletions
|
|
@ -206,6 +206,8 @@ _To configure via env, the following parameters must be provided:_
|
|||
- `LDK_ESPLORA_SERVER`: By default the optimized Alby esplora is used. You can configure your own esplora server (note: the public blockstream one is slow and can cause onchain syncing and issues with opening channels)
|
||||
- `LDK_VSS_URL`: Use VSS (encrypted remote storage) rather than local sqlite store for lightning and bitcoin data. Currently this feature only works for brand new Alby Hub instances that are connected to Alby Accounts with an active subscription plan.
|
||||
- `LDK_LISTENING_ADDRESSES`: configure listening addresses, required for public channels, and ideally reachable if you would like others to be able to initiate peering with your node.
|
||||
- `LDK_MAX_CHANNEL_SATURATION`: Sets the maximum portion of a channel's total capacity that may be used for sending a payment, expressed as a power of 1/2. See `max_channel_saturation_power_of_half` in [LDK docs](https://docs.rs/lightning/latest/lightning/routing/router/struct.PaymentParameters.html#structfield.max_channel_saturation_power_of_half).
|
||||
- `LDK_MAX_PATH_COUNT`: Maximum number of paths that may be used by MPP payments.
|
||||
|
||||
#### LDK Network Configuration
|
||||
|
||||
|
|
|
|||
|
|
@ -15,44 +15,46 @@ const (
|
|||
)
|
||||
|
||||
type AppConfig struct {
|
||||
Relay string `envconfig:"RELAY" default:"wss://relay.getalby.com/v1"`
|
||||
LNBackendType string `envconfig:"LN_BACKEND_TYPE"`
|
||||
LNDAddress string `envconfig:"LND_ADDRESS"`
|
||||
LNDCertFile string `envconfig:"LND_CERT_FILE"`
|
||||
LNDMacaroonFile string `envconfig:"LND_MACAROON_FILE"`
|
||||
Workdir string `envconfig:"WORK_DIR"`
|
||||
Port string `envconfig:"PORT" default:"8080"`
|
||||
DatabaseUri string `envconfig:"DATABASE_URI" default:"nwc.db"`
|
||||
JWTSecret string `envconfig:"JWT_SECRET"`
|
||||
LogLevel string `envconfig:"LOG_LEVEL" default:"4"`
|
||||
LogToFile bool `envconfig:"LOG_TO_FILE" default:"true"`
|
||||
Network string `envconfig:"NETWORK"`
|
||||
LDKNetwork string `envconfig:"LDK_NETWORK"`
|
||||
LDKEsploraServer string `envconfig:"LDK_ESPLORA_SERVER" default:"https://electrs.getalbypro.com"` // TODO: remove LDK prefix
|
||||
LDKGossipSource string `envconfig:"LDK_GOSSIP_SOURCE"`
|
||||
LDKLogLevel string `envconfig:"LDK_LOG_LEVEL" default:"3"`
|
||||
LDKVssUrl string `envconfig:"LDK_VSS_URL" default:"https://vss.getalbypro.com/vss"`
|
||||
LDKListeningAddresses string `envconfig:"LDK_LISTENING_ADDRESSES" default:"0.0.0.0:9735,[::]:9735"`
|
||||
LDKTransientNetworkGraph bool `envconfig:"LDK_TRANSIENT_NETWORK_GRAPH" default:"false"`
|
||||
LDKBitcoindRpcHost string `envconfig:"LDK_BITCOIND_RPC_HOST"`
|
||||
LDKBitcoindRpcPort string `envconfig:"LDK_BITCOIND_RPC_PORT"`
|
||||
LDKBitcoindRpcUser string `envconfig:"LDK_BITCOIND_RPC_USER"`
|
||||
LDKBitcoindRpcPassword string `envconfig:"LDK_BITCOIND_RPC_PASSWORD"`
|
||||
MempoolApi string `envconfig:"MEMPOOL_API" default:"https://mempool.space/api"`
|
||||
AlbyClientId string `envconfig:"ALBY_OAUTH_CLIENT_ID" default:"J2PbXS1yOf"`
|
||||
AlbyClientSecret string `envconfig:"ALBY_OAUTH_CLIENT_SECRET" default:"rABK2n16IWjLTZ9M1uKU"`
|
||||
BaseUrl string `envconfig:"BASE_URL"`
|
||||
FrontendUrl string `envconfig:"FRONTEND_URL"`
|
||||
LogEvents bool `envconfig:"LOG_EVENTS" default:"true"`
|
||||
AutoLinkAlbyAccount bool `envconfig:"AUTO_LINK_ALBY_ACCOUNT" default:"true"`
|
||||
PhoenixdAddress string `envconfig:"PHOENIXD_ADDRESS"`
|
||||
PhoenixdAuthorization string `envconfig:"PHOENIXD_AUTHORIZATION"`
|
||||
GoProfilerAddr string `envconfig:"GO_PROFILER_ADDR"`
|
||||
DdProfilerEnabled bool `envconfig:"DD_PROFILER_ENABLED" default:"false"`
|
||||
EnableAdvancedSetup bool `envconfig:"ENABLE_ADVANCED_SETUP" default:"true"`
|
||||
AutoUnlockPassword string `envconfig:"AUTO_UNLOCK_PASSWORD"`
|
||||
LogDBQueries bool `envconfig:"LOG_DB_QUERIES" default:"false"`
|
||||
BoltzApi string `envconfig:"BOLTZ_API" default:"https://api.boltz.exchange"`
|
||||
Relay string `envconfig:"RELAY" default:"wss://relay.getalby.com/v1"`
|
||||
LNBackendType string `envconfig:"LN_BACKEND_TYPE"`
|
||||
LNDAddress string `envconfig:"LND_ADDRESS"`
|
||||
LNDCertFile string `envconfig:"LND_CERT_FILE"`
|
||||
LNDMacaroonFile string `envconfig:"LND_MACAROON_FILE"`
|
||||
Workdir string `envconfig:"WORK_DIR"`
|
||||
Port string `envconfig:"PORT" default:"8080"`
|
||||
DatabaseUri string `envconfig:"DATABASE_URI" default:"nwc.db"`
|
||||
JWTSecret string `envconfig:"JWT_SECRET"`
|
||||
LogLevel string `envconfig:"LOG_LEVEL" default:"4"`
|
||||
LogToFile bool `envconfig:"LOG_TO_FILE" default:"true"`
|
||||
Network string `envconfig:"NETWORK"`
|
||||
LDKNetwork string `envconfig:"LDK_NETWORK"`
|
||||
LDKEsploraServer string `envconfig:"LDK_ESPLORA_SERVER" default:"https://electrs.getalbypro.com"` // TODO: remove LDK prefix
|
||||
LDKGossipSource string `envconfig:"LDK_GOSSIP_SOURCE"`
|
||||
LDKLogLevel string `envconfig:"LDK_LOG_LEVEL" default:"3"`
|
||||
LDKMaxChannelSaturationPowerOfHalf uint8 `envconfig:"LDK_MAX_CHANNEL_SATURATION" default:"2"`
|
||||
LDKMaxPathCount uint8 `envconfig:"LDK_MAX_PATH_COUNT" default:"5"`
|
||||
LDKVssUrl string `envconfig:"LDK_VSS_URL" default:"https://vss.getalbypro.com/vss"`
|
||||
LDKListeningAddresses string `envconfig:"LDK_LISTENING_ADDRESSES" default:"0.0.0.0:9735,[::]:9735"`
|
||||
LDKTransientNetworkGraph bool `envconfig:"LDK_TRANSIENT_NETWORK_GRAPH" default:"false"`
|
||||
LDKBitcoindRpcHost string `envconfig:"LDK_BITCOIND_RPC_HOST"`
|
||||
LDKBitcoindRpcPort string `envconfig:"LDK_BITCOIND_RPC_PORT"`
|
||||
LDKBitcoindRpcUser string `envconfig:"LDK_BITCOIND_RPC_USER"`
|
||||
LDKBitcoindRpcPassword string `envconfig:"LDK_BITCOIND_RPC_PASSWORD"`
|
||||
MempoolApi string `envconfig:"MEMPOOL_API" default:"https://mempool.space/api"`
|
||||
AlbyClientId string `envconfig:"ALBY_OAUTH_CLIENT_ID" default:"J2PbXS1yOf"`
|
||||
AlbyClientSecret string `envconfig:"ALBY_OAUTH_CLIENT_SECRET" default:"rABK2n16IWjLTZ9M1uKU"`
|
||||
BaseUrl string `envconfig:"BASE_URL"`
|
||||
FrontendUrl string `envconfig:"FRONTEND_URL"`
|
||||
LogEvents bool `envconfig:"LOG_EVENTS" default:"true"`
|
||||
AutoLinkAlbyAccount bool `envconfig:"AUTO_LINK_ALBY_ACCOUNT" default:"true"`
|
||||
PhoenixdAddress string `envconfig:"PHOENIXD_ADDRESS"`
|
||||
PhoenixdAuthorization string `envconfig:"PHOENIXD_AUTHORIZATION"`
|
||||
GoProfilerAddr string `envconfig:"GO_PROFILER_ADDR"`
|
||||
DdProfilerEnabled bool `envconfig:"DD_PROFILER_ENABLED" default:"false"`
|
||||
EnableAdvancedSetup bool `envconfig:"ENABLE_ADVANCED_SETUP" default:"true"`
|
||||
AutoUnlockPassword string `envconfig:"AUTO_UNLOCK_PASSWORD"`
|
||||
LogDBQueries bool `envconfig:"LOG_DB_QUERIES" default:"false"`
|
||||
BoltzApi string `envconfig:"BOLTZ_API" default:"https://api.boltz.exchange"`
|
||||
}
|
||||
|
||||
func (c *AppConfig) IsDefaultClientId() bool {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,11 @@ func NewLDKService(ctx context.Context, cfg config.Config, eventPublisher events
|
|||
}
|
||||
|
||||
ldkConfig.ListeningAddresses = &listeningAddresses
|
||||
logLevel, _ := strconv.Atoi(cfg.GetEnv().LDKLogLevel)
|
||||
logLevel, err := strconv.Atoi(cfg.GetEnv().LDKLogLevel)
|
||||
if err != nil {
|
||||
// If parsing log level fails we default to 3, which is then bumped below
|
||||
logLevel = int(ldk_node.LogLevelDebug)
|
||||
}
|
||||
// LogLevelGossip is added due to bug in go bindings which uses an enum that starts at 1 instead of 0
|
||||
ldkLogger := NewLDKLogger(ldk_node.LogLevel(logLevel) + ldk_node.LogLevelGossip)
|
||||
ldkConfig.TransientNetworkGraph = cfg.GetEnv().LDKTransientNetworkGraph
|
||||
|
|
@ -521,10 +525,14 @@ func (ls *LDKService) SendPaymentSync(ctx context.Context, invoice string, amoun
|
|||
ldkEventSubscription := ls.ldkEventBroadcaster.Subscribe()
|
||||
defer ls.ldkEventBroadcaster.CancelSubscription(ldkEventSubscription)
|
||||
|
||||
var paymentHash string
|
||||
saturationPower := ls.cfg.GetEnv().LDKMaxChannelSaturationPowerOfHalf
|
||||
maxPathCount := ls.cfg.GetEnv().LDKMaxPathCount
|
||||
maxTotalRoutingFeeMsat := getMaxTotalRoutingFeeLimit(paymentAmountMsat)
|
||||
|
||||
sendingParams := &ldk_node.SendingParameters{
|
||||
MaxTotalRoutingFeeMsat: &maxTotalRoutingFeeMsat,
|
||||
MaxTotalRoutingFeeMsat: &maxTotalRoutingFeeMsat,
|
||||
MaxChannelSaturationPowerOfHalf: &saturationPower,
|
||||
MaxPathCount: &maxPathCount,
|
||||
}
|
||||
|
||||
invoiceObj, err := ldk_node.Bolt11InvoiceFromStr(invoice)
|
||||
|
|
@ -533,6 +541,7 @@ func (ls *LDKService) SendPaymentSync(ctx context.Context, invoice string, amoun
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var paymentHash string
|
||||
if amount == nil {
|
||||
paymentHash, err = ls.node.Bolt11Payment().Send(invoiceObj, sendingParams)
|
||||
} else {
|
||||
|
|
@ -626,9 +635,14 @@ func (ls *LDKService) SendKeysend(ctx context.Context, amount uint64, destinatio
|
|||
ldkEventSubscription := ls.ldkEventBroadcaster.Subscribe()
|
||||
defer ls.ldkEventBroadcaster.CancelSubscription(ldkEventSubscription)
|
||||
|
||||
saturationPower := ls.cfg.GetEnv().LDKMaxChannelSaturationPowerOfHalf
|
||||
maxPathCount := ls.cfg.GetEnv().LDKMaxPathCount
|
||||
maxTotalRoutingFeeMsat := getMaxTotalRoutingFeeLimit(amount)
|
||||
|
||||
sendingParams := &ldk_node.SendingParameters{
|
||||
MaxTotalRoutingFeeMsat: &maxTotalRoutingFeeMsat,
|
||||
MaxTotalRoutingFeeMsat: &maxTotalRoutingFeeMsat,
|
||||
MaxChannelSaturationPowerOfHalf: &saturationPower,
|
||||
MaxPathCount: &maxPathCount,
|
||||
}
|
||||
|
||||
paymentHash, err := ls.node.SpontaneousPayment().SendWithTlvsAndPreimage(amount, destination, sendingParams, customTlvs, &preimage)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue