mirror of https://github.com/lightninglabs/loop
swapserverrpc: add instantout service
parent
b7c1e68f46
commit
932a55aaf6
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,136 @@
|
||||
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 InstantSwapServer {
|
||||
// RequestInstantLoopOut initiates an instant loop out swap.
|
||||
rpc RequestInstantLoopOut (InstantLoopOutRequest)
|
||||
returns (InstantLoopOutResponse);
|
||||
|
||||
// PollPaymentAccepted polls the server to see if the payment has been
|
||||
// accepted.
|
||||
rpc PollPaymentAccepted (PollPaymentAcceptedRequest)
|
||||
returns (PollPaymentAcceptedResponse);
|
||||
|
||||
// InitHtlcSig is called by the client to initiate the htlc sig exchange.
|
||||
rpc InitHtlcSig (InitHtlcSigRequest) returns (InitHtlcSigResponse);
|
||||
|
||||
// PushHtlcSig is called by the client to push the htlc sigs to the server.
|
||||
rpc PushHtlcSig (PushHtlcSigRequest) returns (PushHtlcSigResponse);
|
||||
|
||||
// PushPreimage is called by the client to push the preimage to the server.
|
||||
// This returns the musig2 signatures that the client needs to sweep the
|
||||
// htlc.
|
||||
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.
|
||||
rpc CancelInstantSwap (CancelInstantSwapRequest)
|
||||
returns (CancelInstantSwapResponse);
|
||||
}
|
||||
|
||||
message InstantLoopOutRequest {
|
||||
// Htlc related fields:
|
||||
// The key for the htlc preimage spending path.
|
||||
bytes receiver_key = 1;
|
||||
|
||||
// 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.
|
||||
int32 expiry = 3;
|
||||
|
||||
// The fee rate in sat/kw that should be used for the htlc.
|
||||
uint64 htlc_fee_rate = 4;
|
||||
|
||||
// The reservations used as the inputs.
|
||||
repeated bytes reservation_ids = 5;
|
||||
|
||||
// The protocol version to use for the swap.
|
||||
InstantOutProtocolVersion protocol_version = 6;
|
||||
}
|
||||
|
||||
message InstantLoopOutResponse {
|
||||
// The swap invoice that the client should pay.
|
||||
string swap_invoice = 1;
|
||||
|
||||
// the key for the htlc expiry path.
|
||||
bytes sender_key = 2;
|
||||
};
|
||||
|
||||
message PollPaymentAcceptedRequest {
|
||||
// The hash of the swap invoice.
|
||||
bytes swap_hash = 1;
|
||||
}
|
||||
|
||||
message PollPaymentAcceptedResponse {
|
||||
// Whether the payment has been accepted.
|
||||
bool accepted = 1;
|
||||
}
|
||||
|
||||
message InitHtlcSigRequest {
|
||||
// The hash of the swap invoice.
|
||||
bytes swap_hash = 1;
|
||||
|
||||
// The nonces that the client will use to generate the htlc sigs.
|
||||
repeated bytes htlc_client_nonces = 2;
|
||||
}
|
||||
|
||||
message InitHtlcSigResponse {
|
||||
// The nonces that the server will use to generate the htlc sigs.
|
||||
repeated bytes htlc_server_nonces = 2;
|
||||
}
|
||||
|
||||
message PushHtlcSigRequest {
|
||||
// The hash of the swap invoice.
|
||||
bytes swap_hash = 1;
|
||||
|
||||
// The sigs that the client generated for the reservation inputs.
|
||||
repeated bytes client_sigs = 2;
|
||||
}
|
||||
|
||||
message PushHtlcSigResponse {
|
||||
// The sigs that the server generated for the reservation inputs.
|
||||
repeated bytes server_sigs = 1;
|
||||
}
|
||||
|
||||
message PushPreimageRequest {
|
||||
// The preimage that the client generated for the swap.
|
||||
bytes preimage = 1;
|
||||
|
||||
// The nonces that the client used to generate the sweepless sweep sigs.
|
||||
repeated bytes client_nonces = 2;
|
||||
|
||||
// The address that the client wants to sweep the htlc to.
|
||||
string client_sweep_addr = 3;
|
||||
|
||||
// The fee rate in sat/kw that the client wants to use for the sweep.
|
||||
uint64 musig_tx_fee_rate = 4;
|
||||
}
|
||||
|
||||
message PushPreimageResponse {
|
||||
// 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;
|
||||
}
|
||||
|
||||
message CancelInstantSwapRequest {
|
||||
// The hash of the swap invoice.
|
||||
bytes swap_hash = 1;
|
||||
}
|
||||
|
||||
message CancelInstantSwapResponse {
|
||||
}
|
||||
|
||||
enum InstantOutProtocolVersion {
|
||||
INSTANTOUT_NONE = 0;
|
||||
INSTANTOUT_FULL_RESERVATION = 1;
|
||||
};
|
@ -0,0 +1,301 @@
|
||||
// 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
|
||||
|
||||
// InstantSwapServerClient is the client API for InstantSwapServer 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 InstantSwapServerClient interface {
|
||||
// RequestInstantLoopOut initiates an instant loop out swap.
|
||||
RequestInstantLoopOut(ctx context.Context, in *InstantLoopOutRequest, opts ...grpc.CallOption) (*InstantLoopOutResponse, error)
|
||||
// PollPaymentAccepted polls the server to see if the payment has been
|
||||
// accepted.
|
||||
PollPaymentAccepted(ctx context.Context, in *PollPaymentAcceptedRequest, opts ...grpc.CallOption) (*PollPaymentAcceptedResponse, error)
|
||||
// InitHtlcSig is called by the client to initiate the htlc sig exchange.
|
||||
InitHtlcSig(ctx context.Context, in *InitHtlcSigRequest, opts ...grpc.CallOption) (*InitHtlcSigResponse, error)
|
||||
// PushHtlcSig is called by the client to push the htlc sigs to the server.
|
||||
PushHtlcSig(ctx context.Context, in *PushHtlcSigRequest, opts ...grpc.CallOption) (*PushHtlcSigResponse, error)
|
||||
// PushPreimage is called by the client to push the preimage to the server.
|
||||
// This returns the musig2 signatures that the client needs to sweep the
|
||||
// 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.
|
||||
CancelInstantSwap(ctx context.Context, in *CancelInstantSwapRequest, opts ...grpc.CallOption) (*CancelInstantSwapResponse, error)
|
||||
}
|
||||
|
||||
type instantSwapServerClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewInstantSwapServerClient(cc grpc.ClientConnInterface) InstantSwapServerClient {
|
||||
return &instantSwapServerClient{cc}
|
||||
}
|
||||
|
||||
func (c *instantSwapServerClient) RequestInstantLoopOut(ctx context.Context, in *InstantLoopOutRequest, opts ...grpc.CallOption) (*InstantLoopOutResponse, error) {
|
||||
out := new(InstantLoopOutResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.InstantSwapServer/RequestInstantLoopOut", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instantSwapServerClient) PollPaymentAccepted(ctx context.Context, in *PollPaymentAcceptedRequest, opts ...grpc.CallOption) (*PollPaymentAcceptedResponse, error) {
|
||||
out := new(PollPaymentAcceptedResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.InstantSwapServer/PollPaymentAccepted", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instantSwapServerClient) InitHtlcSig(ctx context.Context, in *InitHtlcSigRequest, opts ...grpc.CallOption) (*InitHtlcSigResponse, error) {
|
||||
out := new(InitHtlcSigResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.InstantSwapServer/InitHtlcSig", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instantSwapServerClient) PushHtlcSig(ctx context.Context, in *PushHtlcSigRequest, opts ...grpc.CallOption) (*PushHtlcSigResponse, error) {
|
||||
out := new(PushHtlcSigResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.InstantSwapServer/PushHtlcSig", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instantSwapServerClient) PushPreimage(ctx context.Context, in *PushPreimageRequest, opts ...grpc.CallOption) (*PushPreimageResponse, error) {
|
||||
out := new(PushPreimageResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.InstantSwapServer/PushPreimage", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *instantSwapServerClient) CancelInstantSwap(ctx context.Context, in *CancelInstantSwapRequest, opts ...grpc.CallOption) (*CancelInstantSwapResponse, error) {
|
||||
out := new(CancelInstantSwapResponse)
|
||||
err := c.cc.Invoke(ctx, "/looprpc.InstantSwapServer/CancelInstantSwap", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// InstantSwapServerServer is the server API for InstantSwapServer service.
|
||||
// All implementations must embed UnimplementedInstantSwapServerServer
|
||||
// for forward compatibility
|
||||
type InstantSwapServerServer interface {
|
||||
// RequestInstantLoopOut initiates an instant loop out swap.
|
||||
RequestInstantLoopOut(context.Context, *InstantLoopOutRequest) (*InstantLoopOutResponse, error)
|
||||
// PollPaymentAccepted polls the server to see if the payment has been
|
||||
// accepted.
|
||||
PollPaymentAccepted(context.Context, *PollPaymentAcceptedRequest) (*PollPaymentAcceptedResponse, error)
|
||||
// InitHtlcSig is called by the client to initiate the htlc sig exchange.
|
||||
InitHtlcSig(context.Context, *InitHtlcSigRequest) (*InitHtlcSigResponse, error)
|
||||
// PushHtlcSig is called by the client to push the htlc sigs to the server.
|
||||
PushHtlcSig(context.Context, *PushHtlcSigRequest) (*PushHtlcSigResponse, error)
|
||||
// PushPreimage is called by the client to push the preimage to the server.
|
||||
// This returns the musig2 signatures that the client needs to sweep the
|
||||
// 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.
|
||||
CancelInstantSwap(context.Context, *CancelInstantSwapRequest) (*CancelInstantSwapResponse, error)
|
||||
mustEmbedUnimplementedInstantSwapServerServer()
|
||||
}
|
||||
|
||||
// UnimplementedInstantSwapServerServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedInstantSwapServerServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedInstantSwapServerServer) RequestInstantLoopOut(context.Context, *InstantLoopOutRequest) (*InstantLoopOutResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RequestInstantLoopOut not implemented")
|
||||
}
|
||||
func (UnimplementedInstantSwapServerServer) PollPaymentAccepted(context.Context, *PollPaymentAcceptedRequest) (*PollPaymentAcceptedResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PollPaymentAccepted not implemented")
|
||||
}
|
||||
func (UnimplementedInstantSwapServerServer) InitHtlcSig(context.Context, *InitHtlcSigRequest) (*InitHtlcSigResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method InitHtlcSig not implemented")
|
||||
}
|
||||
func (UnimplementedInstantSwapServerServer) PushHtlcSig(context.Context, *PushHtlcSigRequest) (*PushHtlcSigResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PushHtlcSig not implemented")
|
||||
}
|
||||
func (UnimplementedInstantSwapServerServer) PushPreimage(context.Context, *PushPreimageRequest) (*PushPreimageResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PushPreimage not implemented")
|
||||
}
|
||||
func (UnimplementedInstantSwapServerServer) CancelInstantSwap(context.Context, *CancelInstantSwapRequest) (*CancelInstantSwapResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CancelInstantSwap not implemented")
|
||||
}
|
||||
func (UnimplementedInstantSwapServerServer) mustEmbedUnimplementedInstantSwapServerServer() {}
|
||||
|
||||
// UnsafeInstantSwapServerServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to InstantSwapServerServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeInstantSwapServerServer interface {
|
||||
mustEmbedUnimplementedInstantSwapServerServer()
|
||||
}
|
||||
|
||||
func RegisterInstantSwapServerServer(s grpc.ServiceRegistrar, srv InstantSwapServerServer) {
|
||||
s.RegisterService(&InstantSwapServer_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _InstantSwapServer_RequestInstantLoopOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(InstantLoopOutRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstantSwapServerServer).RequestInstantLoopOut(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.InstantSwapServer/RequestInstantLoopOut",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstantSwapServerServer).RequestInstantLoopOut(ctx, req.(*InstantLoopOutRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstantSwapServer_PollPaymentAccepted_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PollPaymentAcceptedRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstantSwapServerServer).PollPaymentAccepted(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.InstantSwapServer/PollPaymentAccepted",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstantSwapServerServer).PollPaymentAccepted(ctx, req.(*PollPaymentAcceptedRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstantSwapServer_InitHtlcSig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(InitHtlcSigRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstantSwapServerServer).InitHtlcSig(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.InstantSwapServer/InitHtlcSig",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstantSwapServerServer).InitHtlcSig(ctx, req.(*InitHtlcSigRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstantSwapServer_PushHtlcSig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PushHtlcSigRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstantSwapServerServer).PushHtlcSig(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.InstantSwapServer/PushHtlcSig",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstantSwapServerServer).PushHtlcSig(ctx, req.(*PushHtlcSigRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstantSwapServer_PushPreimage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PushPreimageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstantSwapServerServer).PushPreimage(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.InstantSwapServer/PushPreimage",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstantSwapServerServer).PushPreimage(ctx, req.(*PushPreimageRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _InstantSwapServer_CancelInstantSwap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CancelInstantSwapRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(InstantSwapServerServer).CancelInstantSwap(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/looprpc.InstantSwapServer/CancelInstantSwap",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(InstantSwapServerServer).CancelInstantSwap(ctx, req.(*CancelInstantSwapRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// InstantSwapServer_ServiceDesc is the grpc.ServiceDesc for InstantSwapServer service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var InstantSwapServer_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "looprpc.InstantSwapServer",
|
||||
HandlerType: (*InstantSwapServerServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "RequestInstantLoopOut",
|
||||
Handler: _InstantSwapServer_RequestInstantLoopOut_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PollPaymentAccepted",
|
||||
Handler: _InstantSwapServer_PollPaymentAccepted_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "InitHtlcSig",
|
||||
Handler: _InstantSwapServer_InitHtlcSig_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PushHtlcSig",
|
||||
Handler: _InstantSwapServer_PushHtlcSig_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PushPreimage",
|
||||
Handler: _InstantSwapServer_PushPreimage_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CancelInstantSwap",
|
||||
Handler: _InstantSwapServer_CancelInstantSwap_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "instantout.proto",
|
||||
}
|
Loading…
Reference in New Issue