Skip to content

Commit

Permalink
Merge pull request #859 from hieblmi/withdrawal-fee-and-address
Browse files Browse the repository at this point in the history
StaticAddr: withdrawal destination address and fee rate
  • Loading branch information
hieblmi authored Nov 29, 2024
2 parents 6982adb + fb9562b commit 5b68e42
Show file tree
Hide file tree
Showing 5 changed files with 503 additions and 426 deletions.
26 changes: 21 additions & 5 deletions cmd/loop/staticaddr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build staticaddr
// +build staticaddr

package main

import (
Expand Down Expand Up @@ -145,6 +142,18 @@ var withdrawalCommand = cli.Command{
Name: "all",
Usage: "withdraws all static address deposits.",
},
cli.StringFlag{
Name: "addr",
Usage: "the optional address that the withdrawn " +
"funds should be sent to, if let blank the " +
"funds will go to lnd's wallet",
},
cli.Int64Flag{
Name: "sat_per_vbyte",
Usage: "(optional) a manual fee expressed in " +
"sat/vbyte that should be used when crafting " +
"the transaction",
},
},
Action: withdraw,
}
Expand All @@ -165,6 +174,7 @@ func withdraw(ctx *cli.Context) error {
isUtxoSelected = ctx.IsSet("utxo")
outpoints []*looprpc.OutPoint
ctxb = context.Background()
destAddr string
)

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

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

resp, err := client.WithdrawDeposits(ctxb,
&looprpc.WithdrawDepositsRequest{
Outpoints: outpoints,
All: isAllSelected,
Outpoints: outpoints,
All: isAllSelected,
DestAddr: destAddr,
SatPerVbyte: int64(ctx.Uint64("sat_per_vbyte")),
})
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 @@ -1447,7 +1447,7 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
}

txhash, pkScript, err := s.withdrawalManager.DeliverWithdrawalRequest(
ctx, outpoints,
ctx, outpoints, req.DestAddr, req.SatPerVbyte,
)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 5b68e42

Please sign in to comment.