Browse Source

loopd: add RPC method to list tokens

pull/101/head
Oliver Gugger 1 year ago
parent
commit
47bf510bd8
No known key found for this signature in database GPG Key ID: 8E4256593F177720
7 changed files with 617 additions and 156 deletions
  1. +1
    -0
      client.go
  2. +34
    -0
      cmd/loopd/swapclient_server.go
  3. +2
    -0
      config.go
  4. +309
    -70
      looprpc/client.pb.go
  5. +61
    -66
      looprpc/client.pb.gw.go
  6. +78
    -14
      looprpc/client.proto
  7. +132
    -6
      looprpc/client.swagger.json

+ 1
- 0
client.go View File

@ -95,6 +95,7 @@ func NewClient(dbDir string, serverAddress string, insecure bool,
LndServices: lnd,
Server: swapServerClient,
Store: store,
LsatStore: lsatStore,
CreateExpiryTimer: func(d time.Duration) <-chan time.Time {
return time.NewTimer(d).C
},

+ 34
- 0
cmd/loopd/swapclient_server.go View File

@ -346,6 +346,40 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
}, nil
}
// GetLsatTokens returns all tokens that are contained in the LSAT token store.
func (s *swapClientServer) GetLsatTokens(ctx context.Context,
_ *looprpc.TokensRequest) (*looprpc.TokensResponse, error) {
log.Infof("Get LSAT tokens request received")
tokens, err := s.impl.LsatStore.AllTokens()
if err != nil {
return nil, err
}
rpcTokens := make([]*looprpc.LsatToken, len(tokens))
idx := 0
for key, token := range tokens {
macBytes, err := token.BaseMacaroon().MarshalBinary()
if err != nil {
return nil, err
}
rpcTokens[idx] = &looprpc.LsatToken{
BaseMacaroon: macBytes,
PaymentHash: token.PaymentHash[:],
PaymentPreimage: token.Preimage[:],
AmountPaidMsat: int64(token.AmountPaid),
RoutingFeePaidMsat: int64(token.RoutingFeePaid),
TimeCreated: token.TimeCreated.Unix(),
Expired: !token.IsValid(),
StorageName: key,
}
idx++
}
return &looprpc.TokensResponse{Tokens: rpcTokens}, nil
}
// validateConfTarget ensures the given confirmation target is valid. If one
// isn't specified (0 value), then the default target is used.
func validateConfTarget(target, defaultTarget int32) (int32, error) {

+ 2
- 0
config.go View File

@ -5,6 +5,7 @@ import (
"github.com/lightninglabs/loop/lndclient"
"github.com/lightninglabs/loop/loopdb"
"github.com/lightninglabs/loop/lsat"
)
// clientConfig contains config items for the swap client.
@ -12,5 +13,6 @@ type clientConfig struct {
LndServices *lndclient.LndServices
Server swapServerClient
Store loopdb.SwapStore
LsatStore lsat.Store
CreateExpiryTimer func(expiry time.Duration) <-chan time.Time
}

+ 309
- 70
looprpc/client.pb.go View File

@ -801,6 +801,192 @@ func (m *QuoteResponse) GetCltvDelta() int32 {
return 0
}
type TokensRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *TokensRequest) Reset() { *m = TokensRequest{} }
func (m *TokensRequest) String() string { return proto.CompactTextString(m) }
func (*TokensRequest) ProtoMessage() {}
func (*TokensRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_014de31d7ac8c57c, []int{9}
}
func (m *TokensRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TokensRequest.Unmarshal(m, b)
}
func (m *TokensRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TokensRequest.Marshal(b, m, deterministic)
}
func (m *TokensRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_TokensRequest.Merge(m, src)
}
func (m *TokensRequest) XXX_Size() int {
return xxx_messageInfo_TokensRequest.Size(m)
}
func (m *TokensRequest) XXX_DiscardUnknown() {
xxx_messageInfo_TokensRequest.DiscardUnknown(m)
}
var xxx_messageInfo_TokensRequest proto.InternalMessageInfo
type TokensResponse struct {
//*
//List of all tokens the daemon knows of, including old/expired tokens.
Tokens []*LsatToken `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *TokensResponse) Reset() { *m = TokensResponse{} }
func (m *TokensResponse) String() string { return proto.CompactTextString(m) }
func (*TokensResponse) ProtoMessage() {}
func (*TokensResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_014de31d7ac8c57c, []int{10}
}
func (m *TokensResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TokensResponse.Unmarshal(m, b)
}
func (m *TokensResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TokensResponse.Marshal(b, m, deterministic)
}
func (m *TokensResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_TokensResponse.Merge(m, src)
}
func (m *TokensResponse) XXX_Size() int {
return xxx_messageInfo_TokensResponse.Size(m)
}
func (m *TokensResponse) XXX_DiscardUnknown() {
xxx_messageInfo_TokensResponse.DiscardUnknown(m)
}
var xxx_messageInfo_TokensResponse proto.InternalMessageInfo
func (m *TokensResponse) GetTokens() []*LsatToken {
if m != nil {
return m.Tokens
}
return nil
}
type LsatToken struct {
//*
//The base macaroon that was baked by the auth server.
BaseMacaroon []byte `protobuf:"bytes,1,opt,name=base_macaroon,json=baseMacaroon,proto3" json:"base_macaroon,omitempty"`
//*
//The payment hash of the payment that was paid to obtain the token.
PaymentHash []byte `protobuf:"bytes,2,opt,name=payment_hash,json=paymentHash,proto3" json:"payment_hash,omitempty"`
//*
//The preimage of the payment hash, knowledge of this is proof that the
//payment has been paid. If the preimage is set to all zeros, this means the
//payment is still pending and the token is not yet fully valid.
PaymentPreimage []byte `protobuf:"bytes,3,opt,name=payment_preimage,json=paymentPreimage,proto3" json:"payment_preimage,omitempty"`
//*
//The amount of millisatoshis that was paid to get the token.
AmountPaidMsat int64 `protobuf:"varint,4,opt,name=amount_paid_msat,json=amountPaidMsat,proto3" json:"amount_paid_msat,omitempty"`
//*
//The amount of millisatoshis paid in routing fee to pay for the token.
RoutingFeePaidMsat int64 `protobuf:"varint,5,opt,name=routing_fee_paid_msat,json=routingFeePaidMsat,proto3" json:"routing_fee_paid_msat,omitempty"`
//*
//The creation time of the token as UNIX timestamp in seconds.
TimeCreated int64 `protobuf:"varint,6,opt,name=time_created,json=timeCreated,proto3" json:"time_created,omitempty"`
//*
//Indicates whether the token is expired or still valid.
Expired bool `protobuf:"varint,7,opt,name=expired,proto3" json:"expired,omitempty"`
//*
//Identifying attribute of this token in the store. Currently represents the
//file name of the token where it's stored on the file system.
StorageName string `protobuf:"bytes,8,opt,name=storage_name,json=storageName,proto3" json:"storage_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *LsatToken) Reset() { *m = LsatToken{} }
func (m *LsatToken) String() string { return proto.CompactTextString(m) }
func (*LsatToken) ProtoMessage() {}
func (*LsatToken) Descriptor() ([]byte, []int) {
return fileDescriptor_014de31d7ac8c57c, []int{11}
}
func (m *LsatToken) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LsatToken.Unmarshal(m, b)
}
func (m *LsatToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_LsatToken.Marshal(b, m, deterministic)
}
func (m *LsatToken) XXX_Merge(src proto.Message) {
xxx_messageInfo_LsatToken.Merge(m, src)
}
func (m *LsatToken) XXX_Size() int {
return xxx_messageInfo_LsatToken.Size(m)
}
func (m *LsatToken) XXX_DiscardUnknown() {
xxx_messageInfo_LsatToken.DiscardUnknown(m)
}
var xxx_messageInfo_LsatToken proto.InternalMessageInfo
func (m *LsatToken) GetBaseMacaroon() []byte {
if m != nil {
return m.BaseMacaroon
}
return nil
}
func (m *LsatToken) GetPaymentHash() []byte {
if m != nil {
return m.PaymentHash
}
return nil
}
func (m *LsatToken) GetPaymentPreimage() []byte {
if m != nil {
return m.PaymentPreimage
}
return nil
}
func (m *LsatToken) GetAmountPaidMsat() int64 {
if m != nil {
return m.AmountPaidMsat
}
return 0
}
func (m *LsatToken) GetRoutingFeePaidMsat() int64 {
if m != nil {
return m.RoutingFeePaidMsat
}
return 0
}
func (m *LsatToken) GetTimeCreated() int64 {
if m != nil {
return m.TimeCreated
}
return 0
}
func (m *LsatToken) GetExpired() bool {
if m != nil {
return m.Expired
}
return false
}
func (m *LsatToken) GetStorageName() string {
if m != nil {
return m.StorageName
}
return ""
}
func init() {
proto.RegisterEnum("looprpc.SwapType", SwapType_name, SwapType_value)
proto.RegisterEnum("looprpc.SwapState", SwapState_name, SwapState_value)
@ -813,81 +999,97 @@ func init() {
proto.RegisterType((*TermsResponse)(nil), "looprpc.TermsResponse")
proto.RegisterType((*QuoteRequest)(nil), "looprpc.QuoteRequest")
proto.RegisterType((*QuoteResponse)(nil), "looprpc.QuoteResponse")
proto.RegisterType((*TokensRequest)(nil), "looprpc.TokensRequest")
proto.RegisterType((*TokensResponse)(nil), "looprpc.TokensResponse")
proto.RegisterType((*LsatToken)(nil), "looprpc.LsatToken")
}
func init() { proto.RegisterFile("client.proto", fileDescriptor_014de31d7ac8c57c) }
var fileDescriptor_014de31d7ac8c57c = []byte{
// 1096 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x73, 0xda, 0xc6,
0x1b, 0x8e, 0x40, 0x18, 0xf1, 0x5a, 0xc8, 0x62, 0x9d, 0xd8, 0x98, 0xdf, 0x2f, 0x13, 0xaa, 0x36,
0x29, 0xe3, 0x43, 0x68, 0x93, 0x53, 0x73, 0xa3, 0x40, 0x12, 0x3c, 0xb6, 0xa1, 0x02, 0x67, 0xa6,
0xbd, 0xa8, 0x1b, 0x58, 0x6c, 0xcd, 0x48, 0x2b, 0x45, 0x5a, 0xfc, 0x67, 0x3a, 0xb9, 0xf4, 0x2b,
0xf4, 0xd6, 0x6f, 0xd1, 0x99, 0x7e, 0x93, 0xde, 0x7b, 0xea, 0xf4, 0x73, 0x74, 0xf6, 0x5d, 0x81,
0x85, 0x89, 0x2f, 0xb9, 0x99, 0x67, 0x9f, 0x7d, 0xde, 0x3f, 0xfb, 0xbc, 0xaf, 0x0c, 0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, 0xcf, 0x9c, 0x74, 0x7e, 0x30, 0x72, 0xd2, 0x6b,
0x36, 0x76, 0x9a, 0x28, 0xdd, 0x20, 0xf5, 0x35, 0xe9, 0x0f, 0x92, 0xd3, 0xfe, 0x85, 0x86, 0xe2,
0x23, 0xf9, 0x09, 0xac, 0x37, 0x4c, 0xa8, 0xce, 0x7d, 0x56, 0xf6, 0x07, 0x18, 0x62, 0x97, 0xd4,
0x72, 0xfd, 0xcc, 0x92, 0xff, 0x39, 0xa7, 0xfd, 0x59, 0xe9, 0x3f, 0x41, 0xed, 0x03, 0xb2, 0x9f,
0xd7, 0xce, 0x65, 0xff, 0x7e, 0x0b, 0xff, 0x81, 0x79, 0xf9, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff,
0xc2, 0x6b, 0xe2, 0x2f, 0xf7, 0x08, 0x00, 0x00,
// 1310 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x72, 0x1a, 0x47,
0x10, 0x36, 0x3f, 0x12, 0xd0, 0x2c, 0xcb, 0x6a, 0x64, 0x4b, 0x48, 0x89, 0xcb, 0x78, 0x13, 0x3b,
0x44, 0x07, 0x13, 0xdb, 0xa7, 0xb8, 0x72, 0x21, 0x08, 0x5b, 0xa8, 0x24, 0x41, 0x16, 0xe4, 0x2a,
0xe7, 0xb2, 0x19, 0xc3, 0x48, 0xda, 0x0a, 0x3b, 0xbb, 0xde, 0x19, 0x6c, 0xa9, 0x52, 0xbe, 0xe4,
0x15, 0x72, 0xcb, 0x5b, 0xa4, 0x2a, 0xb7, 0x9c, 0xf2, 0x0c, 0xb9, 0xe7, 0x94, 0x07, 0x49, 0x4d,
0xcf, 0xb0, 0x5a, 0x84, 0x7d, 0xf1, 0x8d, 0xfd, 0xe6, 0x9b, 0x6f, 0xba, 0x7b, 0xbe, 0xee, 0x01,
0xac, 0xc9, 0x2c, 0x60, 0x5c, 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d9, 0x29, 0x95, 0x91, 0x5e, 0x9a, 0x29, 0x6e, 0x13, 0xa5,
0x77, 0x49, 0x63, 0x49, 0xfa, 0x8d, 0xe2, 0xb4, 0x7f, 0xa1, 0xa1, 0x7c, 0x4f, 0x7e, 0x04, 0xfb,
0x05, 0x93, 0xba, 0x72, 0x9f, 0x14, 0xfd, 0x0e, 0x1e, 0xb1, 0x49, 0x36, 0x32, 0xf5, 0x34, 0xc1,
0xff, 0x94, 0xd1, 0xfe, 0xa4, 0xf0, 0xef, 0xa1, 0xf6, 0x0e, 0xd9, 0xce, 0x6a, 0x67, 0xa3, 0x7f,
0x05, 0x35, 0x75, 0xc2, 0x62, 0x88, 0x88, 0x8c, 0x19, 0x96, 0x26, 0xd5, 0xee, 0xf6, 0x0a, 0xbe,
0x6c, 0x30, 0x52, 0xc7, 0x23, 0x04, 0x95, 0x6d, 0x3d, 0x9d, 0x5e, 0xaf, 0xe3, 0x1f, 0xd5, 0xa7,
0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xbc, 0xc2, 0x52, 0x9d, 0xdf, 0x0a, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -931,6 +1133,9 @@ type SwapClientClient interface {
//*
//GetQuote returns a quote for a swap with the provided parameters.
GetLoopInQuote(ctx context.Context, in *QuoteRequest, opts ...grpc.CallOption) (*QuoteResponse, error)
//*
//GetLsatTokens returns all LSAT tokens the daemon ever paid for.
GetLsatTokens(ctx context.Context, in *TokensRequest, opts ...grpc.CallOption) (*TokensResponse, error)
}
type swapClientClient struct {
@ -1027,6 +1232,15 @@ func (c *swapClientClient) GetLoopInQuote(ctx context.Context, in *QuoteRequest,
return out, nil
}
func (c *swapClientClient) GetLsatTokens(ctx context.Context, in *TokensRequest, opts ...grpc.CallOption) (*TokensResponse, error) {
out := new(TokensResponse)
err := c.cc.Invoke(ctx, "/looprpc.SwapClient/GetLsatTokens", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// SwapClientServer is the server API for SwapClient service.
type SwapClientServer interface {
//* loop: `out`
@ -1058,6 +1272,9 @@ type SwapClientServer interface {
//*
//GetQuote returns a quote for a swap with the provided parameters.
GetLoopInQuote(context.Context, *QuoteRequest) (*QuoteResponse, error)
//*
//GetLsatTokens returns all LSAT tokens the daemon ever paid for.
GetLsatTokens(context.Context, *TokensRequest) (*TokensResponse, error)
}
func RegisterSwapClientServer(s *grpc.Server, srv SwapClientServer) {
@ -1193,6 +1410,24 @@ func _SwapClient_GetLoopInQuote_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler)
}
func _SwapClient_GetLsatTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TokensRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SwapClientServer).GetLsatTokens(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/looprpc.SwapClient/GetLsatTokens",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SwapClientServer).GetLsatTokens(ctx, req.(*TokensRequest))
}
return interceptor(ctx, in, info, handler)
}
var _SwapClient_serviceDesc = grpc.ServiceDesc{
ServiceName: "looprpc.SwapClient",
HandlerType: (*SwapClientServer)(nil),
@ -1221,6 +1456,10 @@ var _SwapClient_serviceDesc = grpc.ServiceDesc{
MethodName: "GetLoopInQuote",
Handler: _SwapClient_GetLoopInQuote_Handler,
},
{
MethodName: "GetLsatTokens",
Handler: _SwapClient_GetLsatTokens_Handler,
},
},
Streams: []grpc.StreamDesc{
{

+ 61
- 66
looprpc/client.pb.gw.go View File

@ -9,13 +9,13 @@ It translates gRPC into RESTful JSON APIs.
package looprpc
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
@ -32,7 +32,11 @@ func request_SwapClient_LoopOut_0(ctx context.Context, marshaler runtime.Marshal
var protoReq LoopOutRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@ -45,7 +49,11 @@ func request_SwapClient_LoopIn_0(ctx context.Context, marshaler runtime.Marshale
var protoReq LoopInRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@ -142,6 +150,15 @@ func request_SwapClient_GetLoopInQuote_0(ctx context.Context, marshaler runtime.
}
func request_SwapClient_GetLsatTokens_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq TokensRequest
var metadata runtime.ServerMetadata
msg, err := client.GetLsatTokens(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
// RegisterSwapClientHandlerFromEndpoint is same as RegisterSwapClientHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterSwapClientHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
@ -152,14 +169,14 @@ func RegisterSwapClientHandlerFromEndpoint(ctx context.Context, mux *runtime.Ser
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
@ -170,20 +187,19 @@ func RegisterSwapClientHandlerFromEndpoint(ctx context.Context, mux *runtime.Ser
// RegisterSwapClientHandler registers the http handlers for service SwapClient to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewSwapClientClient(conn)
return RegisterSwapClientHandlerClient(ctx, mux, NewSwapClientClient(conn))
}
// RegisterSwapClientHandlerClient registers the http handlers for service SwapClient
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SwapClientClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SwapClientClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "SwapClientClient" to call the correct interceptors.
func RegisterSwapClientHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SwapClientClient) error {
mux.Handle("POST", pattern_SwapClient_LoopOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@ -202,17 +218,8 @@ func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn
})
mux.Handle("POST", pattern_SwapClient_LoopIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@ -231,17 +238,8 @@ func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn
})
mux.Handle("GET", pattern_SwapClient_LoopOutTerms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@ -260,17 +258,8 @@ func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn
})
mux.Handle("GET", pattern_SwapClient_LoopOutQuote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@ -289,17 +278,8 @@ func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn
})
mux.Handle("GET", pattern_SwapClient_GetLoopInTerms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@ -318,17 +298,8 @@ func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn
})
mux.Handle("GET", pattern_SwapClient_GetLoopInQuote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
@ -346,6 +317,26 @@ func RegisterSwapClientHandler(ctx context.Context, mux *runtime.ServeMux, conn
})
mux.Handle("GET", pattern_SwapClient_GetLsatTokens_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)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_SwapClient_GetLsatTokens_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_SwapClient_GetLsatTokens_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@ -361,6 +352,8 @@ var (
pattern_SwapClient_GetLoopInTerms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "loop", "in", "terms"}, ""))
pattern_SwapClient_GetLoopInQuote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "loop", "in", "quote", "amt"}, ""))
pattern_SwapClient_GetLsatTokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "lsat", "tokens"}, ""))
)
var (
@ -375,4 +368,6 @@ var (
forward_SwapClient_GetLoopInTerms_0 = runtime.ForwardResponseMessage
forward_SwapClient_GetLoopInQuote_0 = runtime.ForwardResponseMessage
forward_SwapClient_GetLsatTokens_0 = runtime.ForwardResponseMessage
)

+ 78
- 14
looprpc/client.proto View File

@ -15,7 +15,7 @@ service SwapClient {
point onwards, progress can be tracked via the SwapStatus stream that is
returned from Monitor().
*/
rpc LoopOut(LoopOutRequest) returns (SwapResponse) {
rpc LoopOut (LoopOutRequest) returns (SwapResponse) {
option (google.api.http) = {
post: "/v1/loop/out"
body: "*"
@ -28,7 +28,7 @@ service SwapClient {
point onwards, progress can be tracked via the SwapStatus stream
that is returned from Monitor().
*/
rpc LoopIn(LoopInRequest) returns (SwapResponse) {
rpc LoopIn (LoopInRequest) returns (SwapResponse) {
option (google.api.http) = {
post: "/v1/loop/in"
body: "*"
@ -39,12 +39,12 @@ service SwapClient {
Monitor will return a stream of swap updates for currently active swaps.
TODO: add MonitorSync version for REST clients.
*/
rpc Monitor(MonitorRequest) returns(stream SwapStatus);
rpc Monitor (MonitorRequest) returns (stream SwapStatus);
/** loop: `terms`
LoopOutTerms returns the terms that the server enforces for a loop out swap.
*/
rpc LoopOutTerms(TermsRequest) returns(TermsResponse) {
rpc LoopOutTerms (TermsRequest) returns (TermsResponse) {
option (google.api.http) = {
get: "/v1/loop/out/terms"
};
@ -54,7 +54,7 @@ service SwapClient {
LoopOutQuote returns a quote for a loop out swap with the provided
parameters.
*/
rpc LoopOutQuote(QuoteRequest) returns(QuoteResponse) {
rpc LoopOutQuote (QuoteRequest) returns (QuoteResponse) {
option (google.api.http) = {
get: "/v1/loop/out/quote/{amt}"
};
@ -63,7 +63,7 @@ service SwapClient {
/**
GetTerms returns the terms that the server enforces for swaps.
*/
rpc GetLoopInTerms(TermsRequest) returns(TermsResponse) {
rpc GetLoopInTerms (TermsRequest) returns (TermsResponse) {
option (google.api.http) = {
get: "/v1/loop/in/terms"
};
@ -72,11 +72,20 @@ service SwapClient {
/**
GetQuote returns a quote for a swap with the provided parameters.
*/
rpc GetLoopInQuote(QuoteRequest) returns(QuoteResponse) {
rpc GetLoopInQuote (QuoteRequest) returns (QuoteResponse) {
option (google.api.http) = {
get: "/v1/loop/in/quote/{amt}"
};
}
/**
GetLsatTokens returns all LSAT tokens the daemon ever paid for.
*/
rpc GetLsatTokens (TokensRequest) returns (TokensResponse) {
option (google.api.http) = {
get: "/v1/lsat/tokens"
};
}
}
message LoopOutRequest {
@ -180,7 +189,7 @@ message LoopInRequest {
max_miner_fee is typically taken from the response of the GetQuote call.
*/
int64 max_miner_fee = 3;
/**
The channel to loop in. If zero, the channel to loop in is selected based
on the lowest routing fee for the swap payment from the server.
@ -209,7 +218,7 @@ message SwapResponse {
string htlc_address = 2;
}
message MonitorRequest{
message MonitorRequest {
}
message SwapStatus {
@ -303,10 +312,10 @@ enum SwapState {
*/
FAILED = 4;
/**
INVOICE_SETTLED is reached when the swap invoice in a loop in swap has been
paid, but we are still waiting for the htlc spend to confirm.
*/
/**
INVOICE_SETTLED is reached when the swap invoice in a loop in swap has been
paid, but we are still waiting for the htlc spend to confirm.
*/
INVOICE_SETTLED = 5;
}
@ -315,7 +324,7 @@ message TermsRequest {
message TermsResponse {
reserved 1,2,3,4,7;
reserved 1, 2, 3, 4, 7;
/**
Minimum swap amount (sat)
@ -376,3 +385,58 @@ message QuoteResponse {
*/
int32 cltv_delta = 5;
}
message TokensRequest {
}
message TokensResponse {
/**
List of all tokens the daemon knows of, including old/expired tokens.
*/
repeated LsatToken tokens = 1;
}
message LsatToken {
/**
The base macaroon that was baked by the auth server.
*/
bytes base_macaroon = 1;
/**
The payment hash of the payment that was paid to obtain the token.
*/
bytes payment_hash = 2;
/**
The preimage of the payment hash, knowledge of this is proof that the
payment has been paid. If the preimage is set to all zeros, this means the
payment is still pending and the token is not yet fully valid.
*/
bytes payment_preimage = 3;
/**
The amount of millisatoshis that was paid to get the token.
*/
int64 amount_paid_msat = 4;
/**
The amount of millisatoshis paid in routing fee to pay for the token.
*/
int64 routing_fee_paid_msat = 5;
/**
The creation time of the token as UNIX timestamp in seconds.
*/
int64 time_created = 6;
/**
Indicates whether the token is expired or still valid.
*/
bool expired = 7;
/**
Identifying attribute of this token in the store. Currently represents the
file name of the token where it's stored on the file system.
*/
string storage_name = 8;
}

+ 132
- 6
looprpc/client.swagger.json View File

@ -21,7 +21,7 @@
"operationId": "LoopIn",
"responses": {
"200": {
"description": "",
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcSwapResponse"
}
@ -48,7 +48,7 @@
"operationId": "GetLoopInQuote",
"responses": {
"200": {
"description": "",
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcQuoteResponse"
}
@ -57,6 +57,7 @@
"parameters": [
{
"name": "amt",
"description": "*\nThe amount to swap in satoshis.",
"in": "path",
"required": true,
"type": "string",
@ -90,7 +91,7 @@
"operationId": "GetLoopInTerms",
"responses": {
"200": {
"description": "",
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcTermsResponse"
}
@ -107,7 +108,7 @@
"operationId": "LoopOut",
"responses": {
"200": {
"description": "",
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcSwapResponse"
}
@ -134,7 +135,7 @@
"operationId": "LoopOutQuote",
"responses": {
"200": {
"description": "",
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcQuoteResponse"
}
@ -143,6 +144,7 @@
"parameters": [
{
"name": "amt",
"description": "*\nThe amount to swap in satoshis.",
"in": "path",
"required": true,
"type": "string",
@ -176,7 +178,7 @@
"operationId": "LoopOutTerms",
"responses": {
"200": {
"description": "",
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcTermsResponse"
}
@ -186,6 +188,23 @@
"SwapClient"
]
}
},
"/v1/lsat/tokens": {
"get": {
"summary": "*\nGetLsatTokens returns all LSAT tokens the daemon ever paid for.",
"operationId": "GetLsatTokens",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/looprpcTokensResponse"
}
}
},
"tags": [
"SwapClient"
]
}
}
},
"definitions": {
@ -273,6 +292,50 @@
}
}
},
"looprpcLsatToken": {
"type": "object",
"properties": {
"base_macaroon": {
"type": "string",
"format": "byte",
"description": "*\nThe base macaroon that was baked by the auth server."
},
"payment_hash": {
"type": "string",
"format": "byte",
"description": "*\nThe payment hash of the payment that was paid to obtain the token."
},
"payment_preimage": {
"type": "string",
"format": "byte",
"description": "*\nThe preimage of the payment hash, knowledge of this is proof that the\npayment has been paid. If the preimage is set to all zeros, this means the\npayment is still pending and the token is not yet fully valid."
},
"amount_paid_msat": {
"type": "string",
"format": "int64",
"description": "*\nThe amount of millisatoshis that was paid to get the token."
},
"routing_fee_paid_msat": {
"type": "string",
"format": "int64",
"description": "*\nThe amount of millisatoshis paid in routing fee to pay for the token."
},
"time_created": {
"type": "string",
"format": "int64",
"description": "*\nThe creation time of the token as UNIX timestamp in seconds."
},
"expired": {
"type": "boolean",
"format": "boolean",
"description": "*\nIndicates whether the token is expired or still valid."
},
"storage_name": {
"type": "string",
"description": "*\nIdentifying attribute of this token in the store. Currently represents the\nfile name of the token where it's stored on the file system."
}
}
},
"looprpcQuoteResponse": {
"type": "object",
"properties": {
@ -403,6 +466,69 @@
"title": "*\nMaximum swap amount (sat)"
}
}
},
"looprpcTokensResponse": {
"type": "object",
"properties": {
"tokens": {
"type": "array",
"items": {
"$ref": "#/definitions/looprpcLsatToken"
},
"description": "*\nList of all tokens the daemon knows of, including old/expired tokens."
}
}
},
"protobufAny": {
"type": "object",
"properties": {
"type_url": {
"type": "string"
},
"value": {
"type": "string",
"format": "byte"
}
}
},
"runtimeStreamError": {
"type": "object",
"properties": {
"grpc_code": {
"type": "integer",
"format": "int32"
},
"http_code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"http_status": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
}
},
"x-stream-definitions": {
"looprpcSwapStatus": {
"type": "object",
"properties": {
"result": {
"$ref": "#/definitions/looprpcSwapStatus"
},
"error": {
"$ref": "#/definitions/runtimeStreamError"
}
},
"title": "Stream result of looprpcSwapStatus"
}
}
}

Loading…
Cancel
Save