loop: xpub support for loop out

pull/605/head
Slyghtning 10 months ago
parent ca933f843c
commit d975b56f0e
No known key found for this signature in database
GPG Key ID: F82D456EA023C9BF

@ -292,6 +292,21 @@ var setParamsCommand = cli.Command{
"autoloop loop out, set to \"default\" in " +
"order to revert to default behavior.",
},
cli.StringFlag{
Name: "account",
Usage: "the name of the account to generate a new " +
"address from. You can list the names of " +
"valid accounts in your backing lnd " +
"instance with \"lncli wallet accounts list\".",
Value: "",
},
cli.StringFlag{
Name: "account_addr_type",
Usage: "the address type of the extended public key " +
"specified in account. Currently only " +
"pay-to-taproot-pubkey(p2tr) is supported",
Value: "p2tr",
},
cli.Uint64Flag{
Name: "autobudget",
Usage: "the maximum amount of fees in satoshis that " +
@ -445,11 +460,35 @@ func setParams(ctx *cli.Context) error {
flagSet = true
}
if ctx.IsSet("destaddr") {
switch {
case ctx.IsSet("destaddr") && ctx.IsSet("account"):
return fmt.Errorf("cannot set destaddr and account at the " +
"same time")
case ctx.IsSet("destaddr"):
params.AutoloopDestAddress = ctx.String("destaddr")
params.Account = ""
flagSet = true
case ctx.IsSet("account") != ctx.IsSet("account_addr_type"):
return liquidity.ErrAccountAndAddrType
case ctx.IsSet("account"):
params.Account = ctx.String("account")
params.AutoloopDestAddress = ""
flagSet = true
}
if ctx.IsSet("account_addr_type") {
switch ctx.String("account_addr_type") {
case "p2tr":
params.AccountAddrType = looprpc.AddressType_TAPROOT_PUBKEY
default:
return fmt.Errorf("unknown account address type")
}
}
if ctx.IsSet("autobudgetrefreshperiod") {
params.AutoloopBudgetRefreshPeriodSec =
uint64(ctx.Duration("autobudgetrefreshperiod").Seconds())

@ -39,6 +39,21 @@ var loopOutCommand = cli.Command{
"should be sent to, if let blank the funds " +
"will go to lnd's wallet",
},
cli.StringFlag{
Name: "account",
Usage: "the name of the account to generate a new " +
"address from. You can list the names of " +
"valid accounts in your backing lnd " +
"instance with \"lncli wallet accounts list\".",
Value: "",
},
cli.StringFlag{
Name: "account_addr_type",
Usage: "the address type of the extended public key " +
"specified in account. Currently only " +
"pay-to-taproot-pubkey(p2tr) is supported",
Value: "p2tr",
},
cli.Uint64Flag{
Name: "amt",
Usage: "the amount in satoshis to loop out",
@ -101,7 +116,7 @@ func loopOut(ctx *cli.Context) error {
}
// Parse outgoing channel set. Don't string split if the flag is empty.
// Otherwise strings.Split returns a slice of length one with an empty
// Otherwise, strings.Split returns a slice of length one with an empty
// element.
var outgoingChanSet []uint64
if ctx.IsSet("channel") {
@ -122,14 +137,41 @@ func loopOut(ctx *cli.Context) error {
return err
}
if ctx.IsSet("addr") && ctx.IsSet("account") {
return fmt.Errorf("cannot set --addr and --account at the " +
"same time. Please specify only one source for a new " +
"address to sweep the loop amount to")
}
var destAddr string
var account string
switch {
case ctx.IsSet("addr"):
destAddr = ctx.String("addr")
case ctx.IsSet("account"):
account = ctx.String("account")
case args.Present():
destAddr = args.First()
}
if ctx.IsSet("account") != ctx.IsSet("account_addr_type") {
return fmt.Errorf("cannot set account without specifying " +
"account address type and vice versa")
}
var accountAddrType looprpc.AddressType
if ctx.IsSet("account_addr_type") {
switch ctx.String("account_addr_type") {
case "p2tr":
accountAddrType = looprpc.AddressType_TAPROOT_PUBKEY
default:
return fmt.Errorf("unknown account address type")
}
}
client, cleanup, err := getClient(ctx)
if err != nil {
return err
@ -191,6 +233,8 @@ func loopOut(ctx *cli.Context) error {
resp, err := client.LoopOut(context.Background(), &looprpc.LoopOutRequest{
Amt: int64(amt),
Dest: destAddr,
Account: account,
AccountAddrType: accountAddrType,
MaxMinerFee: int64(limits.maxMinerFee),
MaxPrepayAmt: int64(limits.maxPrepayAmt),
MaxSwapFee: int64(limits.maxSwapFee),

Loading…
Cancel
Save