multi: add OutAddr parameter for autoloop loop out

pull/542/head
George Tsagkarelis 1 year ago
parent 0ef205cb24
commit fa0393b331
No known key found for this signature in database
GPG Key ID: 0807D1013F48208A

@ -286,6 +286,12 @@ var setParamsCommand = cli.Command{
"of swaps, limited to the budget set by " + "of swaps, limited to the budget set by " +
"autobudget", "autobudget",
}, },
cli.StringFlag{
Name: "destaddr",
Usage: "custom address to be used as destination for " +
"autoloop loop out, set to \"default\" in " +
"order to revert to default behavior",
},
cli.Uint64Flag{ cli.Uint64Flag{
Name: "autobudget", Name: "autobudget",
Usage: "the maximum amount of fees in satoshis that " + Usage: "the maximum amount of fees in satoshis that " +
@ -429,6 +435,11 @@ func setParams(ctx *cli.Context) error {
flagSet = true flagSet = true
} }
if ctx.IsSet("destaddr") {
params.AutoloopDestAddress = ctx.String("destaddr")
flagSet = true
}
if ctx.IsSet("budgetstart") { if ctx.IsSet("budgetstart") {
params.AutoloopBudgetStartSec = ctx.Uint64("budgetstart") params.AutoloopBudgetStartSec = ctx.Uint64("budgetstart")
flagSet = true flagSet = true

@ -380,6 +380,13 @@ func (m *Manager) autoloop(ctx context.Context) error {
// Create a copy of our range var so that we can reference it. // Create a copy of our range var so that we can reference it.
swap := swap swap := swap
// Check if the parameter for custom address is defined for loop
// outs.
if m.params.DestAddr != nil {
swap.DestAddr = m.params.DestAddr
}
loopOut, err := m.cfg.LoopOut(ctx, &swap) loopOut, err := m.cfg.LoopOut(ctx, &swap)
if err != nil { if err != nil {
return err return err

@ -18,9 +18,10 @@ import (
var ( var (
// defaultParameters contains the default parameters that we start our // defaultParameters contains the default parameters that we start our
// liquidity manger with. // liquidity manager with.
defaultParameters = Parameters{ defaultParameters = Parameters{
AutoFeeBudget: defaultBudget, AutoFeeBudget: defaultBudget,
DestAddr: nil,
MaxAutoInFlight: defaultMaxInFlight, MaxAutoInFlight: defaultMaxInFlight,
ChannelRules: make(map[lnwire.ShortChannelID]*SwapRule), ChannelRules: make(map[lnwire.ShortChannelID]*SwapRule),
PeerRules: make(map[route.Vertex]*SwapRule), PeerRules: make(map[route.Vertex]*SwapRule),
@ -37,6 +38,10 @@ type Parameters struct {
// Autoloop enables automatic dispatch of swaps. // Autoloop enables automatic dispatch of swaps.
Autoloop bool Autoloop bool
// DestAddr is the address to be used for sweeping the on-chain HTLC that
// is related with a loop out.
DestAddr btcutil.Address
// AutoFeeBudget is the total amount we allow to be spent on // AutoFeeBudget is the total amount we allow to be spent on
// automatically dispatched swaps. Once this budget has been used, we // automatically dispatched swaps. Once this budget has been used, we
// will stop dispatching swaps until the budget is increased or the // will stop dispatching swaps until the budget is increased or the
@ -347,12 +352,25 @@ func rpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
return nil, err return nil, err
} }
var destaddr btcutil.Address
if len(req.AutoloopDestAddress) != 0 {
if req.AutoloopDestAddress == "default" {
destaddr = nil
} else {
destaddr, err = btcutil.DecodeAddress(req.AutoloopDestAddress, nil)
if err != nil {
return nil, err
}
}
}
params := &Parameters{ params := &Parameters{
FeeLimit: feeLimit, FeeLimit: feeLimit,
SweepConfTarget: req.SweepConfTarget, SweepConfTarget: req.SweepConfTarget,
FailureBackOff: time.Duration(req.FailureBackoffSec) * FailureBackOff: time.Duration(req.FailureBackoffSec) *
time.Second, time.Second,
Autoloop: req.Autoloop, Autoloop: req.Autoloop,
DestAddr: destaddr,
AutoFeeBudget: btcutil.Amount(req.AutoloopBudgetSat), AutoFeeBudget: btcutil.Amount(req.AutoloopBudgetSat),
MaxAutoInFlight: int(req.AutoMaxInFlight), MaxAutoInFlight: int(req.AutoMaxInFlight),
ChannelRules: make( ChannelRules: make(

@ -747,12 +747,18 @@ func (s *swapClientServer) GetLiquidityParams(_ context.Context,
totalRules := len(cfg.ChannelRules) + len(cfg.PeerRules) totalRules := len(cfg.ChannelRules) + len(cfg.PeerRules)
var destaddr string
if cfg.DestAddr != nil {
destaddr = cfg.DestAddr.String()
}
rpcCfg := &clientrpc.LiquidityParameters{ rpcCfg := &clientrpc.LiquidityParameters{
SweepConfTarget: cfg.SweepConfTarget, SweepConfTarget: cfg.SweepConfTarget,
FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()), FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()),
Autoloop: cfg.Autoloop, Autoloop: cfg.Autoloop,
AutoloopBudgetSat: uint64(cfg.AutoFeeBudget), AutoloopBudgetSat: uint64(cfg.AutoFeeBudget),
AutoMaxInFlight: uint64(cfg.MaxAutoInFlight), AutoMaxInFlight: uint64(cfg.MaxAutoInFlight),
AutoloopDestAddress: destaddr,
Rules: make( Rules: make(
[]*clientrpc.LiquidityRule, 0, totalRules, []*clientrpc.LiquidityRule, 0, totalRules,
), ),

Loading…
Cancel
Save