From 850dee37ee9ff733a70b68f6f0370cca55259653 Mon Sep 17 00:00:00 2001 From: ErikEk Date: Sat, 17 Jul 2021 02:33:00 +0200 Subject: [PATCH] invoices: return payment address from addholdinvoice --- cmd/lncli/invoicesrpc_active.go | 6 +--- docs/release-notes/release-notes-0.14.0.md | 5 ++++ lnrpc/invoicesrpc/invoices.pb.go | 35 ++++++++++++++++++++-- lnrpc/invoicesrpc/invoices.proto | 17 ++++++++++- lnrpc/invoicesrpc/invoices.swagger.json | 12 +++++++- lnrpc/invoicesrpc/invoices_server.go | 2 ++ 6 files changed, 67 insertions(+), 10 deletions(-) diff --git a/cmd/lncli/invoicesrpc_active.go b/cmd/lncli/invoicesrpc_active.go index f4b4bd61f2..7678fa0357 100644 --- a/cmd/lncli/invoicesrpc_active.go +++ b/cmd/lncli/invoicesrpc_active.go @@ -252,11 +252,7 @@ func addHoldInvoice(ctx *cli.Context) error { return err } - printJSON(struct { - PayReq string `json:"pay_req"` - }{ - PayReq: resp.PaymentRequest, - }) + printRespJSON(resp) return nil } diff --git a/docs/release-notes/release-notes-0.14.0.md b/docs/release-notes/release-notes-0.14.0.md index 3504a42da4..6e81667be9 100644 --- a/docs/release-notes/release-notes-0.14.0.md +++ b/docs/release-notes/release-notes-0.14.0.md @@ -1,5 +1,10 @@ # Release Notes +## RPC Server + +[Return payment address and add index from +addholdinvoice call](https://github.com/lightningnetwork/lnd/pull/5533). + # Build System [A new pre-submit check has been diff --git a/lnrpc/invoicesrpc/invoices.pb.go b/lnrpc/invoicesrpc/invoices.pb.go index ca4e16f161..0ef31bc1b3 100644 --- a/lnrpc/invoicesrpc/invoices.pb.go +++ b/lnrpc/invoicesrpc/invoices.pb.go @@ -266,10 +266,21 @@ type AddHoldInvoiceResp struct { unknownFields protoimpl.UnknownFields // - //A bare-bones invoice for a payment within the Lightning Network. With the + //A bare-bones invoice for a payment within the Lightning Network. With the //details of the invoice, the sender has all the data necessary to send a //payment to the recipient. PaymentRequest string `protobuf:"bytes,1,opt,name=payment_request,json=paymentRequest,proto3" json:"payment_request,omitempty"` + // + //The "add" index of this invoice. Each newly created invoice will increment + //this index making it monotonically increasing. Callers to the + //SubscribeInvoices call can use this to instantly get notified of all added + //invoices with an add_index greater than this one. + AddIndex uint64 `protobuf:"varint,2,opt,name=add_index,json=addIndex,proto3" json:"add_index,omitempty"` + // + //The payment address of the generated invoice. This value should be used + //in all payments for this invoice as we require it for end to end + //security. + PaymentAddr []byte `protobuf:"bytes,3,opt,name=payment_addr,json=paymentAddr,proto3" json:"payment_addr,omitempty"` } func (x *AddHoldInvoiceResp) Reset() { @@ -311,6 +322,20 @@ func (x *AddHoldInvoiceResp) GetPaymentRequest() string { return "" } +func (x *AddHoldInvoiceResp) GetAddIndex() uint64 { + if x != nil { + return x.AddIndex + } + return 0 +} + +func (x *AddHoldInvoiceResp) GetPaymentAddr() []byte { + if x != nil { + return x.PaymentAddr + } + return nil +} + type SettleInvoiceMsg struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -477,11 +502,15 @@ var file_invoicesrpc_invoices_proto_rawDesc = []byte{ 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6c, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x52, 0x0a, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x22, 0x3d, 0x0a, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x22, 0x7d, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x48, 0x6f, 0x6c, 0x64, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x61, - 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2e, 0x0a, 0x10, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x61, 0x64, 0x64, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x61, 0x64, 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0b, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x22, 0x2e, 0x0a, 0x10, 0x53, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x4d, 0x73, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x72, 0x65, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x22, 0x13, 0x0a, 0x11, diff --git a/lnrpc/invoicesrpc/invoices.proto b/lnrpc/invoicesrpc/invoices.proto index df52b8c82f..c8e963e39a 100644 --- a/lnrpc/invoicesrpc/invoices.proto +++ b/lnrpc/invoicesrpc/invoices.proto @@ -98,11 +98,26 @@ message AddHoldInvoiceRequest { message AddHoldInvoiceResp { /* - A bare-bones invoice for a payment within the Lightning Network. With the + A bare-bones invoice for a payment within the Lightning Network. With the details of the invoice, the sender has all the data necessary to send a payment to the recipient. */ string payment_request = 1; + + /* + The "add" index of this invoice. Each newly created invoice will increment + this index making it monotonically increasing. Callers to the + SubscribeInvoices call can use this to instantly get notified of all added + invoices with an add_index greater than this one. + */ + uint64 add_index = 2; + + /* + The payment address of the generated invoice. This value should be used + in all payments for this invoice as we require it for end to end + security. + */ + bytes payment_addr = 3; } message SettleInvoiceMsg { diff --git a/lnrpc/invoicesrpc/invoices.swagger.json b/lnrpc/invoicesrpc/invoices.swagger.json index 02d094e161..4548eed71a 100644 --- a/lnrpc/invoicesrpc/invoices.swagger.json +++ b/lnrpc/invoicesrpc/invoices.swagger.json @@ -226,7 +226,17 @@ "properties": { "payment_request": { "type": "string", - "description": "A bare-bones invoice for a payment within the Lightning Network. With the\ndetails of the invoice, the sender has all the data necessary to send a\npayment to the recipient." + "description": "A bare-bones invoice for a payment within the Lightning Network. With the\ndetails of the invoice, the sender has all the data necessary to send a\npayment to the recipient." + }, + "add_index": { + "type": "string", + "format": "uint64", + "description": "The \"add\" index of this invoice. Each newly created invoice will increment\nthis index making it monotonically increasing. Callers to the\nSubscribeInvoices call can use this to instantly get notified of all added\ninvoices with an add_index greater than this one." + }, + "payment_addr": { + "type": "string", + "format": "byte", + "description": "The payment address of the generated invoice. This value should be used\nin all payments for this invoice as we require it for end to end\nsecurity." } } }, diff --git a/lnrpc/invoicesrpc/invoices_server.go b/lnrpc/invoicesrpc/invoices_server.go index 0db5022c8b..83228a64a1 100644 --- a/lnrpc/invoicesrpc/invoices_server.go +++ b/lnrpc/invoicesrpc/invoices_server.go @@ -354,6 +354,8 @@ func (s *Server) AddHoldInvoice(ctx context.Context, } return &AddHoldInvoiceResp{ + AddIndex: dbInvoice.AddIndex, PaymentRequest: string(dbInvoice.PaymentRequest), + PaymentAddr: dbInvoice.Terms.PaymentAddr[:], }, nil }