Skip to content

Commit 8aeeaef

Browse files
committed
loopd+lsat: add LSAT cost configuration parameters
1 parent d9597e8 commit 8aeeaef

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

loopd/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"path/filepath"
55

66
"github.com/btcsuite/btcutil"
7+
"github.com/lightninglabs/loop/lsat"
78
)
89

910
var (
@@ -39,7 +40,9 @@ type config struct {
3940
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
4041
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"`
4142

42-
DebugLevel string `short:"d" 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"`
43+
DebugLevel string `short:"d" 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"`
44+
MaxLSATCost uint32 `long:"maxlsatcost" description:"Maximum cost in satoshis that loopd is going to pay for an LSAT token automatically. Does not include routing fees."`
45+
MaxLSATFee uint32 `long:"maxlsatfee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an LSAT token."`
4346

4447
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
4548

@@ -60,6 +63,8 @@ var defaultConfig = config{
6063
MaxLogFiles: defaultMaxLogFiles,
6164
MaxLogFileSize: defaultMaxLogFileSize,
6265
DebugLevel: defaultLogLevel,
66+
MaxLSATCost: lsat.DefaultMaxCostSats,
67+
MaxLSATFee: lsat.DefaultMaxRoutingFeeSats,
6368
Lnd: &lndConfig{
6469
Host: "localhost:10009",
6570
},

lsat/interceptor.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ const (
3333
// challenge.
3434
AuthHeader = "WWW-Authenticate"
3535

36-
// MaxRoutingFee is the maximum routing fee in satoshis that we are
37-
// going to pay to acquire an LSAT token.
38-
// TODO(guggero): make this configurable
39-
MaxRoutingFeeSats = 10
36+
// DefaultMaxCostSats is the default maximum amount in satoshis that we
37+
// are going to pay for an LSAT automatically. Does not include routing
38+
// fees.
39+
DefaultMaxCostSats = 1000
40+
41+
// DefaultMaxRoutingFeeSats is the default maximum routing fee in
42+
// satoshis that we are going to pay to acquire an LSAT token.
43+
DefaultMaxRoutingFeeSats = 10
4044

4145
// PaymentTimeout is the maximum time we allow a payment to take before
4246
// we stop waiting for it.
@@ -238,7 +242,7 @@ func (i *Interceptor) payLsatToken(ctx context.Context, md *metadata.MD) (
238242
payCtx, cancel := context.WithTimeout(ctx, PaymentTimeout)
239243
defer cancel()
240244
respChan := i.lnd.Client.PayInvoice(
241-
payCtx, invoiceStr, MaxRoutingFeeSats, nil,
245+
payCtx, invoiceStr, DefaultMaxRoutingFeeSats, nil,
242246
)
243247
select {
244248
case result := <-respChan:

0 commit comments

Comments
 (0)