From 55c769ef9dfc331deb8c11ab2f22cc5bf983ff3a Mon Sep 17 00:00:00 2001 From: George Tsagkarelis Date: Fri, 17 Mar 2023 17:31:28 +0200 Subject: [PATCH] liquidity: parse old auto budget to new parameters --- liquidity/parameters.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/liquidity/parameters.go b/liquidity/parameters.go index c1781e4..a1823d0 100644 --- a/liquidity/parameters.go +++ b/liquidity/parameters.go @@ -34,6 +34,8 @@ var ( } ) +const InfiniteDuration = (24 * 31 * 12 * 100) * time.Hour + // Parameters is a set of parameters provided by the user which guide // how we assess liquidity. type Parameters struct { @@ -404,6 +406,18 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters, time.Second } + // If an old-style budget was written to storage then express it by + // using the new auto budget parameters. If the newly added parameters + // have the 0 default value, but a budget was defined that means the + // client is using the old style budget parameters. + if req.AutoloopBudgetRefreshPeriodSec == 0 && + req.AutoloopBudgetSat != 0 { + + params.AutoFeeRefreshPeriod = InfiniteDuration + params.AutoloopBudgetLastRefresh = time.Unix( + int64(req.AutoloopBudgetStartSec), 0) + } + for _, rule := range req.Rules { peerRule := rule.Pubkey != nil chanRule := rule.ChannelId != 0