lncli: add new zpay32 options to command line
The new BOLT-11 compliant zpay32 package offers a few new available options when creating invoices. This commit adds those options to lncli, such that callers can specify these when creating payment requests.
This commit is contained in:
parent
15d753fd9e
commit
ed8dd0b9e4
@ -764,7 +764,7 @@ var sendPaymentCommand = cli.Command{
|
|||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "pay_req",
|
Name: "pay_req",
|
||||||
Usage: "a zbase32-check encoded payment request to fulfill",
|
Usage: "a bech32 encoded payment request to fulfill",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: sendPayment,
|
Action: sendPayment,
|
||||||
@ -885,12 +885,14 @@ var addInvoiceCommand = cli.Command{
|
|||||||
Name: "addinvoice",
|
Name: "addinvoice",
|
||||||
Usage: "add a new invoice.",
|
Usage: "add a new invoice.",
|
||||||
Description: "Add a new invoice, expressing intent for a future payment. " +
|
Description: "Add a new invoice, expressing intent for a future payment. " +
|
||||||
"The value of the invoice in satoshis and a 32 byte hash preimage are neccesary for the creation",
|
"The value of the invoice in satoshis is neccesary for the " +
|
||||||
|
"creation, the remaining parameters are optional.",
|
||||||
ArgsUsage: "value preimage",
|
ArgsUsage: "value preimage",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "memo",
|
Name: "memo",
|
||||||
Usage: "an optional memo to attach along with the invoice",
|
Usage: "a description of the payment to attach along " +
|
||||||
|
"with the invoice (default=\"\")",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "receipt",
|
Name: "receipt",
|
||||||
@ -898,12 +900,34 @@ var addInvoiceCommand = cli.Command{
|
|||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "preimage",
|
Name: "preimage",
|
||||||
Usage: "the hex-encoded preimage (32 byte) which will allow settling an incoming HTLC payable to this preimage",
|
Usage: "the hex-encoded preimage (32 byte) which will " +
|
||||||
|
"allow settling an incoming HTLC payable to this " +
|
||||||
|
"preimage. If not set, a random preimage will be " +
|
||||||
|
"created.",
|
||||||
},
|
},
|
||||||
cli.Int64Flag{
|
cli.Int64Flag{
|
||||||
Name: "value",
|
Name: "value",
|
||||||
Usage: "the value of this invoice in satoshis",
|
Usage: "the value of this invoice in satoshis",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "description_hash",
|
||||||
|
Usage: "SHA-256 hash of the description of the payment. " +
|
||||||
|
"Used if the purpose of payment cannot naturally " +
|
||||||
|
"fit within the memo. If provided this will be " +
|
||||||
|
"used instead of the description(memo) field in " +
|
||||||
|
"the encoded invoice.",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "fallback_addr",
|
||||||
|
Usage: "fallback on-chain address that can be used in " +
|
||||||
|
"case the lightning payment fails",
|
||||||
|
},
|
||||||
|
cli.Int64Flag{
|
||||||
|
Name: "expiry",
|
||||||
|
Usage: "the invoice's expiry time in seconds. If not " +
|
||||||
|
"specified an expiry of 3600 seconds (1 hour) " +
|
||||||
|
"is implied.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: addInvoice,
|
Action: addInvoice,
|
||||||
}
|
}
|
||||||
@ -911,6 +935,7 @@ var addInvoiceCommand = cli.Command{
|
|||||||
func addInvoice(ctx *cli.Context) error {
|
func addInvoice(ctx *cli.Context) error {
|
||||||
var (
|
var (
|
||||||
preimage []byte
|
preimage []byte
|
||||||
|
descHash []byte
|
||||||
receipt []byte
|
receipt []byte
|
||||||
value int64
|
value int64
|
||||||
err error
|
err error
|
||||||
@ -945,6 +970,11 @@ func addInvoice(ctx *cli.Context) error {
|
|||||||
return fmt.Errorf("unable to parse preimage: %v", err)
|
return fmt.Errorf("unable to parse preimage: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
descHash, err = hex.DecodeString(ctx.String("description_hash"))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to parse description_hash: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
receipt, err = hex.DecodeString(ctx.String("receipt"))
|
receipt, err = hex.DecodeString(ctx.String("receipt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to parse receipt: %v", err)
|
return fmt.Errorf("unable to parse receipt: %v", err)
|
||||||
@ -955,6 +985,9 @@ func addInvoice(ctx *cli.Context) error {
|
|||||||
Receipt: receipt,
|
Receipt: receipt,
|
||||||
RPreimage: preimage,
|
RPreimage: preimage,
|
||||||
Value: value,
|
Value: value,
|
||||||
|
DescriptionHash: descHash,
|
||||||
|
FallbackAddr: ctx.String("fallback_addr"),
|
||||||
|
Expiry: ctx.Int64("expiry"),
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.AddInvoice(context.Background(), invoice)
|
resp, err := client.AddInvoice(context.Background(), invoice)
|
||||||
@ -1490,7 +1523,7 @@ var decodePayReqComamnd = cli.Command{
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "pay_req",
|
Name: "pay_req",
|
||||||
Usage: "the zpay32 encoded payment request",
|
Usage: "the bech32 encoded payment request",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: decodePayReq,
|
Action: decodePayReq,
|
||||||
|
Loading…
Reference in New Issue
Block a user