Skip to content

Commit c16e170

Browse files
committed
multi: expose confirmation target for loop out HTLC sweep
1 parent a138790 commit c16e170

File tree

6 files changed

+116
-70
lines changed

6 files changed

+116
-70
lines changed

cmd/loop/loopout.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ var loopOutCommand = cli.Command{
3636
Name: "amt",
3737
Usage: "the amount in satoshis to loop out",
3838
},
39+
cli.Uint64Flag{
40+
Name: "conf_target",
41+
Usage: "the number of blocks from the swap " +
42+
"initiation height that the on-chain HTLC " +
43+
"should be swept within",
44+
Value: uint64(loop.DefaultSweepConfTarget),
45+
},
3946
},
4047
Action: loopOut,
4148
}
@@ -75,8 +82,10 @@ func loopOut(ctx *cli.Context) error {
7582
}
7683
defer cleanup()
7784

85+
sweepConfTarget := int32(ctx.Uint64("conf_target"))
7886
quoteReq := &looprpc.QuoteRequest{
79-
Amt: int64(amt),
87+
Amt: int64(amt),
88+
ConfTarget: sweepConfTarget,
8089
}
8190
quote, err := client.LoopOutQuote(context.Background(), quoteReq)
8291
if err != nil {
@@ -103,6 +112,7 @@ func loopOut(ctx *cli.Context) error {
103112
MaxPrepayRoutingFee: int64(*limits.maxPrepayRoutingFee),
104113
MaxSwapRoutingFee: int64(*limits.maxSwapRoutingFee),
105114
LoopOutChannel: unchargeChannel,
115+
SweepConfTarget: sweepConfTarget,
106116
})
107117
if err != nil {
108118
return err

cmd/loopd/swapclient_server.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
4141

4242
logger.Infof("Loop out request received")
4343

44+
sweepConfTarget, err := validateConfTarget(
45+
in.SweepConfTarget, loop.DefaultSweepConfTarget,
46+
)
47+
if err != nil {
48+
return nil, err
49+
}
50+
4451
var sweepAddr btcutil.Address
4552
if in.Dest == "" {
4653
// Generate sweep address if none specified.
@@ -67,7 +74,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context,
6774
MaxPrepayRoutingFee: btcutil.Amount(in.MaxPrepayRoutingFee),
6875
MaxSwapRoutingFee: btcutil.Amount(in.MaxSwapRoutingFee),
6976
MaxSwapFee: btcutil.Amount(in.MaxSwapFee),
70-
SweepConfTarget: defaultConfTarget,
77+
SweepConfTarget: sweepConfTarget,
7178
}
7279
if in.LoopOutChannel != 0 {
7380
req.LoopOutChannel = &in.LoopOutChannel
@@ -249,7 +256,9 @@ func (s *swapClientServer) LoopOutTerms(ctx context.Context,
249256
func (s *swapClientServer) LoopOutQuote(ctx context.Context,
250257
req *looprpc.QuoteRequest) (*looprpc.QuoteResponse, error) {
251258

252-
confTarget, err := validateConfTarget(req.ConfTarget, defaultConfTarget)
259+
confTarget, err := validateConfTarget(
260+
req.ConfTarget, loop.DefaultSweepConfTarget,
261+
)
253262
if err != nil {
254263
return nil, err
255264
}

loopout.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ import (
2020
var (
2121
// MinLoopOutPreimageRevealDelta configures the minimum number of
2222
// remaining blocks before htlc expiry required to reveal preimage.
23-
MinLoopOutPreimageRevealDelta = int32(20)
23+
MinLoopOutPreimageRevealDelta int32 = 20
24+
25+
// DefaultSweepConfTarget is the default confirmation target we'll use
26+
// when sweeping on-chain HTLCs.
27+
DefaultSweepConfTarget int32 = 6
2428
)
2529

2630
// loopOutSwap contains all the in-memory state related to a pending loop out

looprpc/client.pb.go

Lines changed: 78 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ message LoopOutRequest {
127127
lowest routing fee for the swap payment to the server.
128128
*/
129129
uint64 loop_out_channel = 8;
130+
131+
/**
132+
The number of blocks from the on-chain HTLC's confirmation height that it
133+
should be swept within.
134+
*/
135+
int32 sweep_conf_target = 9;
130136
}
131137

132138
message LoopInRequest {

looprpc/client.swagger.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
"type": "string",
137137
"format": "uint64",
138138
"description": "*\nThe channel to loop out, the channel to loop out is selected based on the\nlowest routing fee for the swap payment to the server."
139+
},
140+
"sweep_conf_target": {
141+
"type": "integer",
142+
"format": "int32",
143+
"description": "*\nThe number of blocks from the on-chain HTLC's confirmation height that it\nshould be swept within."
139144
}
140145
}
141146
},

0 commit comments

Comments
 (0)