diff --git a/swapserverrpc/reservation.pb.go b/swapserverrpc/reservation.pb.go new file mode 100644 index 0000000..7097970 --- /dev/null +++ b/swapserverrpc/reservation.pb.go @@ -0,0 +1,468 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc v3.6.1 +// source: reservation.proto + +// We can't change this to swapserverrpc, it would be a breaking change because +// the package name is also contained in the HTTP URIs and old clients would +// call the wrong endpoints. Luckily with the go_package option we can have +// different golang and RPC package names to fix protobuf namespace conflicts. + +package swapserverrpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ReservationProtocolVersion is the version of the reservation protocol. +type ReservationProtocolVersion int32 + +const ( + // RESERVATION_NONE is the default value and means that the reservation + // protocol version is not set. + ReservationProtocolVersion_RESERVATION_NONE ReservationProtocolVersion = 0 + // RESERVATION_SERVER_REQUEST is the first version of the reservation + // protocol where the server notifies the client about a reservation. + ReservationProtocolVersion_RESERVATION_SERVER_NOTIFY ReservationProtocolVersion = 1 +) + +// Enum value maps for ReservationProtocolVersion. +var ( + ReservationProtocolVersion_name = map[int32]string{ + 0: "RESERVATION_NONE", + 1: "RESERVATION_SERVER_NOTIFY", + } + ReservationProtocolVersion_value = map[string]int32{ + "RESERVATION_NONE": 0, + "RESERVATION_SERVER_NOTIFY": 1, + } +) + +func (x ReservationProtocolVersion) Enum() *ReservationProtocolVersion { + p := new(ReservationProtocolVersion) + *p = x + return p +} + +func (x ReservationProtocolVersion) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ReservationProtocolVersion) Descriptor() protoreflect.EnumDescriptor { + return file_reservation_proto_enumTypes[0].Descriptor() +} + +func (ReservationProtocolVersion) Type() protoreflect.EnumType { + return &file_reservation_proto_enumTypes[0] +} + +func (x ReservationProtocolVersion) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ReservationProtocolVersion.Descriptor instead. +func (ReservationProtocolVersion) EnumDescriptor() ([]byte, []int) { + return file_reservation_proto_rawDescGZIP(), []int{0} +} + +// ReservationNotificationRequest is an empty request sent from the client to +// the server to open a stream to receive reservation notifications. +type ReservationNotificationRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ReservationNotificationRequest) Reset() { + *x = ReservationNotificationRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_reservation_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReservationNotificationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReservationNotificationRequest) ProtoMessage() {} + +func (x *ReservationNotificationRequest) ProtoReflect() protoreflect.Message { + mi := &file_reservation_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReservationNotificationRequest.ProtoReflect.Descriptor instead. +func (*ReservationNotificationRequest) Descriptor() ([]byte, []int) { + return file_reservation_proto_rawDescGZIP(), []int{0} +} + +// ServerReservationNotification is a notification sent from the server to the +// client if the server wants to open a reservation. +type ServerReservationNotification struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // reservation_id is the id of the reservation. + ReservationId []byte `protobuf:"bytes,1,opt,name=reservation_id,json=reservationId,proto3" json:"reservation_id,omitempty"` + // value is the value of the reservation in satoshis. + Value uint64 `protobuf:"varint,2,opt,name=value,proto3" json:"value,omitempty"` + // server_key is the public key of the server. + ServerKey []byte `protobuf:"bytes,3,opt,name=server_key,json=serverKey,proto3" json:"server_key,omitempty"` + // expiry is the absolute expiry of the reservation. + Expiry uint32 `protobuf:"varint,4,opt,name=expiry,proto3" json:"expiry,omitempty"` + // protocol_version is the version of the reservation protocol. + ProtocolVersion ReservationProtocolVersion `protobuf:"varint,5,opt,name=protocol_version,json=protocolVersion,proto3,enum=looprpc.ReservationProtocolVersion" json:"protocol_version,omitempty"` +} + +func (x *ServerReservationNotification) Reset() { + *x = ServerReservationNotification{} + if protoimpl.UnsafeEnabled { + mi := &file_reservation_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerReservationNotification) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerReservationNotification) ProtoMessage() {} + +func (x *ServerReservationNotification) ProtoReflect() protoreflect.Message { + mi := &file_reservation_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerReservationNotification.ProtoReflect.Descriptor instead. +func (*ServerReservationNotification) Descriptor() ([]byte, []int) { + return file_reservation_proto_rawDescGZIP(), []int{1} +} + +func (x *ServerReservationNotification) GetReservationId() []byte { + if x != nil { + return x.ReservationId + } + return nil +} + +func (x *ServerReservationNotification) GetValue() uint64 { + if x != nil { + return x.Value + } + return 0 +} + +func (x *ServerReservationNotification) GetServerKey() []byte { + if x != nil { + return x.ServerKey + } + return nil +} + +func (x *ServerReservationNotification) GetExpiry() uint32 { + if x != nil { + return x.Expiry + } + return 0 +} + +func (x *ServerReservationNotification) GetProtocolVersion() ReservationProtocolVersion { + if x != nil { + return x.ProtocolVersion + } + return ReservationProtocolVersion_RESERVATION_NONE +} + +// ServerOpenReservationRequest is a request sent from the client to the server +// to confirm a reservation opening. +type ServerOpenReservationRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // reservation_id is the id of the reservation. + ReservationId []byte `protobuf:"bytes,1,opt,name=reservation_id,json=reservationId,proto3" json:"reservation_id,omitempty"` + // client_key is the public key of the client. + ClientKey []byte `protobuf:"bytes,2,opt,name=client_key,json=clientKey,proto3" json:"client_key,omitempty"` +} + +func (x *ServerOpenReservationRequest) Reset() { + *x = ServerOpenReservationRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_reservation_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerOpenReservationRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerOpenReservationRequest) ProtoMessage() {} + +func (x *ServerOpenReservationRequest) ProtoReflect() protoreflect.Message { + mi := &file_reservation_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerOpenReservationRequest.ProtoReflect.Descriptor instead. +func (*ServerOpenReservationRequest) Descriptor() ([]byte, []int) { + return file_reservation_proto_rawDescGZIP(), []int{2} +} + +func (x *ServerOpenReservationRequest) GetReservationId() []byte { + if x != nil { + return x.ReservationId + } + return nil +} + +func (x *ServerOpenReservationRequest) GetClientKey() []byte { + if x != nil { + return x.ClientKey + } + return nil +} + +// ServerOpenReservationResponse is a response sent from the server to the +// client to confirm a reservation opening. +type ServerOpenReservationResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ServerOpenReservationResponse) Reset() { + *x = ServerOpenReservationResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_reservation_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerOpenReservationResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerOpenReservationResponse) ProtoMessage() {} + +func (x *ServerOpenReservationResponse) ProtoReflect() protoreflect.Message { + mi := &file_reservation_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerOpenReservationResponse.ProtoReflect.Descriptor instead. +func (*ServerOpenReservationResponse) Descriptor() ([]byte, []int) { + return file_reservation_proto_rawDescGZIP(), []int{3} +} + +var File_reservation_proto protoreflect.FileDescriptor + +var file_reservation_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x22, 0x20, 0x0a, 0x1e, + 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xe3, + 0x01, 0x0a, 0x1d, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, + 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x65, 0x78, + 0x70, 0x69, 0x72, 0x79, 0x12, 0x4e, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, + 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x64, 0x0a, 0x1c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, + 0x65, 0x6e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x72, 0x65, + 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x51, 0x0a, 0x1a, 0x52, + 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x45, 0x53, + 0x45, 0x52, 0x56, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, + 0x1d, 0x0a, 0x19, 0x52, 0x45, 0x53, 0x45, 0x52, 0x56, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, + 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x59, 0x10, 0x01, 0x32, 0xea, + 0x01, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x72, 0x0a, 0x1d, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x27, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, + 0x2e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x26, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x74, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x30, 0x01, 0x12, 0x60, 0x0a, 0x0f, 0x4f, 0x70, 0x65, + 0x6e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x6c, + 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x65, + 0x6e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, + 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x73, 0x77, 0x61, + 0x70, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_reservation_proto_rawDescOnce sync.Once + file_reservation_proto_rawDescData = file_reservation_proto_rawDesc +) + +func file_reservation_proto_rawDescGZIP() []byte { + file_reservation_proto_rawDescOnce.Do(func() { + file_reservation_proto_rawDescData = protoimpl.X.CompressGZIP(file_reservation_proto_rawDescData) + }) + return file_reservation_proto_rawDescData +} + +var file_reservation_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_reservation_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_reservation_proto_goTypes = []interface{}{ + (ReservationProtocolVersion)(0), // 0: looprpc.ReservationProtocolVersion + (*ReservationNotificationRequest)(nil), // 1: looprpc.ReservationNotificationRequest + (*ServerReservationNotification)(nil), // 2: looprpc.ServerReservationNotification + (*ServerOpenReservationRequest)(nil), // 3: looprpc.ServerOpenReservationRequest + (*ServerOpenReservationResponse)(nil), // 4: looprpc.ServerOpenReservationResponse +} +var file_reservation_proto_depIdxs = []int32{ + 0, // 0: looprpc.ServerReservationNotification.protocol_version:type_name -> looprpc.ReservationProtocolVersion + 1, // 1: looprpc.ReservationService.ReservationNotificationStream:input_type -> looprpc.ReservationNotificationRequest + 3, // 2: looprpc.ReservationService.OpenReservation:input_type -> looprpc.ServerOpenReservationRequest + 2, // 3: looprpc.ReservationService.ReservationNotificationStream:output_type -> looprpc.ServerReservationNotification + 4, // 4: looprpc.ReservationService.OpenReservation:output_type -> looprpc.ServerOpenReservationResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_reservation_proto_init() } +func file_reservation_proto_init() { + if File_reservation_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_reservation_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReservationNotificationRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_reservation_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerReservationNotification); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_reservation_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerOpenReservationRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_reservation_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerOpenReservationResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_reservation_proto_rawDesc, + NumEnums: 1, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_reservation_proto_goTypes, + DependencyIndexes: file_reservation_proto_depIdxs, + EnumInfos: file_reservation_proto_enumTypes, + MessageInfos: file_reservation_proto_msgTypes, + }.Build() + File_reservation_proto = out.File + file_reservation_proto_rawDesc = nil + file_reservation_proto_goTypes = nil + file_reservation_proto_depIdxs = nil +} diff --git a/swapserverrpc/reservation.proto b/swapserverrpc/reservation.proto new file mode 100644 index 0000000..e29d056 --- /dev/null +++ b/swapserverrpc/reservation.proto @@ -0,0 +1,70 @@ +syntax = "proto3"; + +// We can't change this to swapserverrpc, it would be a breaking change because +// the package name is also contained in the HTTP URIs and old clients would +// call the wrong endpoints. Luckily with the go_package option we can have +// different golang and RPC package names to fix protobuf namespace conflicts. +package looprpc; + +option go_package = "github.com/lightninglabs/loop/swapserverrpc"; + +service ReservationService { + // ReservationNotificationStream is a server side stream that sends + // notifications if the server wants to open a reservation to the client. + rpc ReservationNotificationStream (ReservationNotificationRequest) + returns (stream ServerReservationNotification); + + // OpenReservation requests a new reservation UTXO from the server. + rpc OpenReservation (ServerOpenReservationRequest) + returns (ServerOpenReservationResponse); +} + +// ReservationNotificationRequest is an empty request sent from the client to +// the server to open a stream to receive reservation notifications. +message ReservationNotificationRequest { +} + +// ServerReservationNotification is a notification sent from the server to the +// client if the server wants to open a reservation. +message ServerReservationNotification { + // reservation_id is the id of the reservation. + bytes reservation_id = 1; + + // value is the value of the reservation in satoshis. + uint64 value = 2; + + // server_key is the public key of the server. + bytes server_key = 3; + + // expiry is the absolute expiry of the reservation. + uint32 expiry = 4; + + // protocol_version is the version of the reservation protocol. + ReservationProtocolVersion protocol_version = 5; +} + +// ServerOpenReservationRequest is a request sent from the client to the server +// to confirm a reservation opening. +message ServerOpenReservationRequest { + // reservation_id is the id of the reservation. + bytes reservation_id = 1; + + // client_key is the public key of the client. + bytes client_key = 2; +} + +// ServerOpenReservationResponse is a response sent from the server to the +// client to confirm a reservation opening. +message ServerOpenReservationResponse { +} + +// ReservationProtocolVersion is the version of the reservation protocol. +enum ReservationProtocolVersion { + // RESERVATION_NONE is the default value and means that the reservation + // protocol version is not set. + RESERVATION_NONE = 0; + + // RESERVATION_SERVER_REQUEST is the first version of the reservation + // protocol where the server notifies the client about a reservation. + RESERVATION_SERVER_NOTIFY = 1; +}; diff --git a/swapserverrpc/reservation_grpc.pb.go b/swapserverrpc/reservation_grpc.pb.go new file mode 100644 index 0000000..f7e7a15 --- /dev/null +++ b/swapserverrpc/reservation_grpc.pb.go @@ -0,0 +1,171 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package swapserverrpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// ReservationServiceClient is the client API for ReservationService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ReservationServiceClient interface { + // ReservationNotificationStream is a server side stream that sends + // notifications if the server wants to open a reservation to the client. + ReservationNotificationStream(ctx context.Context, in *ReservationNotificationRequest, opts ...grpc.CallOption) (ReservationService_ReservationNotificationStreamClient, error) + // OpenReservation requests a new reservation UTXO from the server. + OpenReservation(ctx context.Context, in *ServerOpenReservationRequest, opts ...grpc.CallOption) (*ServerOpenReservationResponse, error) +} + +type reservationServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewReservationServiceClient(cc grpc.ClientConnInterface) ReservationServiceClient { + return &reservationServiceClient{cc} +} + +func (c *reservationServiceClient) ReservationNotificationStream(ctx context.Context, in *ReservationNotificationRequest, opts ...grpc.CallOption) (ReservationService_ReservationNotificationStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &ReservationService_ServiceDesc.Streams[0], "/looprpc.ReservationService/ReservationNotificationStream", opts...) + if err != nil { + return nil, err + } + x := &reservationServiceReservationNotificationStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ReservationService_ReservationNotificationStreamClient interface { + Recv() (*ServerReservationNotification, error) + grpc.ClientStream +} + +type reservationServiceReservationNotificationStreamClient struct { + grpc.ClientStream +} + +func (x *reservationServiceReservationNotificationStreamClient) Recv() (*ServerReservationNotification, error) { + m := new(ServerReservationNotification) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *reservationServiceClient) OpenReservation(ctx context.Context, in *ServerOpenReservationRequest, opts ...grpc.CallOption) (*ServerOpenReservationResponse, error) { + out := new(ServerOpenReservationResponse) + err := c.cc.Invoke(ctx, "/looprpc.ReservationService/OpenReservation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ReservationServiceServer is the server API for ReservationService service. +// All implementations must embed UnimplementedReservationServiceServer +// for forward compatibility +type ReservationServiceServer interface { + // ReservationNotificationStream is a server side stream that sends + // notifications if the server wants to open a reservation to the client. + ReservationNotificationStream(*ReservationNotificationRequest, ReservationService_ReservationNotificationStreamServer) error + // OpenReservation requests a new reservation UTXO from the server. + OpenReservation(context.Context, *ServerOpenReservationRequest) (*ServerOpenReservationResponse, error) + mustEmbedUnimplementedReservationServiceServer() +} + +// UnimplementedReservationServiceServer must be embedded to have forward compatible implementations. +type UnimplementedReservationServiceServer struct { +} + +func (UnimplementedReservationServiceServer) ReservationNotificationStream(*ReservationNotificationRequest, ReservationService_ReservationNotificationStreamServer) error { + return status.Errorf(codes.Unimplemented, "method ReservationNotificationStream not implemented") +} +func (UnimplementedReservationServiceServer) OpenReservation(context.Context, *ServerOpenReservationRequest) (*ServerOpenReservationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OpenReservation not implemented") +} +func (UnimplementedReservationServiceServer) mustEmbedUnimplementedReservationServiceServer() {} + +// UnsafeReservationServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ReservationServiceServer will +// result in compilation errors. +type UnsafeReservationServiceServer interface { + mustEmbedUnimplementedReservationServiceServer() +} + +func RegisterReservationServiceServer(s grpc.ServiceRegistrar, srv ReservationServiceServer) { + s.RegisterService(&ReservationService_ServiceDesc, srv) +} + +func _ReservationService_ReservationNotificationStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ReservationNotificationRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ReservationServiceServer).ReservationNotificationStream(m, &reservationServiceReservationNotificationStreamServer{stream}) +} + +type ReservationService_ReservationNotificationStreamServer interface { + Send(*ServerReservationNotification) error + grpc.ServerStream +} + +type reservationServiceReservationNotificationStreamServer struct { + grpc.ServerStream +} + +func (x *reservationServiceReservationNotificationStreamServer) Send(m *ServerReservationNotification) error { + return x.ServerStream.SendMsg(m) +} + +func _ReservationService_OpenReservation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ServerOpenReservationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ReservationServiceServer).OpenReservation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/looprpc.ReservationService/OpenReservation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ReservationServiceServer).OpenReservation(ctx, req.(*ServerOpenReservationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ReservationService_ServiceDesc is the grpc.ServiceDesc for ReservationService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ReservationService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "looprpc.ReservationService", + HandlerType: (*ReservationServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "OpenReservation", + Handler: _ReservationService_OpenReservation_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "ReservationNotificationStream", + Handler: _ReservationService_ReservationNotificationStream_Handler, + ServerStreams: true, + }, + }, + Metadata: "reservation.proto", +}