From 89310c87787227745a73cdc441beaafc9a63f225 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 20 Sep 2016 16:14:45 -0700 Subject: [PATCH] cmd/lncli: add new --debug_send option to sendpayment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new option to the send payment command. The new option toggles usage of the debug HTLC R-Hash when sending the described payment. This flag should be used in conjunction with lnd nodes that have been started with the `—debughtlc` flag in order to allow sending payments without first registering invoices. --- cmd/lncli/commands.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 93c62a3e..2de0abab 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -526,6 +526,10 @@ var SendPaymentCommand = cli.Command{ Name: "payment_hash, r", Usage: "the hash to use within the payment's HTLC", }, + cli.BoolFlag{ + Name: "debug_send", + Usage: "use the debug rHash when sending the HTLC", + }, cli.BoolFlag{ Name: "fast, f", Usage: "skip the HTLC trickle logic, immediately creating a " + @@ -553,10 +557,21 @@ func sendPaymentCommand(ctx *cli.Context) error { } req := &lnrpc.SendRequest{ - Dest: destAddr, - Amt: int64(ctx.Int("amt")), - PaymentHash: rHash[:], - FastSend: ctx.Bool("fast"), + Dest: destNode, + Amt: int64(ctx.Int("amt")), + FastSend: ctx.Bool("fast"), + } + + if !ctx.Bool("debug_send") { + rHash, err := hex.DecodeString(ctx.String("payment_hash")) + if err != nil { + return err + } + if len(rHash) != 32 { + return fmt.Errorf("payment hash must be exactly 32 "+ + "bytes, is instead %v", len(rHash)) + } + req.PaymentHash = rHash } paymentStream, err := client.SendPayment(context.Background())