Browse Source

loopd+lsat: add LSAT cost configuration parameters

pull/132/head
Oliver Gugger 1 year ago
parent
commit
8aeeaefbaf
No known key found for this signature in database GPG Key ID: 8E4256593F177720
2 changed files with 15 additions and 6 deletions
  1. +6
    -1
      loopd/config.go
  2. +9
    -5
      lsat/interceptor.go

+ 6
- 1
loopd/config.go View File

@ -4,6 +4,7 @@ import (
"path/filepath"
"github.com/btcsuite/btcutil"
"github.com/lightninglabs/loop/lsat"
)
var (
@ -39,7 +40,9 @@ type config struct {
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"`
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"`
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"`
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."`
MaxLSATFee uint32 `long:"maxlsatfee" description:"Maximum routing fee in satoshis that we are willing to pay while paying for an LSAT token."`
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
@ -60,6 +63,8 @@ var defaultConfig = config{
MaxLogFiles: defaultMaxLogFiles,
MaxLogFileSize: defaultMaxLogFileSize,
DebugLevel: defaultLogLevel,
MaxLSATCost: lsat.DefaultMaxCostSats,
MaxLSATFee: lsat.DefaultMaxRoutingFeeSats,
Lnd: &lndConfig{
Host: "localhost:10009",
},

+ 9
- 5
lsat/interceptor.go View File

@ -33,10 +33,14 @@ const (
// challenge.
AuthHeader = "WWW-Authenticate"
// MaxRoutingFee is the maximum routing fee in satoshis that we are
// going to pay to acquire an LSAT token.
// TODO(guggero): make this configurable
MaxRoutingFeeSats = 10
// DefaultMaxCostSats is the default maximum amount in satoshis that we
// are going to pay for an LSAT automatically. Does not include routing
// fees.
DefaultMaxCostSats = 1000
// DefaultMaxRoutingFeeSats is the default maximum routing fee in
// satoshis that we are going to pay to acquire an LSAT token.
DefaultMaxRoutingFeeSats = 10
// PaymentTimeout is the maximum time we allow a payment to take before
// we stop waiting for it.
@ -238,7 +242,7 @@ func (i *Interceptor) payLsatToken(ctx context.Context, md *metadata.MD) (
payCtx, cancel := context.WithTimeout(ctx, PaymentTimeout)
defer cancel()
respChan := i.lnd.Client.PayInvoice(
payCtx, invoiceStr, MaxRoutingFeeSats, nil,
payCtx, invoiceStr, DefaultMaxRoutingFeeSats, nil,
)
select {
case result := <-respChan:

Loading…
Cancel
Save