Skip to content

Commit 7bb04ae

Browse files
committed
loopd: recorgnize maxlsatcost and maxlsatfee flags
The flags were re-added in hidden mode so that users who specified them could start the daemon after upgrading. If a flag is used, a deprecation warning is printed. Updated release_notes.md.
1 parent 0e7927a commit 7bb04ae

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

loopd/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ type Config struct {
160160
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB."`
161161

162162
DebugLevel string `long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
163+
MaxLSATCost uint32 `long:"maxlsatcost" hidden:"true"`
164+
MaxLSATFee uint32 `long:"maxlsatfee" hidden:"true"`
163165
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."`
164166
MaxL402Fee uint32 `long:"maxl402fee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an L402 token."`
165167

loopd/utils.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/btcsuite/btcd/btcutil"
88
"github.com/btcsuite/btcd/chaincfg"
9+
"github.com/lightninglabs/aperture/l402"
910
"github.com/lightninglabs/lndclient"
1011
"github.com/lightninglabs/loop"
1112
"github.com/lightninglabs/loop/liquidity"
@@ -21,6 +22,23 @@ func getClient(cfg *Config, swapDb loopdb.SwapStore,
2122
sweeperDb sweepbatcher.BatcherStore, lnd *lndclient.LndServices) (
2223
*loop.Client, func(), error) {
2324

25+
// Default is not set for MaxLSATCost and MaxLSATFee to distinguish
26+
// it from user explicitly setting the option to default value.
27+
// So if MaxL402Cost and MaxLSATFee are not set in the config file
28+
// and command line, they are set to 0.
29+
const (
30+
defaultCost = l402.DefaultMaxCostSats
31+
defaultFee = l402.DefaultMaxRoutingFeeSats
32+
)
33+
if cfg.MaxL402Cost != defaultCost && cfg.MaxLSATCost != 0 {
34+
return nil, nil, fmt.Errorf("both maxl402cost and maxlsatcost" +
35+
" were specified; they are not allowed together")
36+
}
37+
if cfg.MaxL402Fee != defaultFee && cfg.MaxLSATFee != 0 {
38+
return nil, nil, fmt.Errorf("both maxl402fee and maxlsatfee" +
39+
" were specified; they are not allowed together")
40+
}
41+
2442
clientConfig := &loop.ClientConfig{
2543
ServerAddress: cfg.Server.Host,
2644
ProxyAddress: cfg.Server.Proxy,
@@ -34,6 +52,17 @@ func getClient(cfg *Config, swapDb loopdb.SwapStore,
3452
MaxPaymentRetries: cfg.MaxPaymentRetries,
3553
}
3654

55+
if cfg.MaxL402Cost == defaultCost && cfg.MaxLSATCost != 0 {
56+
log.Warnf("Option maxlsatcost is deprecated and will be " +
57+
"removed. Switch to maxl402cost.")
58+
clientConfig.MaxL402Cost = btcutil.Amount(cfg.MaxLSATCost)
59+
}
60+
if cfg.MaxL402Fee == defaultFee && cfg.MaxLSATFee != 0 {
61+
log.Warnf("Option maxlsatfee is deprecated and will be " +
62+
"removed. Switch to maxl402fee.")
63+
clientConfig.MaxL402Fee = btcutil.Amount(cfg.MaxLSATFee)
64+
}
65+
3766
swapClient, cleanUp, err := loop.NewClient(
3867
cfg.DataDir, swapDb, sweeperDb, clientConfig,
3968
)

release_notes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ This file tracks release notes for the loop client.
1919
#### Breaking Changes
2020

2121
In loopd.conf file `maxlsatcost` and `maxlsatfee` were renamed to `maxl402cost`
22-
and `maxl402fee` accordingly. If they have been changed locally, the file has
23-
to be updated for loopd to recognize the options.
22+
and `maxl402fee` accordingly. Old versions of the options are still recognized
23+
for backward compatibility, but a deprecation warning is printed. Users are
24+
encouraged to change the options to new names if they have been changed locally.
2425

2526
The path in looprpc "/v1/lsat/tokens" was renamed to "/v1/l402/tokens" and
2627
the corresponding method was renamed from `GetLsatTokens` to `GetL402Tokens`.

0 commit comments

Comments
 (0)