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

Minor improvements in the lncli api regarding channel closures. #8350

Merged
merged 4 commits into from
Jan 16, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,10 @@ var closeChannelCommand = cli.Command{
In the case of a cooperative closure, one can manually set the fee to
be used for the closing transaction via either the --conf_target or
--sat_per_vbyte arguments. This will be the starting value used during
fee negotiation. This is optional.
fee negotiation. This is optional. The parameter --max_fee_rate in
comparison is the end boundary of the fee negotiation, if not specified
it's always x3 of the starting value. Increasing this value increases
the chance of a successful negotiation.

In the case of a cooperative closure, one can manually set the address
to deliver funds to upon closure. This is optional, and may only be used
Expand Down Expand Up @@ -808,7 +811,8 @@ var closeChannelCommand = cli.Command{
Name: "sat_per_vbyte",
Usage: "(optional) a manual fee expressed in " +
"sat/vbyte that should be used when crafting " +
"the transaction",
"the transaction; default is a conf-target " +
"of 6 blocks",
},
cli.StringFlag{
Name: "delivery_addr",
Expand All @@ -817,6 +821,14 @@ var closeChannelCommand = cli.Command{
"be used if an upfront shutdown address is not " +
"already set",
},
cli.Uint64Flag{
Name: "max_fee_rate",
Usage: "(optional) maximum fee rate in sat/vbyte " +
"accepted during the negotiation (default is " +
"x3 of the desired fee rate); increases the " +
"success pobability of the negotiation if " +
"set higher",
},
},
Action: actionDecorator(closeChannel),
}
Expand Down Expand Up @@ -853,6 +865,7 @@ func closeChannel(ctx *cli.Context) error {
TargetConf: int32(ctx.Int64("conf_target")),
SatPerVbyte: ctx.Uint64(feeRateFlag),
DeliveryAddress: ctx.String("delivery_addr"),
MaxFeePerVbyte: ctx.Uint64("max_fee_rate"),
}

// After parsing the request, we'll spin up a goroutine that will
Expand Down
77 changes: 59 additions & 18 deletions cmd/lncli/walletrpc_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func walletCommands() []cli.Command {
pendingSweepsCommand,
bumpFeeCommand,
bumpCloseFeeCommand,
bumpForceCloseFeeCommand,
listSweepsCommand,
labelTxCommand,
publishTxCommand,
Expand Down Expand Up @@ -266,14 +267,19 @@ func bumpFee(ctx *cli.Context) error {

var bumpCloseFeeCommand = cli.Command{
Name: "bumpclosefee",
Usage: "Bumps the fee of a channel closing transaction.",
Usage: "Bumps the fee of a channel force closing transaction.",
ArgsUsage: "channel_point",
Hidden: true,
Description: `
This command allows the fee of a channel closing transaction to be
increased by using the child-pays-for-parent mechanism. It will instruct
the sweeper to sweep the anchor outputs of transactions in the set
of valid commitments for the specified channel at the requested fee
rate or confirmation target.
This command works only for unilateral closes of anchor channels. It
allows the fee of a channel force closing transaction to be increased by
using the child-pays-for-parent mechanism. It will instruct the sweeper
to sweep the anchor outputs of the closing transaction at the requested
fee rate or confirmation target. The specified fee rate will be the
effective fee rate taking the parent fee into account.
Depending on the sweeper configuration (batchwindowduration) the sweeptx
will not be published immediately.
NOTE: This cmd is DEPRECATED please use bumpforceclosefee instead.
`,
Flags: []cli.Flag{
cli.Uint64Flag{
Expand All @@ -292,10 +298,44 @@ var bumpCloseFeeCommand = cli.Command{
"should be used when sweeping the output",
},
},
Action: actionDecorator(bumpCloseFee),
Action: actionDecorator(bumpForceCloseFee),
}

func bumpCloseFee(ctx *cli.Context) error {
var bumpForceCloseFeeCommand = cli.Command{
Name: "bumpforceclosefee",
ziggie1984 marked this conversation as resolved.
Show resolved Hide resolved
Usage: "Bumps the fee of a channel force closing transaction.",
ArgsUsage: "channel_point",
Description: `
This command works only for unilateral closes of anchor channels. It
allows the fee of a channel force closing transaction to be increased by
using the child-pays-for-parent mechanism. It will instruct the sweeper
to sweep the anchor outputs of the closing transaction at the requested
fee rate or confirmation target. The specified fee rate will be the
effective fee rate taking the parent fee into account.
Depending on the sweeper configuration (batchwindowduration) the sweeptx
will not be published immediately.
ziggie1984 marked this conversation as resolved.
Show resolved Hide resolved
`,
Flags: []cli.Flag{
cli.Uint64Flag{
Name: "conf_target",
Usage: "the number of blocks that the output should " +
"be swept on-chain within",
},
cli.Uint64Flag{
Name: "sat_per_byte",
Usage: "Deprecated, use sat_per_vbyte instead.",
Hidden: true,
},
cli.Uint64Flag{
Name: "sat_per_vbyte",
Usage: "a manual fee expressed in sat/vbyte that " +
"should be used when sweeping the output",
},
},
Action: actionDecorator(bumpForceCloseFee),
}

func bumpForceCloseFee(ctx *cli.Context) error {
ctxc := getContext()

// Display the command's help message if we do not have the expected
Expand Down Expand Up @@ -368,19 +408,20 @@ func bumpCloseFee(ctx *cli.Context) error {
continue
}

// Bump fee of the anchor sweep.
fmt.Printf("Bumping fee of %v:%v\n",
sweepTxID, sweep.Outpoint.OutputIndex)

_, err = walletClient.BumpFee(ctxc, &walletrpc.BumpFeeRequest{
Outpoint: sweep.Outpoint,
TargetConf: uint32(ctx.Uint64("conf_target")),
SatPerVbyte: ctx.Uint64(feeRateFlag),
Force: true,
})
resp, err := walletClient.BumpFee(
ctxc, &walletrpc.BumpFeeRequest{
Outpoint: sweep.Outpoint,
TargetConf: uint32(ctx.Uint64("conf_target")),
SatPerVbyte: ctx.Uint64(feeRateFlag),
Force: true,
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: closing parenthesis on new line.

if err != nil {
return err
}

// Bump fee of the anchor sweep.
fmt.Printf("Bumping fee of %v:%v: %v\n",
sweepTxID, sweep.Outpoint.OutputIndex, resp.GetStatus())
}

return nil
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@

## lncli Additions

* Deprecate `bumpclosefee` for `bumpforceclosefee` to accomodate for the fact
that only force closing transactions can be bumped to avoid confusion.
Moreover allow to specify a max fee rate range when coop closing a channel.
[Deprecate bumpclosefee for bumpforceclosefee and add `max_fee_rate` option
to `closechannel` cmd](https://github.com/lightningnetwork/lnd/pull/8350).

# Improvements
## Functional Updates
### Tlv
Expand Down