From 9e91e4ed15fdd71eb47e4bf9d904364fde72b942 Mon Sep 17 00:00:00 2001 From: carla Date: Thu, 9 Sep 2021 13:58:33 +0200 Subject: [PATCH] multi: add loop out routing hints config parameter for opt-in --- client.go | 5 +++++ executor.go | 2 ++ loopd/config.go | 3 ++- loopd/utils.go | 17 +++++++++-------- loopout.go | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index 9baf581..45ae9f6 100644 --- a/client.go +++ b/client.go @@ -107,6 +107,10 @@ type ClientConfig struct { // for a loop out swap. When greater than one, a multi-part payment may // be attempted. LoopOutMaxParts uint32 + + // LoopOutRoutingHints indicates whether to use server-provided routing + // hints to improve off-chain routing. + LoopOutRoutingHints bool } // NewClient returns a new instance to initiate swaps with. @@ -146,6 +150,7 @@ func NewClient(dbDir string, cfg *ClientConfig) (*Client, func(), error) { sweeper: sweeper, createExpiryTimer: config.CreateExpiryTimer, loopOutMaxParts: cfg.LoopOutMaxParts, + routingHints: cfg.LoopOutRoutingHints, cancelSwap: swapServerClient.CancelLoopOutSwap, }) diff --git a/executor.go b/executor.go index f759e2c..70bd2b5 100644 --- a/executor.go +++ b/executor.go @@ -25,6 +25,7 @@ type executorConfig struct { createExpiryTimer func(expiry time.Duration) <-chan time.Time loopOutMaxParts uint32 + routingHints bool cancelSwap func(ctx context.Context, details *outCancelDetails) error } @@ -146,6 +147,7 @@ func (s *executor) run(mainCtx context.Context, blockEpochChan: queue.ChanOut(), timerFactory: s.executorConfig.createExpiryTimer, loopOutMaxParts: s.executorConfig.loopOutMaxParts, + routingHints: s.executorConfig.routingHints, cancelSwap: s.executorConfig.cancelSwap, }, height) if err != nil && err != context.Canceled { diff --git a/loopd/config.go b/loopd/config.go index a54a2bb..16d1cb2 100644 --- a/loopd/config.go +++ b/loopd/config.go @@ -129,7 +129,8 @@ type Config struct { 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."` - LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."` + LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."` + LoopOutRoutingHints bool `long:"loopouthints" description:"Whether to use server-provided hints to improve the success rate of off-chain routing. Note that enabling this setting will apply updates to lnd's mission control state."` Lnd *lndConfig `group:"lnd" namespace:"lnd"` diff --git a/loopd/utils.go b/loopd/utils.go index 59e8cca..a1175c6 100644 --- a/loopd/utils.go +++ b/loopd/utils.go @@ -17,14 +17,15 @@ func getClient(config *Config, lnd *lndclient.LndServices) (*loop.Client, func(), error) { clientConfig := &loop.ClientConfig{ - ServerAddress: config.Server.Host, - ProxyAddress: config.Server.Proxy, - SwapServerNoTLS: config.Server.NoTLS, - TLSPathServer: config.Server.TLSPath, - Lnd: lnd, - MaxLsatCost: btcutil.Amount(config.MaxLSATCost), - MaxLsatFee: btcutil.Amount(config.MaxLSATFee), - LoopOutMaxParts: config.LoopOutMaxParts, + ServerAddress: config.Server.Host, + ProxyAddress: config.Server.Proxy, + SwapServerNoTLS: config.Server.NoTLS, + TLSPathServer: config.Server.TLSPath, + Lnd: lnd, + MaxLsatCost: btcutil.Amount(config.MaxLSATCost), + MaxLsatFee: btcutil.Amount(config.MaxLSATFee), + LoopOutMaxParts: config.LoopOutMaxParts, + LoopOutRoutingHints: config.LoopOutRoutingHints, } swapClient, cleanUp, err := loop.NewClient(config.DataDir, clientConfig) diff --git a/loopout.go b/loopout.go index 2d4f619..bf0af02 100644 --- a/loopout.go +++ b/loopout.go @@ -85,6 +85,7 @@ type executeConfig struct { blockEpochChan <-chan interface{} timerFactory func(d time.Duration) <-chan time.Time loopOutMaxParts uint32 + routingHints bool cancelSwap func(context.Context, *outCancelDetails) error }