diff --git a/cost_migration.go b/cost_migration.go index 247f63fad..a39ef8eca 100644 --- a/cost_migration.go +++ b/cost_migration.go @@ -150,11 +150,21 @@ func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices, // costs in the database. updatedCosts := make(map[lntypes.Hash]loopdb.SwapCost) for _, loopOutSwap := range loopOutSwaps { + if loopOutSwap.State().State.IsPending() { + continue + } + cost, err := CalculateLoopOutCost( lnd.ChainParams, loopOutSwap, paymentFees, ) if err != nil { - return err + // We don't want to fail loopd because of any old swap + // that we're unable to calculate the cost for. We'll + // warn though so that we can investigate further. + log.Warnf("Unable to calculate cost for swap %v: %v", + loopOutSwap.Hash, err) + + continue } _, ok := updatedCosts[loopOutSwap.Hash] diff --git a/loopd/config.go b/loopd/config.go index 423784aeb..2c417b72f 100644 --- a/loopd/config.go +++ b/loopd/config.go @@ -76,6 +76,10 @@ var ( defaultLndMacaroon, ) + // DefaultLndRPCTimeout is the default timeout to use when communicating + // with lnd. + DefaultLndRPCTimeout = time.Minute + // DefaultTLSCertPath is the default full path of the autogenerated TLS // certificate. DefaultTLSCertPath = filepath.Join( @@ -118,6 +122,9 @@ type lndConfig struct { MacaroonPath string `long:"macaroonpath" description:"The full path to the single macaroon to use, either the admin.macaroon or a custom baked one. Cannot be specified at the same time as macaroondir. A custom macaroon must contain ALL permissions required for all subservers to work, otherwise permission errors will occur."` TLSPath string `long:"tlspath" description:"Path to lnd tls certificate"` + + // RPCTimeout is the timeout to use when communicating with lnd. + RPCTimeout time.Duration `long:"rpctimeout" description:"The timeout to use when communicating with lnd"` } type loopServerConfig struct { @@ -217,6 +224,7 @@ func DefaultConfig() Config { Lnd: &lndConfig{ Host: "localhost:10009", MacaroonPath: DefaultLndMacaroonPath, + RPCTimeout: DefaultLndRPCTimeout, }, } } diff --git a/loopd/run.go b/loopd/run.go index 151890cd1..34b2cd70d 100644 --- a/loopd/run.go +++ b/loopd/run.go @@ -96,6 +96,7 @@ func NewListenerConfig(config *Config, rpcCfg RPCConfig) *ListenerCfg { BlockUntilChainSynced: true, CallerCtx: callerCtx, BlockUntilUnlocked: true, + RPCTimeout: cfg.RPCTimeout, } // If a custom lnd connection is specified we use that