lncli: use routerrpc for payments

This commit is contained in:
Joost Jager
2020-03-30 12:45:14 +02:00
parent f060da3971
commit dead6a772a
2 changed files with 116 additions and 60 deletions

View File

@@ -2380,7 +2380,7 @@ func queryRoutes(ctx *cli.Context) error {
return fmt.Errorf("amt argument missing")
}
feeLimit, err := retrieveFeeLimit(ctx)
feeLimit, err := retrieveFeeLimitLegacy(ctx)
if err != nil {
return err
}
@@ -2403,6 +2403,38 @@ func queryRoutes(ctx *cli.Context) error {
return nil
}
// retrieveFeeLimitLegacy retrieves the fee limit based on the different fee
// limit flags passed. This function will eventually disappear in favor of
// retrieveFeeLimit and the new payment rpc.
func retrieveFeeLimitLegacy(ctx *cli.Context) (*lnrpc.FeeLimit, error) {
switch {
case ctx.IsSet("fee_limit") && ctx.IsSet("fee_limit_percent"):
return nil, fmt.Errorf("either fee_limit or fee_limit_percent " +
"can be set, but not both")
case ctx.IsSet("fee_limit"):
return &lnrpc.FeeLimit{
Limit: &lnrpc.FeeLimit_Fixed{
Fixed: ctx.Int64("fee_limit"),
},
}, nil
case ctx.IsSet("fee_limit_percent"):
feeLimitPercent := ctx.Int64("fee_limit_percent")
if feeLimitPercent < 0 {
return nil, errors.New("negative fee limit percentage " +
"provided")
}
return &lnrpc.FeeLimit{
Limit: &lnrpc.FeeLimit_Percent{
Percent: feeLimitPercent,
},
}, nil
}
// Since the fee limit flags aren't required, we don't return an error
// if they're not set.
return nil, nil
}
var getNetworkInfoCommand = cli.Command{
Name: "getnetworkinfo",
Category: "Channels",