Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticAddr: Withdraw arbitrary amounts #860

Merged
merged 4 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cmd/loop/staticaddr.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ var withdrawalCommand = cli.Command{
Usage: "withdraws all static address deposits.",
},
cli.StringFlag{
Name: "addr",
Name: "dest_addr",
Usage: "the optional address that the withdrawn " +
"funds should be sent to, if let blank the " +
"funds will go to lnd's wallet",
Expand All @@ -159,6 +159,12 @@ var withdrawalCommand = cli.Command{
"sat/vbyte that should be used when crafting " +
"the transaction",
},
cli.IntFlag{
Name: "amount",
Usage: "the number of satoshis that should be " +
"withdrawn from the selected deposits. The " +
"change is sent back to the static address",
},
},
Action: withdraw,
}
Expand Down Expand Up @@ -198,8 +204,8 @@ func withdraw(ctx *cli.Context) error {
return fmt.Errorf("unknown withdrawal request")
}

if ctx.IsSet("addr") {
destAddr = ctx.String("addr")
if ctx.IsSet("dest_addr") {
destAddr = ctx.String("dest_addr")
}

resp, err := client.WithdrawDeposits(ctxb,
Expand All @@ -208,6 +214,7 @@ func withdraw(ctx *cli.Context) error {
All: isAllSelected,
DestAddr: destAddr,
SatPerVbyte: int64(ctx.Uint64("sat_per_vbyte")),
Amount: ctx.Int64("amount"),
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion loopd/swapclient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
}

txhash, pkScript, err := s.withdrawalManager.DeliverWithdrawalRequest(
ctx, outpoints, req.DestAddr, req.SatPerVbyte,
ctx, outpoints, req.DestAddr, req.SatPerVbyte, req.Amount,
)
if err != nil {
return nil, err
Expand Down
889 changes: 452 additions & 437 deletions looprpc/client.pb.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions looprpc/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,15 @@ message WithdrawDepositsRequest {
The fee rate in sat/vbyte to use for the withdrawal transaction.
*/
int64 sat_per_vbyte = 4;

/*
The amount in satoshis that should be withdrawn from the selected deposits.
If there is change, it will be sent back to the static address. The fees for
the transaction are taken from the change output. If the change is below
the dust limit, there won't be a change output and the dust goes towards
fees.
*/
int64 amount = 5;
}

message WithdrawDepositsResponse {
Expand Down
Loading
Loading