mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: add OutAddr parameter for autoloop loop out
This commit is contained in:
parent
0ef205cb24
commit
fa0393b331
4 changed files with 48 additions and 6 deletions
|
|
@ -286,6 +286,12 @@ var setParamsCommand = cli.Command{
|
|||
"of swaps, limited to the budget set by " +
|
||||
"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{
|
||||
Name: "autobudget",
|
||||
Usage: "the maximum amount of fees in satoshis that " +
|
||||
|
|
@ -429,6 +435,11 @@ func setParams(ctx *cli.Context) error {
|
|||
flagSet = true
|
||||
}
|
||||
|
||||
if ctx.IsSet("destaddr") {
|
||||
params.AutoloopDestAddress = ctx.String("destaddr")
|
||||
flagSet = true
|
||||
}
|
||||
|
||||
if ctx.IsSet("budgetstart") {
|
||||
params.AutoloopBudgetStartSec = ctx.Uint64("budgetstart")
|
||||
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.
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ import (
|
|||
|
||||
var (
|
||||
// defaultParameters contains the default parameters that we start our
|
||||
// liquidity manger with.
|
||||
// liquidity manager with.
|
||||
defaultParameters = Parameters{
|
||||
AutoFeeBudget: defaultBudget,
|
||||
DestAddr: nil,
|
||||
MaxAutoInFlight: defaultMaxInFlight,
|
||||
ChannelRules: make(map[lnwire.ShortChannelID]*SwapRule),
|
||||
PeerRules: make(map[route.Vertex]*SwapRule),
|
||||
|
|
@ -37,6 +38,10 @@ type Parameters struct {
|
|||
// Autoloop enables automatic dispatch of swaps.
|
||||
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
|
||||
// automatically dispatched swaps. Once this budget has been used, we
|
||||
// will stop dispatching swaps until the budget is increased or the
|
||||
|
|
@ -347,12 +352,25 @@ func rpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
|
|||
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{
|
||||
FeeLimit: feeLimit,
|
||||
SweepConfTarget: req.SweepConfTarget,
|
||||
FailureBackOff: time.Duration(req.FailureBackoffSec) *
|
||||
time.Second,
|
||||
Autoloop: req.Autoloop,
|
||||
DestAddr: destaddr,
|
||||
AutoFeeBudget: btcutil.Amount(req.AutoloopBudgetSat),
|
||||
MaxAutoInFlight: int(req.AutoMaxInFlight),
|
||||
ChannelRules: make(
|
||||
|
|
|
|||
|
|
@ -747,12 +747,18 @@ func (s *swapClientServer) GetLiquidityParams(_ context.Context,
|
|||
|
||||
totalRules := len(cfg.ChannelRules) + len(cfg.PeerRules)
|
||||
|
||||
var destaddr string
|
||||
if cfg.DestAddr != nil {
|
||||
destaddr = cfg.DestAddr.String()
|
||||
}
|
||||
|
||||
rpcCfg := &clientrpc.LiquidityParameters{
|
||||
SweepConfTarget: cfg.SweepConfTarget,
|
||||
FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()),
|
||||
Autoloop: cfg.Autoloop,
|
||||
AutoloopBudgetSat: uint64(cfg.AutoFeeBudget),
|
||||
AutoMaxInFlight: uint64(cfg.MaxAutoInFlight),
|
||||
SweepConfTarget: cfg.SweepConfTarget,
|
||||
FailureBackoffSec: uint64(cfg.FailureBackOff.Seconds()),
|
||||
Autoloop: cfg.Autoloop,
|
||||
AutoloopBudgetSat: uint64(cfg.AutoFeeBudget),
|
||||
AutoMaxInFlight: uint64(cfg.MaxAutoInFlight),
|
||||
AutoloopDestAddress: destaddr,
|
||||
Rules: make(
|
||||
[]*clientrpc.LiquidityRule, 0, totalRules,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue