parent
a13ad0a339
commit
0e07699550
@ -834,16 +834,13 @@ var sendPaymentCommand = cli.Command{
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "pay_req",
|
||||
Usage: "a bech32 encoded payment request to fulfill",
|
||||
Usage: "a zpay32 encoded payment request to fulfill",
|
||||
},
|
||||
},
|
||||
Action: sendPayment,
|
||||
}
|
||||
|
||||
func sendPayment(ctx *cli.Context) error {
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
// Show command help if no arguments provieded
|
||||
if ctx.NArg() == 0 && ctx.NumFlags() == 0 {
|
||||
cli.ShowCommandHelp(ctx, "sendpayment")
|
||||
@ -922,6 +919,13 @@ func sendPayment(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
return sendPaymentRequest(ctx, req)
|
||||
}
|
||||
|
||||
func sendPaymentRequest(ctx *cli.Context, req *lnrpc.SendRequest) error {
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
paymentStream, err := client.SendPayment(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
@ -951,6 +955,40 @@ func sendPayment(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var payInvoiceCommand = cli.Command{
|
||||
Name: "payinvoice",
|
||||
Usage: "pay an invoice over lightning",
|
||||
ArgsUsage: "pay_req",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "pay_req",
|
||||
Usage: "a zpay32 encoded payment request to fulfill",
|
||||
},
|
||||
},
|
||||
Action: payInvoice,
|
||||
}
|
||||
|
||||
func payInvoice(ctx *cli.Context) error {
|
||||
args := ctx.Args()
|
||||
|
||||
var payReq string
|
||||
|
||||
switch {
|
||||
case ctx.IsSet("pay_req"):
|
||||
payReq = ctx.String("pay_req")
|
||||
case args.Present():
|
||||
payReq = args.First()
|
||||
default:
|
||||
return fmt.Errorf("pay_req argument missing")
|
||||
}
|
||||
|
||||
req := &lnrpc.SendRequest{
|
||||
PaymentRequest: payReq,
|
||||
}
|
||||
|
||||
return sendPaymentRequest(ctx, req)
|
||||
}
|
||||
|
||||
var addInvoiceCommand = cli.Command{
|
||||
Name: "addinvoice",
|
||||
Usage: "add a new invoice.",
|
||||
|
@ -171,6 +171,7 @@ func main() {
|
||||
getInfoCommand,
|
||||
pendingChannelsCommand,
|
||||
sendPaymentCommand,
|
||||
payInvoiceCommand,
|
||||
addInvoiceCommand,
|
||||
lookupInvoiceCommand,
|
||||
listInvoicesCommand,
|
||||
|
Loading…
Reference in New Issue
Block a user