swapserverrpc: sync with server types

This commit is contained in:
Boris Nagaev 2024-09-22 13:31:03 -03:00
parent 8447f58ff9
commit af81f3b2bf
No known key found for this signature in database
8 changed files with 1061 additions and 403 deletions

View file

@ -81,7 +81,9 @@ type InstantLoopOutRequest struct {
ReceiverKey []byte `protobuf:"bytes,1,opt,name=receiver_key,json=receiverKey,proto3" json:"receiver_key,omitempty"`
// The hash of the preimage that will be used to settle the htlc.
SwapHash []byte `protobuf:"bytes,2,opt,name=swap_hash,json=swapHash,proto3" json:"swap_hash,omitempty"`
// The requested absolute block height of the on-chain htlc.
// The requested absolute block height of the on-chain htlc. This is
// subjected to min and max constraints as reported in the LoopOutTerms
// response.
Expiry int32 `protobuf:"varint,3,opt,name=expiry,proto3" json:"expiry,omitempty"`
// The fee rate in sat/kw that should be used for the htlc.
HtlcFeeRate uint64 `protobuf:"varint,4,opt,name=htlc_fee_rate,json=htlcFeeRate,proto3" json:"htlc_fee_rate,omitempty"`

View file

@ -30,7 +30,8 @@ service InstantSwapServer {
rpc PushPreimage (PushPreimageRequest) returns (PushPreimageResponse);
// CancelInstantSwap tries to cancel the instant swap. This can only be
// called if the swap has not been accepted yet.
// called if the swap has not been accepted yet. This allows the server to
// release the reservation inputs.
rpc CancelInstantSwap (CancelInstantSwapRequest)
returns (CancelInstantSwapResponse);
@ -48,7 +49,9 @@ message InstantLoopOutRequest {
// The hash of the preimage that will be used to settle the htlc.
bytes swap_hash = 2;
// The requested absolute block height of the on-chain htlc.
// The requested absolute block height of the on-chain htlc. This is
// subjected to min and max constraints as reported in the LoopOutTerms
// response.
int32 expiry = 3;
// The fee rate in sat/kw that should be used for the htlc.

View file

@ -32,7 +32,8 @@ type InstantSwapServerClient interface {
// htlc.
PushPreimage(ctx context.Context, in *PushPreimageRequest, opts ...grpc.CallOption) (*PushPreimageResponse, error)
// CancelInstantSwap tries to cancel the instant swap. This can only be
// called if the swap has not been accepted yet.
// called if the swap has not been accepted yet. This allows the server to
// release the reservation inputs.
CancelInstantSwap(ctx context.Context, in *CancelInstantSwapRequest, opts ...grpc.CallOption) (*CancelInstantSwapResponse, error)
// GetInstantOutQuote returns the absolute fee in satoshis for the swap and
// the pubkey to query the route to estimate offchain payment fees.
@ -128,7 +129,8 @@ type InstantSwapServerServer interface {
// htlc.
PushPreimage(context.Context, *PushPreimageRequest) (*PushPreimageResponse, error)
// CancelInstantSwap tries to cancel the instant swap. This can only be
// called if the swap has not been accepted yet.
// called if the swap has not been accepted yet. This allows the server to
// release the reservation inputs.
CancelInstantSwap(context.Context, *CancelInstantSwapRequest) (*CancelInstantSwapResponse, error)
// GetInstantOutQuote returns the absolute fee in satoshis for the swap and
// the pubkey to query the route to estimate offchain payment fees.

View file

@ -32,7 +32,7 @@ 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
// RESERVATION_SERVER_NOTIFY is the first version of the reservation
// protocol where the server notifies the client about a reservation.
ReservationProtocolVersion_RESERVATION_SERVER_NOTIFY ReservationProtocolVersion = 1
)
@ -82,6 +82,9 @@ type ReservationNotificationRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// protocol_version is the maximum version the client supports.
ProtocolVersion ReservationProtocolVersion `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion,proto3,enum=looprpc.ReservationProtocolVersion" json:"protocol_version,omitempty"`
}
func (x *ReservationNotificationRequest) Reset() {
@ -116,6 +119,13 @@ func (*ReservationNotificationRequest) Descriptor() ([]byte, []int) {
return file_reservation_proto_rawDescGZIP(), []int{0}
}
func (x *ReservationNotificationRequest) GetProtocolVersion() ReservationProtocolVersion {
if x != nil {
return x.ProtocolVersion
}
return ReservationProtocolVersion_RESERVATION_NONE
}
// ServerReservationNotification is a notification sent from the server to the
// client if the server wants to open a reservation.
type ServerReservationNotification struct {
@ -305,9 +315,14 @@ 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,
0x6f, 0x74, 0x6f, 0x12, 0x07, 0x6c, 0x6f, 0x6f, 0x70, 0x72, 0x70, 0x63, 0x22, 0x70, 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,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4e,
0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69,
0x6f, 0x6e, 0x18, 0x01, 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, 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,
@ -379,16 +394,17 @@ var file_reservation_proto_goTypes = []interface{}{
(*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
0, // 0: looprpc.ReservationNotificationRequest.protocol_version:type_name -> looprpc.ReservationProtocolVersion
0, // 1: looprpc.ServerReservationNotification.protocol_version:type_name -> looprpc.ReservationProtocolVersion
1, // 2: looprpc.ReservationService.ReservationNotificationStream:input_type -> looprpc.ReservationNotificationRequest
3, // 3: looprpc.ReservationService.OpenReservation:input_type -> looprpc.ServerOpenReservationRequest
2, // 4: looprpc.ReservationService.ReservationNotificationStream:output_type -> looprpc.ServerReservationNotification
4, // 5: looprpc.ReservationService.OpenReservation:output_type -> looprpc.ServerOpenReservationResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_reservation_proto_init() }

View file

@ -22,6 +22,8 @@ service ReservationService {
// ReservationNotificationRequest is an empty request sent from the client to
// the server to open a stream to receive reservation notifications.
message ReservationNotificationRequest {
// protocol_version is the maximum version the client supports.
ReservationProtocolVersion protocol_version = 1;
}
// ServerReservationNotification is a notification sent from the server to the
@ -64,7 +66,7 @@ enum ReservationProtocolVersion {
// protocol version is not set.
RESERVATION_NONE = 0;
// RESERVATION_SERVER_REQUEST is the first version of the reservation
// RESERVATION_SERVER_NOTIFY is the first version of the reservation
// protocol where the server notifies the client about a reservation.
RESERVATION_SERVER_NOTIFY = 1;
};

File diff suppressed because it is too large Load diff

View file

@ -284,6 +284,13 @@ message ServerLoopInQuoteRequest {
// loopd/v0.10.0-beta/commit=3b635821
// litd/v0.2.0-alpha/commit=326d754
string user_agent = 6;
// If this is a quote request for a static address loop in, this value
// defines the number of static address deposits that the client wants to
// quote for. The amount of the quote reflects the sum of all deposits. The
// number of deposits here is taken into consideration for the total swap
// fee.
uint32 num_static_address_deposits = 7;
}
message ServerLoopInQuoteResponse {
@ -514,6 +521,7 @@ message ServerProbeRequest {
// The protocol version that the client adheres to.
ProtocolVersion protocol_version = 1;
// The probe amount.
uint64 amt = 2;
// The target node for the probe.
@ -638,12 +646,12 @@ message ServerPushKeyRes {
}
// FetchL402Request is an empty request sent from the client to the server to
// fetch the lnd l402.
// fetch the lnd L402.
message FetchL402Request {
}
// FetchL402Response is an empty response sent from the server to the client to
// confirm the lnd l402.
// confirm the lnd L402.
message FetchL402Response {
}
@ -652,4 +660,61 @@ message FetchL402Response {
enum StaticAddressProtocolVersion {
// V0 is the initially released static address protocol version.
V0 = 0;
}
}
service StaticAddressServer {
// ServerNewAddress generates a new static address for the client to use.
// The server will generate the address and return the server key and the
// address's CSV expiry.
rpc ServerNewAddress (ServerNewAddressRequest)
returns (ServerNewAddressResponse);
// ServerWithdrawDeposits allows to cooperatively sweep deposits that
// haven't timed out yet to the client's wallet. The server will generate
// the partial sigs for the client's selected deposits.
rpc ServerWithdrawDeposits (ServerWithdrawRequest)
returns (ServerWithdrawResponse);
}
message ServerNewAddressRequest {
// The protocol version that the client adheres to.
StaticAddressProtocolVersion protocol_version = 1;
// The client key for the MuSig2 static address output.
bytes client_key = 2;
}
message ServerNewAddressResponse {
ServerAddressParameters params = 1;
}
message ServerAddressParameters {
// The server key for the MuSig2 static address output.
bytes server_key = 1;
// The CSV expiry of the static address output.
uint32 expiry = 2;
}
message ServerWithdrawRequest {
// The deposit outpoints the client wishes to close.
repeated PrevoutInfo outpoints = 1;
// The nonces that the client used to generate the coop close tx sigs.
repeated bytes client_nonces = 2;
// The address that the client wants to sweep the static address deposits
// to.
string client_sweep_addr = 3;
// The fee rate in sat/kw that the client wants to use for the sweep.
uint64 tx_fee_rate = 4;
}
message ServerWithdrawResponse {
// The sweep sigs that the server generated for the htlc.
repeated bytes musig2_sweep_sigs = 1;
// The nonces that the server used to generate the sweepless sweep sigs.
repeated bytes server_nonces = 2;
}

View file

@ -698,3 +698,137 @@ var SwapServer_ServiceDesc = grpc.ServiceDesc{
},
Metadata: "server.proto",
}
// StaticAddressServerClient is the client API for StaticAddressServer 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 StaticAddressServerClient interface {
// ServerNewAddress generates a new static address for the client to use.
// The server will generate the address and return the server key and the
// address's CSV expiry.
ServerNewAddress(ctx context.Context, in *ServerNewAddressRequest, opts ...grpc.CallOption) (*ServerNewAddressResponse, error)
// ServerWithdrawDeposits allows to cooperatively sweep deposits that
// haven't timed out yet to the client's wallet. The server will generate
// the partial sigs for the client's selected deposits.
ServerWithdrawDeposits(ctx context.Context, in *ServerWithdrawRequest, opts ...grpc.CallOption) (*ServerWithdrawResponse, error)
}
type staticAddressServerClient struct {
cc grpc.ClientConnInterface
}
func NewStaticAddressServerClient(cc grpc.ClientConnInterface) StaticAddressServerClient {
return &staticAddressServerClient{cc}
}
func (c *staticAddressServerClient) ServerNewAddress(ctx context.Context, in *ServerNewAddressRequest, opts ...grpc.CallOption) (*ServerNewAddressResponse, error) {
out := new(ServerNewAddressResponse)
err := c.cc.Invoke(ctx, "/looprpc.StaticAddressServer/ServerNewAddress", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *staticAddressServerClient) ServerWithdrawDeposits(ctx context.Context, in *ServerWithdrawRequest, opts ...grpc.CallOption) (*ServerWithdrawResponse, error) {
out := new(ServerWithdrawResponse)
err := c.cc.Invoke(ctx, "/looprpc.StaticAddressServer/ServerWithdrawDeposits", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// StaticAddressServerServer is the server API for StaticAddressServer service.
// All implementations must embed UnimplementedStaticAddressServerServer
// for forward compatibility
type StaticAddressServerServer interface {
// ServerNewAddress generates a new static address for the client to use.
// The server will generate the address and return the server key and the
// address's CSV expiry.
ServerNewAddress(context.Context, *ServerNewAddressRequest) (*ServerNewAddressResponse, error)
// ServerWithdrawDeposits allows to cooperatively sweep deposits that
// haven't timed out yet to the client's wallet. The server will generate
// the partial sigs for the client's selected deposits.
ServerWithdrawDeposits(context.Context, *ServerWithdrawRequest) (*ServerWithdrawResponse, error)
mustEmbedUnimplementedStaticAddressServerServer()
}
// UnimplementedStaticAddressServerServer must be embedded to have forward compatible implementations.
type UnimplementedStaticAddressServerServer struct {
}
func (UnimplementedStaticAddressServerServer) ServerNewAddress(context.Context, *ServerNewAddressRequest) (*ServerNewAddressResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ServerNewAddress not implemented")
}
func (UnimplementedStaticAddressServerServer) ServerWithdrawDeposits(context.Context, *ServerWithdrawRequest) (*ServerWithdrawResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ServerWithdrawDeposits not implemented")
}
func (UnimplementedStaticAddressServerServer) mustEmbedUnimplementedStaticAddressServerServer() {}
// UnsafeStaticAddressServerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to StaticAddressServerServer will
// result in compilation errors.
type UnsafeStaticAddressServerServer interface {
mustEmbedUnimplementedStaticAddressServerServer()
}
func RegisterStaticAddressServerServer(s grpc.ServiceRegistrar, srv StaticAddressServerServer) {
s.RegisterService(&StaticAddressServer_ServiceDesc, srv)
}
func _StaticAddressServer_ServerNewAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ServerNewAddressRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StaticAddressServerServer).ServerNewAddress(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.StaticAddressServer/ServerNewAddress",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StaticAddressServerServer).ServerNewAddress(ctx, req.(*ServerNewAddressRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StaticAddressServer_ServerWithdrawDeposits_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ServerWithdrawRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StaticAddressServerServer).ServerWithdrawDeposits(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.StaticAddressServer/ServerWithdrawDeposits",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StaticAddressServerServer).ServerWithdrawDeposits(ctx, req.(*ServerWithdrawRequest))
}
return interceptor(ctx, in, info, handler)
}
// StaticAddressServer_ServiceDesc is the grpc.ServiceDesc for StaticAddressServer service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var StaticAddressServer_ServiceDesc = grpc.ServiceDesc{
ServiceName: "looprpc.StaticAddressServer",
HandlerType: (*StaticAddressServerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ServerNewAddress",
Handler: _StaticAddressServer_ServerNewAddress_Handler,
},
{
MethodName: "ServerWithdrawDeposits",
Handler: _StaticAddressServer_ServerWithdrawDeposits_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "server.proto",
}