cmd/lncli: accept zpay32 requests in sendpayment command

This commit is contained in:
Olaoluwa Osuntokun 2017-01-02 15:38:00 -08:00
parent 5a9be3f812
commit 9b50df704c
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -546,10 +546,9 @@ var SendPaymentCommand = cli.Command{
Name: "debug_send", Name: "debug_send",
Usage: "use the debug rHash when sending the HTLC", Usage: "use the debug rHash when sending the HTLC",
}, },
cli.BoolFlag{ cli.StringFlag{
Name: "fast, f", Name: "pay_req",
Usage: "skip the HTLC trickle logic, immediately creating a " + Usage: "a zbase32-check encoded payment request to fulfill",
"new commitment",
}, },
}, },
Action: sendPaymentCommand, Action: sendPaymentCommand,
@ -558,6 +557,12 @@ var SendPaymentCommand = cli.Command{
func sendPaymentCommand(ctx *cli.Context) error { func sendPaymentCommand(ctx *cli.Context) error {
client := getClient(ctx) client := getClient(ctx)
var req *lnrpc.SendRequest
if ctx.String("pay_req") != "" {
req = &lnrpc.SendRequest{
PaymentRequest: ctx.String("pay_req"),
}
} else {
destNode, err := hex.DecodeString(ctx.String("dest")) destNode, err := hex.DecodeString(ctx.String("dest"))
if err != nil { if err != nil {
return err return err
@ -567,10 +572,9 @@ func sendPaymentCommand(ctx *cli.Context) error {
"instead: %v", len(destNode)) "instead: %v", len(destNode))
} }
req := &lnrpc.SendRequest{ req = &lnrpc.SendRequest{
Dest: destNode, Dest: destNode,
Amt: int64(ctx.Int("amt")), Amt: int64(ctx.Int("amt")),
FastSend: ctx.Bool("fast"),
} }
if !ctx.Bool("debug_send") { if !ctx.Bool("debug_send") {
@ -584,6 +588,7 @@ func sendPaymentCommand(ctx *cli.Context) error {
} }
req.PaymentHash = rHash req.PaymentHash = rHash
} }
}
paymentStream, err := client.SendPayment(context.Background()) paymentStream, err := client.SendPayment(context.Background())
if err != nil { if err != nil {