diff --git a/loopd/config.go b/loopd/config.go index 24def35..423784a 100644 --- a/loopd/config.go +++ b/loopd/config.go @@ -160,6 +160,8 @@ type Config struct { MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB."` DebugLevel string `long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify =,=,... to set the log level for individual subsystems -- Use show to list available subsystems"` + MaxLSATCost uint32 `long:"maxlsatcost" hidden:"true"` + MaxLSATFee uint32 `long:"maxlsatfee" hidden:"true"` MaxL402Cost uint32 `long:"maxl402cost" description:"Maximum cost in satoshis that loopd is going to pay for an L402 token automatically. Does not include routing fees."` MaxL402Fee uint32 `long:"maxl402fee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an L402 token."` diff --git a/loopd/utils.go b/loopd/utils.go index b8b9119..e6c7547 100644 --- a/loopd/utils.go +++ b/loopd/utils.go @@ -6,6 +6,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" + "github.com/lightninglabs/aperture/l402" "github.com/lightninglabs/lndclient" "github.com/lightninglabs/loop" "github.com/lightninglabs/loop/liquidity" @@ -21,6 +22,23 @@ func getClient(cfg *Config, swapDb loopdb.SwapStore, sweeperDb sweepbatcher.BatcherStore, lnd *lndclient.LndServices) ( *loop.Client, func(), error) { + // Default is not set for MaxLSATCost and MaxLSATFee to distinguish + // it from user explicitly setting the option to default value. + // So if MaxL402Cost and MaxLSATFee are not set in the config file + // and command line, they are set to 0. + const ( + defaultCost = l402.DefaultMaxCostSats + defaultFee = l402.DefaultMaxRoutingFeeSats + ) + if cfg.MaxL402Cost != defaultCost && cfg.MaxLSATCost != 0 { + return nil, nil, fmt.Errorf("both maxl402cost and maxlsatcost" + + " were specified; they are not allowed together") + } + if cfg.MaxL402Fee != defaultFee && cfg.MaxLSATFee != 0 { + return nil, nil, fmt.Errorf("both maxl402fee and maxlsatfee" + + " were specified; they are not allowed together") + } + clientConfig := &loop.ClientConfig{ ServerAddress: cfg.Server.Host, ProxyAddress: cfg.Server.Proxy, @@ -34,6 +52,17 @@ func getClient(cfg *Config, swapDb loopdb.SwapStore, MaxPaymentRetries: cfg.MaxPaymentRetries, } + if cfg.MaxL402Cost == defaultCost && cfg.MaxLSATCost != 0 { + log.Warnf("Option maxlsatcost is deprecated and will be " + + "removed. Switch to maxl402cost.") + clientConfig.MaxL402Cost = btcutil.Amount(cfg.MaxLSATCost) + } + if cfg.MaxL402Fee == defaultFee && cfg.MaxLSATFee != 0 { + log.Warnf("Option maxlsatfee is deprecated and will be " + + "removed. Switch to maxl402fee.") + clientConfig.MaxL402Fee = btcutil.Amount(cfg.MaxLSATFee) + } + swapClient, cleanUp, err := loop.NewClient( cfg.DataDir, swapDb, sweeperDb, clientConfig, ) diff --git a/release_notes.md b/release_notes.md index 056aa18..7b752a0 100644 --- a/release_notes.md +++ b/release_notes.md @@ -19,8 +19,9 @@ This file tracks release notes for the loop client. #### Breaking Changes In loopd.conf file `maxlsatcost` and `maxlsatfee` were renamed to `maxl402cost` -and `maxl402fee` accordingly. If they have been changed locally, the file has -to be updated for loopd to recognize the options. +and `maxl402fee` accordingly. Old versions of the options are still recognized +for backward compatibility, but a deprecation warning is printed. Users are +encouraged to change the options to new names if they have been changed locally. The path in looprpc "/v1/lsat/tokens" was renamed to "/v1/l402/tokens" and the corresponding method was renamed from `GetLsatTokens` to `GetL402Tokens`.