Skip to content

Commit e41e7f5

Browse files
authored
Merge pull request #860 from hieblmi/withdraw-amounts
StaticAddr: Withdraw arbitrary amounts
2 parents c8546d9 + c7cc47b commit e41e7f5

File tree

7 files changed

+823
-669
lines changed

7 files changed

+823
-669
lines changed

cmd/loop/staticaddr.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var withdrawalCommand = cli.Command{
148148
Usage: "withdraws all static address deposits.",
149149
},
150150
cli.StringFlag{
151-
Name: "addr",
151+
Name: "dest_addr",
152152
Usage: "the optional address that the withdrawn " +
153153
"funds should be sent to, if let blank the " +
154154
"funds will go to lnd's wallet",
@@ -159,6 +159,12 @@ var withdrawalCommand = cli.Command{
159159
"sat/vbyte that should be used when crafting " +
160160
"the transaction",
161161
},
162+
cli.IntFlag{
163+
Name: "amount",
164+
Usage: "the number of satoshis that should be " +
165+
"withdrawn from the selected deposits. The " +
166+
"change is sent back to the static address",
167+
},
162168
},
163169
Action: withdraw,
164170
}
@@ -198,8 +204,8 @@ func withdraw(ctx *cli.Context) error {
198204
return fmt.Errorf("unknown withdrawal request")
199205
}
200206

201-
if ctx.IsSet("addr") {
202-
destAddr = ctx.String("addr")
207+
if ctx.IsSet("dest_addr") {
208+
destAddr = ctx.String("dest_addr")
203209
}
204210

205211
resp, err := client.WithdrawDeposits(ctxb,
@@ -208,6 +214,7 @@ func withdraw(ctx *cli.Context) error {
208214
All: isAllSelected,
209215
DestAddr: destAddr,
210216
SatPerVbyte: int64(ctx.Uint64("sat_per_vbyte")),
217+
Amount: ctx.Int64("amount"),
211218
})
212219
if err != nil {
213220
return err

loopd/swapclient_server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
15411541
}
15421542

15431543
txhash, pkScript, err := s.withdrawalManager.DeliverWithdrawalRequest(
1544-
ctx, outpoints, req.DestAddr, req.SatPerVbyte,
1544+
ctx, outpoints, req.DestAddr, req.SatPerVbyte, req.Amount,
15451545
)
15461546
if err != nil {
15471547
return nil, err

looprpc/client.pb.go

+452-437
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

+9
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,15 @@ message WithdrawDepositsRequest {
16231623
The fee rate in sat/vbyte to use for the withdrawal transaction.
16241624
*/
16251625
int64 sat_per_vbyte = 4;
1626+
1627+
/*
1628+
The amount in satoshis that should be withdrawn from the selected deposits.
1629+
If there is change, it will be sent back to the static address. The fees for
1630+
the transaction are taken from the change output. If the change is below
1631+
the dust limit, there won't be a change output and the dust goes towards
1632+
fees.
1633+
*/
1634+
int64 amount = 5;
16261635
}
16271636

16281637
message WithdrawDepositsResponse {

0 commit comments

Comments
 (0)