invoicesrpc: add SettleInvoice

This commit is contained in:
Joost Jager 2019-02-11 12:02:39 +01:00
parent 0823c79e4e
commit f450929b65
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
3 changed files with 187 additions and 39 deletions

@ -26,7 +26,7 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type CancelInvoiceMsg struct {
// / Hash corresponding to the invoice to cancel.
// / Hash corresponding to the (hold) invoice to cancel.
PaymentHash []byte `protobuf:"bytes,1,opt,name=payment_hash,json=paymentHash,proto3" json:"payment_hash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -37,7 +37,7 @@ func (m *CancelInvoiceMsg) Reset() { *m = CancelInvoiceMsg{} }
func (m *CancelInvoiceMsg) String() string { return proto.CompactTextString(m) }
func (*CancelInvoiceMsg) ProtoMessage() {}
func (*CancelInvoiceMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_invoices_1388f29ea95fbe6f, []int{0}
return fileDescriptor_invoices_faecc7e411e82f9d, []int{0}
}
func (m *CancelInvoiceMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelInvoiceMsg.Unmarshal(m, b)
@ -74,7 +74,7 @@ func (m *CancelInvoiceResp) Reset() { *m = CancelInvoiceResp{} }
func (m *CancelInvoiceResp) String() string { return proto.CompactTextString(m) }
func (*CancelInvoiceResp) ProtoMessage() {}
func (*CancelInvoiceResp) Descriptor() ([]byte, []int) {
return fileDescriptor_invoices_1388f29ea95fbe6f, []int{1}
return fileDescriptor_invoices_faecc7e411e82f9d, []int{1}
}
func (m *CancelInvoiceResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelInvoiceResp.Unmarshal(m, b)
@ -131,7 +131,7 @@ func (m *AddHoldInvoiceRequest) Reset() { *m = AddHoldInvoiceRequest{} }
func (m *AddHoldInvoiceRequest) String() string { return proto.CompactTextString(m) }
func (*AddHoldInvoiceRequest) ProtoMessage() {}
func (*AddHoldInvoiceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_invoices_1388f29ea95fbe6f, []int{2}
return fileDescriptor_invoices_faecc7e411e82f9d, []int{2}
}
func (m *AddHoldInvoiceRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AddHoldInvoiceRequest.Unmarshal(m, b)
@ -229,7 +229,7 @@ func (m *AddHoldInvoiceResp) Reset() { *m = AddHoldInvoiceResp{} }
func (m *AddHoldInvoiceResp) String() string { return proto.CompactTextString(m) }
func (*AddHoldInvoiceResp) ProtoMessage() {}
func (*AddHoldInvoiceResp) Descriptor() ([]byte, []int) {
return fileDescriptor_invoices_1388f29ea95fbe6f, []int{3}
return fileDescriptor_invoices_faecc7e411e82f9d, []int{3}
}
func (m *AddHoldInvoiceResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AddHoldInvoiceResp.Unmarshal(m, b)
@ -256,11 +256,82 @@ func (m *AddHoldInvoiceResp) GetPaymentRequest() string {
return ""
}
type SettleInvoiceMsg struct {
// / Externally discovered pre-image that should be used to settle the hold invoice.
Preimage []byte `protobuf:"bytes,1,opt,name=preimage,proto3" json:"preimage,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SettleInvoiceMsg) Reset() { *m = SettleInvoiceMsg{} }
func (m *SettleInvoiceMsg) String() string { return proto.CompactTextString(m) }
func (*SettleInvoiceMsg) ProtoMessage() {}
func (*SettleInvoiceMsg) Descriptor() ([]byte, []int) {
return fileDescriptor_invoices_faecc7e411e82f9d, []int{4}
}
func (m *SettleInvoiceMsg) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SettleInvoiceMsg.Unmarshal(m, b)
}
func (m *SettleInvoiceMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SettleInvoiceMsg.Marshal(b, m, deterministic)
}
func (dst *SettleInvoiceMsg) XXX_Merge(src proto.Message) {
xxx_messageInfo_SettleInvoiceMsg.Merge(dst, src)
}
func (m *SettleInvoiceMsg) XXX_Size() int {
return xxx_messageInfo_SettleInvoiceMsg.Size(m)
}
func (m *SettleInvoiceMsg) XXX_DiscardUnknown() {
xxx_messageInfo_SettleInvoiceMsg.DiscardUnknown(m)
}
var xxx_messageInfo_SettleInvoiceMsg proto.InternalMessageInfo
func (m *SettleInvoiceMsg) GetPreimage() []byte {
if m != nil {
return m.Preimage
}
return nil
}
type SettleInvoiceResp struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SettleInvoiceResp) Reset() { *m = SettleInvoiceResp{} }
func (m *SettleInvoiceResp) String() string { return proto.CompactTextString(m) }
func (*SettleInvoiceResp) ProtoMessage() {}
func (*SettleInvoiceResp) Descriptor() ([]byte, []int) {
return fileDescriptor_invoices_faecc7e411e82f9d, []int{5}
}
func (m *SettleInvoiceResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SettleInvoiceResp.Unmarshal(m, b)
}
func (m *SettleInvoiceResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SettleInvoiceResp.Marshal(b, m, deterministic)
}
func (dst *SettleInvoiceResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_SettleInvoiceResp.Merge(dst, src)
}
func (m *SettleInvoiceResp) XXX_Size() int {
return xxx_messageInfo_SettleInvoiceResp.Size(m)
}
func (m *SettleInvoiceResp) XXX_DiscardUnknown() {
xxx_messageInfo_SettleInvoiceResp.DiscardUnknown(m)
}
var xxx_messageInfo_SettleInvoiceResp proto.InternalMessageInfo
func init() {
proto.RegisterType((*CancelInvoiceMsg)(nil), "invoicesrpc.CancelInvoiceMsg")
proto.RegisterType((*CancelInvoiceResp)(nil), "invoicesrpc.CancelInvoiceResp")
proto.RegisterType((*AddHoldInvoiceRequest)(nil), "invoicesrpc.AddHoldInvoiceRequest")
proto.RegisterType((*AddHoldInvoiceResp)(nil), "invoicesrpc.AddHoldInvoiceResp")
proto.RegisterType((*SettleInvoiceMsg)(nil), "invoicesrpc.SettleInvoiceMsg")
proto.RegisterType((*SettleInvoiceResp)(nil), "invoicesrpc.SettleInvoiceResp")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -289,6 +360,10 @@ type InvoicesClient interface {
// AddHoldInvoice creates a hold invoice. It ties the invoice to the hash
// supplied in the request.
AddHoldInvoice(ctx context.Context, in *AddHoldInvoiceRequest, opts ...grpc.CallOption) (*AddHoldInvoiceResp, error)
// *
// SettleInvoice settles an accepted invoice. If the invoice is already
// settled, this call will succeed.
SettleInvoice(ctx context.Context, in *SettleInvoiceMsg, opts ...grpc.CallOption) (*SettleInvoiceResp, error)
}
type invoicesClient struct {
@ -349,6 +424,15 @@ func (c *invoicesClient) AddHoldInvoice(ctx context.Context, in *AddHoldInvoiceR
return out, nil
}
func (c *invoicesClient) SettleInvoice(ctx context.Context, in *SettleInvoiceMsg, opts ...grpc.CallOption) (*SettleInvoiceResp, error) {
out := new(SettleInvoiceResp)
err := c.cc.Invoke(ctx, "/invoicesrpc.Invoices/SettleInvoice", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// InvoicesServer is the server API for Invoices service.
type InvoicesServer interface {
// *
@ -365,6 +449,10 @@ type InvoicesServer interface {
// AddHoldInvoice creates a hold invoice. It ties the invoice to the hash
// supplied in the request.
AddHoldInvoice(context.Context, *AddHoldInvoiceRequest) (*AddHoldInvoiceResp, error)
// *
// SettleInvoice settles an accepted invoice. If the invoice is already
// settled, this call will succeed.
SettleInvoice(context.Context, *SettleInvoiceMsg) (*SettleInvoiceResp, error)
}
func RegisterInvoicesServer(s *grpc.Server, srv InvoicesServer) {
@ -428,6 +516,24 @@ func _Invoices_AddHoldInvoice_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _Invoices_SettleInvoice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SettleInvoiceMsg)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(InvoicesServer).SettleInvoice(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/invoicesrpc.Invoices/SettleInvoice",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(InvoicesServer).SettleInvoice(ctx, req.(*SettleInvoiceMsg))
}
return interceptor(ctx, in, info, handler)
}
var _Invoices_serviceDesc = grpc.ServiceDesc{
ServiceName: "invoicesrpc.Invoices",
HandlerType: (*InvoicesServer)(nil),
@ -440,6 +546,10 @@ var _Invoices_serviceDesc = grpc.ServiceDesc{
MethodName: "AddHoldInvoice",
Handler: _Invoices_AddHoldInvoice_Handler,
},
{
MethodName: "SettleInvoice",
Handler: _Invoices_SettleInvoice_Handler,
},
},
Streams: []grpc.StreamDesc{
{
@ -452,38 +562,40 @@ var _Invoices_serviceDesc = grpc.ServiceDesc{
}
func init() {
proto.RegisterFile("invoicesrpc/invoices.proto", fileDescriptor_invoices_1388f29ea95fbe6f)
proto.RegisterFile("invoicesrpc/invoices.proto", fileDescriptor_invoices_faecc7e411e82f9d)
}
var fileDescriptor_invoices_1388f29ea95fbe6f = []byte{
// 450 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0x4f, 0x8f, 0xd3, 0x3e,
0x10, 0x55, 0xb6, 0xdd, 0x6e, 0xeb, 0xec, 0xee, 0xaf, 0xbf, 0x01, 0x56, 0x51, 0xc4, 0x9f, 0x10,
0x71, 0x88, 0x38, 0x24, 0xd0, 0x15, 0xd7, 0x95, 0x80, 0x4b, 0x39, 0x80, 0x50, 0x56, 0x5c, 0xb8,
0x54, 0x4e, 0x62, 0x12, 0x6b, 0x5d, 0xdb, 0xd8, 0x4e, 0x61, 0x3f, 0x15, 0x9f, 0x8d, 0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9d, 0x62,
0x66, 0xbf, 0xfd, 0xf2, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0x12, 0x25, 0x68, 0x92, 0x41, 0x03,
0x00, 0x00,
var fileDescriptor_invoices_faecc7e411e82f9d = []byte{
// 490 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0x4f, 0x8f, 0xd3, 0x3c,
0x10, 0xc6, 0x95, 0xb6, 0xdb, 0x6d, 0xa7, 0xbb, 0xfb, 0xf6, 0x35, 0xb0, 0x8a, 0x22, 0xfe, 0x84,
0x88, 0x43, 0xc4, 0x21, 0x81, 0xae, 0xb8, 0xae, 0x04, 0x5c, 0xca, 0x01, 0x84, 0x52, 0x71, 0xe1,
0x52, 0xb9, 0x89, 0x49, 0xac, 0x75, 0x6d, 0x63, 0xbb, 0x85, 0xfd, 0x54, 0x7c, 0x06, 0xbe, 0x19,
0x8a, 0xe3, 0x96, 0x24, 0x0b, 0xdc, 0x66, 0x1e, 0xcf, 0x3c, 0x19, 0xff, 0x3c, 0x81, 0x80, 0xf2,
0xbd, 0xa0, 0x39, 0xd1, 0x4a, 0xe6, 0xe9, 0x21, 0x4e, 0xa4, 0x12, 0x46, 0xa0, 0x59, 0xeb, 0x2c,
0x78, 0x58, 0x0a, 0x51, 0x32, 0x92, 0x62, 0x49, 0x53, 0xcc, 0xb9, 0x30, 0xd8, 0x50, 0xc1, 0x5d,
0x69, 0x30, 0x55, 0x32, 0x6f, 0xc2, 0xe8, 0x15, 0xcc, 0xdf, 0x62, 0x9e, 0x13, 0xf6, 0xae, 0xe9,
0x7e, 0xaf, 0x4b, 0xf4, 0x14, 0xce, 0x24, 0xbe, 0xdd, 0x12, 0x6e, 0xd6, 0x15, 0xd6, 0x95, 0xef,
0x85, 0x5e, 0x7c, 0x96, 0xcd, 0x9c, 0xb6, 0xc4, 0xba, 0x8a, 0xee, 0xc1, 0xff, 0x9d,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0, 0x2d, 0x2e, 0x89, 0x7b, 0xb9, 0x63, 0x5e, 0x3f,
0x5b, 0xa7, 0xbe, 0xfe, 0xdc, 0xe2, 0xe7, 0x00, 0x26, 0x2e, 0xd7, 0xe8, 0x1a, 0x2e, 0x57, 0xbb,
0x4d, 0x0d, 0x75, 0x43, 0x56, 0x94, 0x97, 0xc7, 0x52, 0x84, 0xdc, 0x25, 0x3f, 0xfe, 0x5e, 0x83,
0xe0, 0xc2, 0x69, 0xae, 0xe6, 0x85, 0x87, 0x3e, 0xc0, 0x79, 0x67, 0x31, 0xd0, 0xa3, 0xa4, 0xb5,
0x97, 0x49, 0x7f, 0xd7, 0x82, 0xc7, 0x7f, 0x3f, 0xb6, 0x2c, 0x3e, 0xc1, 0x45, 0x97, 0x10, 0x8a,
0x3a, 0x1d, 0x7f, 0xdc, 0xb7, 0xe0, 0xc9, 0x3f, 0x6b, 0xb4, 0xac, 0xc7, 0xec, 0x80, 0xe8, 0x8d,
0xd9, 0x87, 0xda, 0x1b, 0xf3, 0x0e, 0xc3, 0x37, 0x57, 0x9f, 0x5f, 0x96, 0xd4, 0x54, 0xbb, 0x4d,
0x92, 0x8b, 0x6d, 0xca, 0x68, 0x59, 0x19, 0x4e, 0x79, 0xc9, 0x89, 0xf9, 0x26, 0xd4, 0x4d, 0xca,
0x78, 0x91, 0x5a, 0x52, 0x69, 0xcb, 0x66, 0x33, 0xb6, 0xbf, 0xe0, 0xd5, 0xaf, 0x00, 0x00, 0x00,
0xff, 0xff, 0x89, 0x60, 0x5e, 0x11, 0xd6, 0x03, 0x00, 0x00,
}

@ -29,10 +29,16 @@ service Invoices {
supplied in the request.
*/
rpc AddHoldInvoice(AddHoldInvoiceRequest) returns (AddHoldInvoiceResp);
/**
SettleInvoice settles an accepted invoice. If the invoice is already
settled, this call will succeed.
*/
rpc SettleInvoice(SettleInvoiceMsg) returns (SettleInvoiceResp);
}
message CancelInvoiceMsg {
/// Hash corresponding to the invoice to cancel.
/// Hash corresponding to the (hold) invoice to cancel.
bytes payment_hash = 1;
}
message CancelInvoiceResp {}
@ -86,3 +92,10 @@ message AddHoldInvoiceResp {
*/
string payment_request = 1 [json_name = "payment_request"];
}
message SettleInvoiceMsg {
/// Externally discovered pre-image that should be used to settle the hold invoice.
bytes preimage = 1;
}
message SettleInvoiceResp {}

@ -12,6 +12,7 @@ import (
"gopkg.in/macaroon-bakery.v2/bakery"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntypes"
)
@ -44,6 +45,10 @@ var (
Entity: "invoices",
Action: "read",
}},
"/invoicesrpc.Invoices/SettleInvoice": {{
Entity: "invoices",
Action: "write",
}},
"/invoicesrpc.Invoices/CancelInvoice": {{
Entity: "invoices",
Action: "write",
@ -196,6 +201,24 @@ func (s *Server) SubscribeSingleInvoice(req *lnrpc.PaymentHash,
}
}
// SettleInvoice settles an accepted invoice. If the invoice is already settled,
// this call will succeed.
func (s *Server) SettleInvoice(ctx context.Context,
in *SettleInvoiceMsg) (*SettleInvoiceResp, error) {
preimage, err := lntypes.MakePreimage(in.Preimage)
if err != nil {
return nil, err
}
err = s.cfg.InvoiceRegistry.SettleHodlInvoice(preimage)
if err != nil && err != channeldb.ErrInvoiceAlreadySettled {
return nil, err
}
return &SettleInvoiceResp{}, nil
}
// CancelInvoice cancels a currently open invoice. If the invoice is already
// canceled, this call will succeed. If the invoice is already settled, it will
// fail.