Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"sync"
"syscall"

"github.com/lightningnetwork/lnd/lnrpc/routerrpc"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/golang/protobuf/jsonpb"
Expand Down Expand Up @@ -2341,8 +2343,11 @@ var payInvoiceCommand = cli.Command{

func payInvoice(ctx *cli.Context) error {
args := ctx.Args()
client, cleanUp := getClient(ctx)
defer cleanUp()

conn := getClientConn(ctx, false)
defer conn.Close()

client := routerrpc.NewRouterClient(conn)

var payReq string
switch {
Expand All @@ -2359,12 +2364,12 @@ func payInvoice(ctx *cli.Context) error {
return err
}

if !ctx.Bool("force") {
err = confirmPayReq(ctx, client, payReq)
if err != nil {
return err
}
}
// if !ctx.Bool("force") {
// err = confirmPayReq(ctx, client, payReq)
// if err != nil {
// return err
// }
// }

req := &lnrpc.SendRequest{
PaymentRequest: payReq,
Expand All @@ -2373,8 +2378,28 @@ func payInvoice(ctx *cli.Context) error {
OutgoingChanId: ctx.Uint64("outgoing_chan_id"),
CltvLimit: uint32(ctx.Int(cltvLimitFlag.Name)),
}
resp, err := client.SendPayment(context.Background(), req)
if err != nil {
return err
}

return sendPaymentRequest(client, req)
printJSON(struct {
E string `json:"payment_error"`
P string `json:"payment_preimage"`
R *lnrpc.Route `json:"payment_route"`
}{
E: resp.PaymentErr,
P: hex.EncodeToString(resp.PreImage),
})

// If we get a payment error back, we pass an error
// up to main which eventually calls fatal() and returns
// with a non-zero exit code.
if resp.PaymentErr != "" {
return errors.New(resp.PaymentErr)
}

return nil
}

var sendToRouteCommand = cli.Command{
Expand Down
7 changes: 0 additions & 7 deletions lnrpc/routerrpc/config_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package routerrpc

import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/routing"
)
Expand All @@ -23,12 +22,6 @@ type Config struct {
// server will find the macaroon named DefaultRouterMacFilename.
NetworkDir string

// ActiveNetParams are the network parameters of the primary network
// that the route is operating on. This is necessary so we can ensure
// that we receive payment requests that send to destinations on our
// network.
ActiveNetParams *chaincfg.Params

// MacService is the main macaroon service that we'll use to handle
// authentication for the Router rpc server.
MacService *macaroons.Service
Expand Down
167 changes: 36 additions & 131 deletions lnrpc/routerrpc/router.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading