From 298f35cdfbcfbf171fb7de645e90bdf6a368d6c8 Mon Sep 17 00:00:00 2001 From: Anton Kovalenko Date: Wed, 20 Nov 2019 18:19:50 +0300 Subject: [PATCH] lncli addholdinvoice: allow specifying msat with --amt_msat * pass amt and amt_msat to rpc, letting server give an error if both are present * take amt from an extra argument if neither amt nor amt_ms are present --- cmd/lncli/invoicesrpc_active.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/lncli/invoicesrpc_active.go b/cmd/lncli/invoicesrpc_active.go index 1cb5471a..75b7090c 100644 --- a/cmd/lncli/invoicesrpc_active.go +++ b/cmd/lncli/invoicesrpc_active.go @@ -160,6 +160,10 @@ var addHoldInvoiceCommand = cli.Command{ Name: "amt", Usage: "the amt of satoshis in this invoice", }, + cli.Int64Flag{ + Name: "amt_msat", + Usage: "the amt of millisatoshis in this invoice", + }, cli.StringFlag{ Name: "description_hash", Usage: "SHA-256 hash of the description of the payment. " + @@ -192,7 +196,6 @@ var addHoldInvoiceCommand = cli.Command{ func addHoldInvoice(ctx *cli.Context) error { var ( descHash []byte - amt int64 err error ) @@ -212,12 +215,11 @@ func addHoldInvoice(ctx *cli.Context) error { args = args.Tail() - switch { - case ctx.IsSet("amt"): - amt = ctx.Int64("amt") - case args.Present(): - amt, err = strconv.ParseInt(args.First(), 10, 64) + amt := ctx.Int64("amt") + amtMsat := ctx.Int64("amt_msat") + if !ctx.IsSet("amt") && !ctx.IsSet("amt_msat") && args.Present() { + amt, err = strconv.ParseInt(args.First(), 10, 64) if err != nil { return fmt.Errorf("unable to decode amt argument: %v", err) } @@ -236,6 +238,7 @@ func addHoldInvoice(ctx *cli.Context) error { Memo: ctx.String("memo"), Hash: hash, Value: amt, + ValueMsat: amtMsat, DescriptionHash: descHash, FallbackAddr: ctx.String("fallback_addr"), Expiry: ctx.Int64("expiry"),