cmd/lncli: add new --debug_send option to sendpayment

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.
This commit is contained in:
Olaoluwa Osuntokun 2016-09-20 16:14:45 -07:00
parent 7310d0a0f7
commit 89310c8778
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -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())