From 2542038243210a1431a0b7bae32978c0e61e0552 Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 15 Dec 2021 09:11:49 +0200 Subject: [PATCH] loop: allow setting swap type for individual rules --- cmd/loop/liquidity.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/loop/liquidity.go b/cmd/loop/liquidity.go index bc2fffa..79e46aa 100644 --- a/cmd/loop/liquidity.go +++ b/cmd/loop/liquidity.go @@ -48,6 +48,14 @@ var setLiquidityRuleCommand = cli.Command{ Description: "Update or remove the liquidity rule for a channel/peer.", ArgsUsage: "{shortchanid | peerpubkey}", Flags: []cli.Flag{ + cli.StringFlag{ + Name: "type", + Usage: "the type of swap to perform, set to 'out' " + + "for acquiring inbound liquidity or 'in' for " + + "acquiring outbound liquidity.", + Value: "out", + }, + cli.IntFlag{ Name: "incoming_threshold", Usage: "the minimum percentage of incoming liquidity " + @@ -168,7 +176,18 @@ func setRule(ctx *cli.Context) error { newRule := &looprpc.LiquidityRule{ ChannelId: chanID, Type: looprpc.LiquidityRuleType_THRESHOLD, - SwapType: looprpc.SwapType_LOOP_OUT, + } + if ctx.IsSet("type") { + switch ctx.String("type") { + case "in": + newRule.SwapType = looprpc.SwapType_LOOP_IN + + case "out": + newRule.SwapType = looprpc.SwapType_LOOP_OUT + + default: + return errors.New("please set type to in or out") + } } if pubkeyRule {