lnrpc: add the deletecanceledinvoice rpc call

This commit is contained in:
MPins committed 2025-07-25 21:09:18 -03:00
1 parent 6f09d9653f
commit 0146e374fd
7 files changed
+1964 -1616

No files matched your search

+1752 -1616
View File
File diff suppressed because it is too large. Load diff
+87
View File
@@ -1305,6 +1305,42 @@ func request_Lightning_SubscribeInvoices_0(ctx context.Context, marshaler runtim
}
var (
filter_Lightning_DeleteCanceledInvoice_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Lightning_DeleteCanceledInvoice_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DelCanceledInvoiceReq
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Lightning_DeleteCanceledInvoice_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.DeleteCanceledInvoice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Lightning_DeleteCanceledInvoice_0(ctx context.Context, marshaler runtime.Marshaler, server LightningServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DelCanceledInvoiceReq
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Lightning_DeleteCanceledInvoice_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.DeleteCanceledInvoice(ctx, &protoReq)
return msg, metadata, err
}
func request_Lightning_DecodePayReq_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq PayReqString
var metadata runtime.ServerMetadata
@@ -3339,6 +3375,31 @@ func RegisterLightningHandlerServer(ctx context.Context, mux *runtime.ServeMux,
return
})
mux.Handle("DELETE", pattern_Lightning_DeleteCanceledInvoice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/lnrpc.Lightning/DeleteCanceledInvoice", runtime.WithHTTPPathPattern("/v1/invoices"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Lightning_DeleteCanceledInvoice_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Lightning_DeleteCanceledInvoice_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_DecodePayReq_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -4900,6 +4961,28 @@ func RegisterLightningHandlerClient(ctx context.Context, mux *runtime.ServeMux,
})
mux.Handle("DELETE", pattern_Lightning_DeleteCanceledInvoice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/lnrpc.Lightning/DeleteCanceledInvoice", runtime.WithHTTPPathPattern("/v1/invoices"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Lightning_DeleteCanceledInvoice_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Lightning_DeleteCanceledInvoice_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_DecodePayReq_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -5680,6 +5763,8 @@ var (
pattern_Lightning_SubscribeInvoices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "invoices", "subscribe"}, ""))
pattern_Lightning_DeleteCanceledInvoice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "invoices"}, ""))
pattern_Lightning_DecodePayReq_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "payreq", "pay_req"}, ""))
pattern_Lightning_ListPayments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "payments"}, ""))
@@ -5818,6 +5903,8 @@ var (
forward_Lightning_SubscribeInvoices_0 = runtime.ForwardResponseStream
forward_Lightning_DeleteCanceledInvoice_0 = runtime.ForwardResponseMessage
forward_Lightning_DecodePayReq_0 = runtime.ForwardResponseMessage
forward_Lightning_ListPayments_0 = runtime.ForwardResponseMessage
+25
View File
@@ -973,6 +973,31 @@ func RegisterLightningJSONCallbacks(registry map[string]func(ctx context.Context
}()
}
registry["lnrpc.Lightning.DeleteCanceledInvoice"] = func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
req := &DelCanceledInvoiceReq{}
err := marshaler.Unmarshal([]byte(reqJSON), req)
if err != nil {
callback("", err)
return
}
client := NewLightningClient(conn)
resp, err := client.DeleteCanceledInvoice(ctx, req)
if err != nil {
callback("", err)
return
}
respBytes, err := marshaler.Marshal(resp)
if err != nil {
callback("", err)
return
}
callback(string(respBytes), nil)
}
registry["lnrpc.Lightning.DecodePayReq"] = func(ctx context.Context,
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
+17
View File
@@ -341,6 +341,13 @@ service Lightning {
*/
rpc SubscribeInvoices (InvoiceSubscription) returns (stream Invoice);
/* lncli: `deletecanceledinvoice`
DeleteCanceledInvoice removes a canceled invoice from the database. If the
invoice is not in the canceled state, an error will be returned.
*/
rpc DeleteCanceledInvoice (DelCanceledInvoiceReq)
returns (DelCanceledInvoiceResp);
/* lncli: `decodepayreq`
DecodePayReq takes an encoded payment request string and attempts to decode
it, returning a full description of the conditions encoded within the
@@ -4234,6 +4241,16 @@ message InvoiceSubscription {
uint64 settle_index = 2;
}
message DelCanceledInvoiceReq {
// Invoice payment hash to delete.
string invoice_hash = 1;
}
message DelCanceledInvoiceResp {
// The status of the delete operation.
string status = 1;
}
enum PaymentFailureReason {
/*
Payment isn't failed (yet).
+39
View File
@@ -1874,6 +1874,36 @@
"Lightning"
]
},
"delete": {
"summary": "lncli: `deletecanceledinvoice`\nDeleteCanceledInvoice removes a canceled invoice from the database. If the\ninvoice is not in the canceled state, an error will be returned.",
"operationId": "Lightning_DeleteCanceledInvoice",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/lnrpcDelCanceledInvoiceResp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "invoice_hash",
"description": "Invoice payment hash to delete.",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"Lightning"
]
},
"post": {
"summary": "lncli: `addinvoice`\nAddInvoice attempts to add a new invoice to the invoice database. Any\nduplicated invoices are rejected, therefore all invoices *must* have a\nunique payment preimage.",
"operationId": "Lightning_AddInvoice",
@@ -4857,6 +4887,15 @@
}
}
},
"lnrpcDelCanceledInvoiceResp": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "The status of the delete operation."
}
}
},
"lnrpcDeleteAllPaymentsResponse": {
"type": "object",
"properties": {
+2
View File
@@ -95,6 +95,8 @@ http:
get: "/v1/invoice/{r_hash_str}"
- selector: lnrpc.Lightning.SubscribeInvoices
get: "/v1/invoices/subscribe"
- selector: lnrpc.Lightning.DeleteCanceledInvoice
delete: "/v1/invoices"
- selector: lnrpc.Lightning.DecodePayReq
get: "/v1/payreq/{pay_req}"
- selector: lnrpc.Lightning.DeletePayment
+42
View File
@@ -243,6 +243,10 @@ type LightningClient interface {
// of these fields can be set. If no fields are set, then we'll only send out
// the latest add/settle events.
SubscribeInvoices(ctx context.Context, in *InvoiceSubscription, opts ...grpc.CallOption) (Lightning_SubscribeInvoicesClient, error)
// lncli: `deletecanceledinvoice`
// DeleteCanceledInvoice removes a canceled invoice from the database. If the
// invoice is not in the canceled state, an error will be returned.
DeleteCanceledInvoice(ctx context.Context, in *DelCanceledInvoiceReq, opts ...grpc.CallOption) (*DelCanceledInvoiceResp, error)
// lncli: `decodepayreq`
// DecodePayReq takes an encoded payment request string and attempts to decode
// it, returning a full description of the conditions encoded within the
@@ -973,6 +977,15 @@ func (x *lightningSubscribeInvoicesClient) Recv() (*Invoice, error) {
return m, nil
}
func (c *lightningClient) DeleteCanceledInvoice(ctx context.Context, in *DelCanceledInvoiceReq, opts ...grpc.CallOption) (*DelCanceledInvoiceResp, error) {
out := new(DelCanceledInvoiceResp)
err := c.cc.Invoke(ctx, "/lnrpc.Lightning/DeleteCanceledInvoice", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *lightningClient) DecodePayReq(ctx context.Context, in *PayReqString, opts ...grpc.CallOption) (*PayReq, error) {
out := new(PayReq)
err := c.cc.Invoke(ctx, "/lnrpc.Lightning/DecodePayReq", in, out, opts...)
@@ -1572,6 +1585,10 @@ type LightningServer interface {
// of these fields can be set. If no fields are set, then we'll only send out
// the latest add/settle events.
SubscribeInvoices(*InvoiceSubscription, Lightning_SubscribeInvoicesServer) error
// lncli: `deletecanceledinvoice`
// DeleteCanceledInvoice removes a canceled invoice from the database. If the
// invoice is not in the canceled state, an error will be returned.
DeleteCanceledInvoice(context.Context, *DelCanceledInvoiceReq) (*DelCanceledInvoiceResp, error)
// lncli: `decodepayreq`
// DecodePayReq takes an encoded payment request string and attempts to decode
// it, returning a full description of the conditions encoded within the
@@ -1869,6 +1886,9 @@ func (UnimplementedLightningServer) LookupInvoice(context.Context, *PaymentHash)
func (UnimplementedLightningServer) SubscribeInvoices(*InvoiceSubscription, Lightning_SubscribeInvoicesServer) error {
return status.Errorf(codes.Unimplemented, "method SubscribeInvoices not implemented")
}
func (UnimplementedLightningServer) DeleteCanceledInvoice(context.Context, *DelCanceledInvoiceReq) (*DelCanceledInvoiceResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteCanceledInvoice not implemented")
}
func (UnimplementedLightningServer) DecodePayReq(context.Context, *PayReqString) (*PayReq, error) {
return nil, status.Errorf(codes.Unimplemented, "method DecodePayReq not implemented")
}
@@ -2683,6 +2703,24 @@ func (x *lightningSubscribeInvoicesServer) Send(m *Invoice) error {
return x.ServerStream.SendMsg(m)
}
func _Lightning_DeleteCanceledInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DelCanceledInvoiceReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LightningServer).DeleteCanceledInvoice(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/lnrpc.Lightning/DeleteCanceledInvoice",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LightningServer).DeleteCanceledInvoice(ctx, req.(*DelCanceledInvoiceReq))
}
return interceptor(ctx, in, info, handler)
}
func _Lightning_DecodePayReq_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PayReqString)
if err := dec(in); err != nil {
@@ -3377,6 +3415,10 @@ var Lightning_ServiceDesc = grpc.ServiceDesc{
MethodName: "LookupInvoice",
Handler: _Lightning_LookupInvoice_Handler,
},
{
MethodName: "DeleteCanceledInvoice",
Handler: _Lightning_DeleteCanceledInvoice_Handler,
},
{
MethodName: "DecodePayReq",
Handler: _Lightning_DecodePayReq_Handler,