Skip to content

Commit 5b68e42

Browse files
authored
Merge pull request #859 from hieblmi/withdrawal-fee-and-address
StaticAddr: withdrawal destination address and fee rate
2 parents 6982adb + fb9562b commit 5b68e42

File tree

5 files changed

+503
-426
lines changed

5 files changed

+503
-426
lines changed

cmd/loop/staticaddr.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build staticaddr
2-
// +build staticaddr
3-
41
package main
52

63
import (
@@ -145,6 +142,18 @@ var withdrawalCommand = cli.Command{
145142
Name: "all",
146143
Usage: "withdraws all static address deposits.",
147144
},
145+
cli.StringFlag{
146+
Name: "addr",
147+
Usage: "the optional address that the withdrawn " +
148+
"funds should be sent to, if let blank the " +
149+
"funds will go to lnd's wallet",
150+
},
151+
cli.Int64Flag{
152+
Name: "sat_per_vbyte",
153+
Usage: "(optional) a manual fee expressed in " +
154+
"sat/vbyte that should be used when crafting " +
155+
"the transaction",
156+
},
148157
},
149158
Action: withdraw,
150159
}
@@ -165,6 +174,7 @@ func withdraw(ctx *cli.Context) error {
165174
isUtxoSelected = ctx.IsSet("utxo")
166175
outpoints []*looprpc.OutPoint
167176
ctxb = context.Background()
177+
destAddr string
168178
)
169179

170180
switch {
@@ -183,10 +193,16 @@ func withdraw(ctx *cli.Context) error {
183193
return fmt.Errorf("unknown withdrawal request")
184194
}
185195

196+
if ctx.IsSet("addr") {
197+
destAddr = ctx.String("addr")
198+
}
199+
186200
resp, err := client.WithdrawDeposits(ctxb,
187201
&looprpc.WithdrawDepositsRequest{
188-
Outpoints: outpoints,
189-
All: isAllSelected,
202+
Outpoints: outpoints,
203+
All: isAllSelected,
204+
DestAddr: destAddr,
205+
SatPerVbyte: int64(ctx.Uint64("sat_per_vbyte")),
190206
})
191207
if err != nil {
192208
return err

loopd/swapclient_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
14471447
}
14481448

14491449
txhash, pkScript, err := s.withdrawalManager.DeliverWithdrawalRequest(
1450-
ctx, outpoints,
1450+
ctx, outpoints, req.DestAddr, req.SatPerVbyte,
14511451
)
14521452
if err != nil {
14531453
return nil, err

0 commit comments

Comments
 (0)