loop: allow setting swap type for individual rules
@@ -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 {
