mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 18:43:42 +02:00
Merge pull request #6858 from bottlepay/lncli-fix-sendpayment
lncli: fix sendpayment arg parsing
This commit is contained in:
@ -171,7 +171,8 @@ var sendPaymentCommand = cli.Command{
|
|||||||
For invoice with payment address:
|
For invoice with payment address:
|
||||||
--dest=N --amt=A --payment_hash=H --final_cltv_delta=T --pay_addr=H
|
--dest=N --amt=A --payment_hash=H --final_cltv_delta=T --pay_addr=H
|
||||||
`,
|
`,
|
||||||
ArgsUsage: "dest amt payment_hash final_cltv_delta pay_addr | --pay_req=[payment request]",
|
ArgsUsage: "dest amt payment_hash final_cltv_delta pay_addr | " +
|
||||||
|
"--pay_req=R [--pay_addr=H]",
|
||||||
Flags: append(paymentFlags(),
|
Flags: append(paymentFlags(),
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "dest, d",
|
Name: "dest, d",
|
||||||
@ -244,7 +245,7 @@ func confirmPayReq(resp *lnrpc.PayReq, amt, feeLimit int64) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePayAddr(ctx *cli.Context) ([]byte, error) {
|
func parsePayAddr(ctx *cli.Context, args cli.Args) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
payAddr []byte
|
payAddr []byte
|
||||||
err error
|
err error
|
||||||
@ -253,8 +254,8 @@ func parsePayAddr(ctx *cli.Context) ([]byte, error) {
|
|||||||
case ctx.IsSet("pay_addr"):
|
case ctx.IsSet("pay_addr"):
|
||||||
payAddr, err = hex.DecodeString(ctx.String("pay_addr"))
|
payAddr, err = hex.DecodeString(ctx.String("pay_addr"))
|
||||||
|
|
||||||
case ctx.Args().Present():
|
case args.Present():
|
||||||
payAddr, err = hex.DecodeString(ctx.Args().First())
|
payAddr, err = hex.DecodeString(args.First())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -291,7 +292,10 @@ func sendPayment(ctx *cli.Context) error {
|
|||||||
// We'll attempt to parse a payment address as well, given that
|
// We'll attempt to parse a payment address as well, given that
|
||||||
// if the user is using an AMP invoice, then they may be trying
|
// if the user is using an AMP invoice, then they may be trying
|
||||||
// to specify that value manually.
|
// to specify that value manually.
|
||||||
payAddr, err := parsePayAddr(ctx)
|
//
|
||||||
|
// Don't parse unnamed arguments to prevent confusion with the main
|
||||||
|
// unnamed argument format for non-AMP payments.
|
||||||
|
payAddr, err := parsePayAddr(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -394,10 +398,11 @@ func sendPayment(ctx *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
args = args.Tail()
|
||||||
req.FinalCltvDelta = int32(delta)
|
req.FinalCltvDelta = int32(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
payAddr, err := parsePayAddr(ctx)
|
payAddr, err := parsePayAddr(ctx, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,9 @@ minimum version needed to build the project.
|
|||||||
caller to specify key-value string pairs that should be appended to the
|
caller to specify key-value string pairs that should be appended to the
|
||||||
outgoing context.
|
outgoing context.
|
||||||
|
|
||||||
|
* [Fix](https://github.com/lightningnetwork/lnd/pull/6858) command line argument
|
||||||
|
parsing for `lncli sendpayment`.
|
||||||
|
|
||||||
## Code Health
|
## Code Health
|
||||||
|
|
||||||
* [test: use `T.TempDir` to create temporary test
|
* [test: use `T.TempDir` to create temporary test
|
||||||
|
Reference in New Issue
Block a user