lncli: rename updatefees to updatechanpolicy

This commit renames the `lncli updatefees` command to
`lncli updatechanpolicy` and adds `time_lock_delta` as
one of the passed parameters.
This commit is contained in:
Johan T. Halseth 2017-12-16 23:13:17 +01:00
parent 551326586c
commit 26421031e2
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 42 additions and 19 deletions

@ -1970,7 +1970,7 @@ var feeReportCommand = cli.Command{
Usage: "display the current fee policies of all active channels", Usage: "display the current fee policies of all active channels",
Description: ` Description: `
Returns the current fee policies of all active channels. Returns the current fee policies of all active channels.
Fee policies can be updated using the updateFees command.`, Fee policies can be updated using the updatechanpolicy command.`,
Action: actionDecorator(feeReport), Action: actionDecorator(feeReport),
} }
@ -1989,13 +1989,13 @@ func feeReport(ctx *cli.Context) error {
return nil return nil
} }
var updateFeesCommand = cli.Command{ var updateChannelPolicyCommand = cli.Command{
Name: "updatefees", Name: "updatechanpolicy",
Usage: "update the fee policy for all channels, or a single channel", Usage: "update the channel policy for all channels, or a single channel",
ArgsUsage: "base_fee_msat fee_rate [channel_point]", ArgsUsage: "base_fee_msat fee_rate time_lock_delta [channel_point]",
Description: ` Description: `
Updates the fee policy for all channels, or just a particular channel Updates the channel policy for all channels, or just a particular channel
identified by it's channel point. The fee update will be committed, and identified by its channel point. The update will be committed, and
broadcast to the rest of the network within the next batch. broadcast to the rest of the network within the next batch.
Channel points are encoded as: funding_txid:output_index`, Channel points are encoded as: funding_txid:output_index`,
Flags: []cli.Flag{ Flags: []cli.Flag{
@ -2011,6 +2011,11 @@ var updateFeesCommand = cli.Command{
"proportionally based on the value of each " + "proportionally based on the value of each " +
"forwarded HTLC, the lowest possible rate is 0.000001", "forwarded HTLC, the lowest possible rate is 0.000001",
}, },
cli.Int64Flag{
Name: "time_lock_delta",
Usage: "the CLTV delta that will be applied to all " +
"forwarded HTLCs",
},
cli.StringFlag{ cli.StringFlag{
Name: "chan_point", Name: "chan_point",
Usage: "The channel whose fee policy should be " + Usage: "The channel whose fee policy should be " +
@ -2018,10 +2023,10 @@ var updateFeesCommand = cli.Command{
"will be updated. Takes the form of: txid:output_index", "will be updated. Takes the form of: txid:output_index",
}, },
}, },
Action: actionDecorator(updateFees), Action: actionDecorator(updateChannelPolicy),
} }
func updateFees(ctx *cli.Context) error { func updateChannelPolicy(ctx *cli.Context) error {
ctxb := context.Background() ctxb := context.Background()
client, cleanUp := getClient(ctx) client, cleanUp := getClient(ctx)
defer cleanUp() defer cleanUp()
@ -2029,6 +2034,7 @@ func updateFees(ctx *cli.Context) error {
var ( var (
baseFee int64 baseFee int64
feeRate float64 feeRate float64
timeLockDelta int64
err error err error
) )
args := ctx.Args() args := ctx.Args()
@ -2060,10 +2066,26 @@ func updateFees(ctx *cli.Context) error {
return fmt.Errorf("fee_rate argument missing") return fmt.Errorf("fee_rate argument missing")
} }
switch {
case ctx.IsSet("time_lock_delta"):
timeLockDelta = ctx.Int64("time_lock_delta")
case args.Present():
timeLockDelta, err = strconv.ParseInt(args.First(), 10, 64)
if err != nil {
return fmt.Errorf("unable to decode time_lock_delta: %v",
err)
}
args = args.Tail()
default:
return fmt.Errorf("time_lock_delta argument missing")
}
var ( var (
chanPoint *lnrpc.ChannelPoint chanPoint *lnrpc.ChannelPoint
chanPointStr string chanPointStr string
) )
switch { switch {
case ctx.IsSet("chan_point"): case ctx.IsSet("chan_point"):
chanPointStr = ctx.String("chan_point") chanPointStr = ctx.String("chan_point")
@ -2093,22 +2115,23 @@ func updateFees(ctx *cli.Context) error {
} }
} }
req := &lnrpc.FeeUpdateRequest{ req := &lnrpc.PolicyUpdateRequest{
BaseFeeMsat: baseFee, BaseFeeMsat: baseFee,
FeeRate: feeRate, FeeRate: feeRate,
TimeLockDelta: uint32(timeLockDelta),
} }
if chanPoint != nil { if chanPoint != nil {
req.Scope = &lnrpc.FeeUpdateRequest_ChanPoint{ req.Scope = &lnrpc.PolicyUpdateRequest_ChanPoint{
ChanPoint: chanPoint, ChanPoint: chanPoint,
} }
} else { } else {
req.Scope = &lnrpc.FeeUpdateRequest_Global{ req.Scope = &lnrpc.PolicyUpdateRequest_Global{
Global: true, Global: true,
} }
} }
resp, err := client.UpdateFees(ctxb, req) resp, err := client.UpdateChannelPolicy(ctxb, req)
if err != nil { if err != nil {
return err return err
} }

@ -193,7 +193,7 @@ func main() {
signMessageCommand, signMessageCommand,
verifyMessageCommand, verifyMessageCommand,
feeReportCommand, feeReportCommand,
updateFeesCommand, updateChannelPolicyCommand,
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {