Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cmd/loop/liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ var setParamsCommand = &cli.Command{
Usage: "the confirmation target for loop in on-chain " +
"htlcs.",
},
&cli.StringFlag{
Name: "loopinsource",
Usage: "the loop-in source to use for autoloop rules: " +
"wallet or static-address.",
},
&cli.BoolFlag{
Name: "easyautoloop",
Usage: "set to true to enable easy autoloop, which " +
Expand Down Expand Up @@ -555,6 +560,23 @@ func setParams(ctx context.Context, cmd *cli.Command) error {
flagSet = true
}

if cmd.IsSet("loopinsource") {
switch cmd.String("loopinsource") {
case "wallet":
params.LoopInSource =
looprpc.LoopInSource_LOOP_IN_SOURCE_WALLET

case "static-address", "static_address", "static":
params.LoopInSource =
looprpc.LoopInSource_LOOP_IN_SOURCE_STATIC_ADDRESS

default:
return fmt.Errorf("unknown loopinsource value")
}

flagSet = true
}

// If we are setting easy autoloop parameters, we need to ensure that
// the asset ID is set, and that we have a valid entry in our params
// map.
Expand Down
3 changes: 3 additions & 0 deletions docs/loop.1
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ update the parameters set for the liquidity manager
.PP
\fB--localbalancesat\fP="": the target size of total local balance in satoshis, used by easy autoloop. (default: 0)

.PP
\fB--loopinsource\fP="": the loop-in source to use for autoloop rules: wallet or static-address.

.PP
\fB--maxamt\fP="": the maximum amount in satoshis that the autoloop client will dispatch per-swap. (default: 0)

Expand Down
1 change: 1 addition & 0 deletions docs/loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ The following flags are supported:
| `--minamt="…"` | the minimum amount in satoshis that the autoloop client will dispatch per-swap | uint | `0` |
| `--maxamt="…"` | the maximum amount in satoshis that the autoloop client will dispatch per-swap | uint | `0` |
| `--htlc_conf="…"` | the confirmation target for loop in on-chain htlcs | int | `0` |
| `--loopinsource="…"` | the loop-in source to use for autoloop rules: wallet or static-address | string |
| `--easyautoloop` | set to true to enable easy autoloop, which will automatically dispatch swaps in order to meet the target local balance | bool | `false` |
| `--localbalancesat="…"` | the target size of total local balance in satoshis, used by easy autoloop | uint | `0` |
| `--easyautoloop_excludepeer="…"` | list of peer pubkeys (hex) to exclude from easy autoloop channel selection; repeat --easyautoloop_excludepeer for multiple peers | string | `[]` |
Expand Down
21 changes: 12 additions & 9 deletions liquidity/easy_autoloop_exclusions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ func TestEasyAutoloopExcludedPeers(t *testing.T) {
)

// Picking a channel should not pick the excluded peer's channel.
picked := c.manager.pickEasyAutoloopChannel(
[]lndclient.ChannelInfo{ch1, ch2}, &params.ClientRestrictions,
nil, nil, 1,
picked, err := c.manager.pickEasyAutoloopChannel(
t.Context(), []lndclient.ChannelInfo{ch1, ch2},
&params.ClientRestrictions, nil, nil, 1,
)
require.NoError(t, err)
require.NotNil(t, picked)
require.Equal(
t, ch2.ChannelID, picked.ChannelID,
Expand Down Expand Up @@ -92,21 +93,23 @@ func TestEasyAutoloopIncludeAllPeers(t *testing.T) {
)

// With exclusion active, peer1 should not be picked.
picked := c.manager.pickEasyAutoloopChannel(
[]lndclient.ChannelInfo{ch1, ch2}, &params.ClientRestrictions,
nil, nil, 1,
picked, err := c.manager.pickEasyAutoloopChannel(
t.Context(), []lndclient.ChannelInfo{ch1, ch2},
&params.ClientRestrictions, nil, nil, 1,
)
require.NoError(t, err)
require.NotNil(t, picked)
require.Equal(t, ch2.ChannelID, picked.ChannelID)

// Simulate --includealleasypeers by clearing the exclusion list as the
// CLI does before sending to the server.
c.manager.params.EasyAutoloopExcludedPeers = nil

picked = c.manager.pickEasyAutoloopChannel(
[]lndclient.ChannelInfo{ch1, ch2}, &params.ClientRestrictions,
nil, nil, 1,
picked, err = c.manager.pickEasyAutoloopChannel(
t.Context(), []lndclient.ChannelInfo{ch1, ch2},
&params.ClientRestrictions, nil, nil, 1,
)
require.NoError(t, err)
require.NotNil(t, picked)
require.Equal(
t, ch1.ChannelID, picked.ChannelID,
Expand Down
Loading
Loading