diff --git a/cmd/loop/main.go b/cmd/loop/main.go index 90c895b..b2a0d99 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -2,18 +2,18 @@ package main import ( "bytes" - "encoding/json" "errors" "fmt" "os" "strconv" "time" - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" "github.com/lightninglabs/loop" "github.com/lightninglabs/loop/looprpc" "github.com/lightninglabs/loop/swap" + "github.com/lightninglabs/protobuf-hex-display/json" + "github.com/lightninglabs/protobuf-hex-display/jsonpb" + "github.com/lightninglabs/protobuf-hex-display/proto" "github.com/btcsuite/btcutil" @@ -30,6 +30,10 @@ var ( maxRoutingFeeRate = int64(20000) defaultSwapWaitTime = 30 * time.Minute + + // maxMsgRecvSize is the largest message our client will receive. We + // set this to 200MiB atm. + maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200) ) func printJSON(resp interface{}) { @@ -49,6 +53,7 @@ func printJSON(resp interface{}) { func printRespJSON(resp proto.Message) { jsonMarshaler := &jsonpb.Marshaler{ + OrigName: true, EmitDefaults: true, Indent: " ", } @@ -83,6 +88,7 @@ func main() { app.Commands = []cli.Command{ loopOutCommand, loopInCommand, termsCommand, monitorCommand, quoteCommand, listAuthCommand, + listSwapsCommand, swapInfoCommand, } err := app.Run(os.Args) @@ -232,6 +238,7 @@ func logSwap(swap *looprpc.SwapStatus) { func getClientConn(address string) (*grpc.ClientConn, error) { opts := []grpc.DialOption{ grpc.WithInsecure(), + grpc.WithDefaultCallOptions(maxMsgRecvSize), } conn, err := grpc.Dial(address, opts...) diff --git a/cmd/loop/swaps.go b/cmd/loop/swaps.go new file mode 100644 index 0000000..80df2e5 --- /dev/null +++ b/cmd/loop/swaps.go @@ -0,0 +1,92 @@ +package main + +import ( + "context" + "encoding/hex" + "fmt" + + "github.com/lightninglabs/loop/looprpc" + "github.com/lightningnetwork/lnd/lntypes" + "github.com/urfave/cli" +) + +var listSwapsCommand = cli.Command{ + Name: "listswaps", + Usage: "list all swaps in the local database", + Description: "Allows the user to get a list of all swaps that are " + + "currently stored in the database", + Action: listSwaps, +} + +func listSwaps(ctx *cli.Context) error { + client, cleanup, err := getClient(ctx) + if err != nil { + return err + } + defer cleanup() + + resp, err := client.ListSwaps( + context.Background(), &looprpc.ListSwapsRequest{}, + ) + if err != nil { + return err + } + + printRespJSON(resp) + return nil +} + +var swapInfoCommand = cli.Command{ + Name: "swapinfo", + Usage: "show the status of a swap", + ArgsUsage: "id", + Description: "Allows the user to get the status of a single swap " + + "currently stored in the database", + Flags: []cli.Flag{ + cli.Uint64Flag{ + Name: "id", + Usage: "the ID of the swap", + }, + }, + Action: swapInfo, +} + +func swapInfo(ctx *cli.Context) error { + args := ctx.Args() + + var id string + switch { + case ctx.IsSet("id"): + id = ctx.String("id") + case ctx.NArg() > 0: + id = args[0] + args = args.Tail() + default: + // Show command help if no arguments and flags were provided. + return cli.ShowCommandHelp(ctx, "swapinfo") + } + + if len(id) != hex.EncodedLen(lntypes.HashSize) { + return fmt.Errorf("invalid swap ID") + } + idBytes, err := hex.DecodeString(id) + if err != nil { + return fmt.Errorf("cannot hex decode id: %v", err) + } + + client, cleanup, err := getClient(ctx) + if err != nil { + return err + } + defer cleanup() + + resp, err := client.SwapInfo( + context.Background(), &looprpc.SwapInfoRequest{Id: idBytes}, + ) + if err != nil { + return err + } + + printRespJSON(resp) + return nil +} diff --git a/go.mod b/go.mod index 99245de..6694bc4 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/google/go-cmp v0.3.1 // indirect github.com/grpc-ecosystem/grpc-gateway v1.10.0 github.com/jessevdk/go-flags v1.4.0 + github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d github.com/lightningnetwork/lnd v0.9.0-beta-rc3.0.20200121213302-a2977c4438b5 github.com/lightningnetwork/lnd/queue v1.0.2 github.com/urfave/cli v1.20.0 diff --git a/go.sum b/go.sum index c4cfafb..fa1cc6a 100644 --- a/go.sum +++ b/go.sum @@ -136,6 +136,7 @@ github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk= github.com/lightninglabs/neutrino v0.11.0 h1:lPpYFCtsfJX2W5zI4pWycPmbbBdr7zU+BafYdLoD6k0= github.com/lightninglabs/neutrino v0.11.0/go.mod h1:CuhF0iuzg9Sp2HO6ZgXgayviFTn1QHdSTJlMncK80wg= +github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d h1:QWD/5MPnaZfUVP7P8wLa4M8Td2DI7XXHXt2vhVtUgGI= github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d/go.mod h1:KDb67YMzoh4eudnzClmvs2FbiLG9vxISmLApUkCa4uI= github.com/lightningnetwork/lightning-onion v1.0.1 h1:qChGgS5+aPxFeR6JiUsGvanei1bn6WJpYbvosw/1604= github.com/lightningnetwork/lightning-onion v1.0.1/go.mod h1:rigfi6Af/KqsF7Za0hOgcyq2PNH4AN70AaMRxcJkff4= diff --git a/loopd/daemon.go b/loopd/daemon.go index 4989579..358841e 100644 --- a/loopd/daemon.go +++ b/loopd/daemon.go @@ -16,9 +16,16 @@ import ( "github.com/lightninglabs/loop" "github.com/lightninglabs/loop/lndclient" "github.com/lightninglabs/loop/looprpc" + "github.com/lightningnetwork/lnd/lntypes" "google.golang.org/grpc" ) +var ( + // maxMsgRecvSize is the largest message our REST proxy will receive. We + // set this to 200MiB atm. + maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200) +) + // listenerCfg holds closures used to retrieve listeners for the gRPC services. type listenerCfg struct { // grpcListener returns a listener to use for the gRPC server. @@ -68,14 +75,18 @@ func daemon(config *config, lisCfg *listenerCfg) error { return err } + swaps := make(map[lntypes.Hash]loop.SwapInfo) for _, s := range swapsList { swaps[s.SwapHash] = *s } // Instantiate the loopd gRPC server. server := swapClientServer{ - impl: swapClient, - lnd: &lnd.LndServices, + impl: swapClient, + lnd: &lnd.LndServices, + swaps: swaps, + subscribers: make(map[int]chan<- interface{}), + statusChan: make(chan loop.SwapInfo), } serverOpts := []grpc.ServerOption{} @@ -92,12 +103,26 @@ func daemon(config *config, lisCfg *listenerCfg) error { } defer grpcListener.Close() + // The default JSON marshaler of the REST proxy only sets OrigName to + // true, which instructs it to use the same field names as specified in + // the proto file and not switch to camel case. What we also want is + // that the marshaler prints all values, even if they are falsey. + customMarshalerOption := proxy.WithMarshalerOption( + proxy.MIMEWildcard, &proxy.JSONPb{ + OrigName: true, + EmitDefaults: true, + }, + ) + // We'll also create and start an accompanying proxy to serve clients // through REST. ctx, cancel := context.WithCancel(context.Background()) defer cancel() - mux := proxy.NewServeMux() - proxyOpts := []grpc.DialOption{grpc.WithInsecure()} + mux := proxy.NewServeMux(customMarshalerOption) + proxyOpts := []grpc.DialOption{ + grpc.WithInsecure(), + grpc.WithDefaultCallOptions(maxMsgRecvSize), + } err = looprpc.RegisterSwapClientHandlerFromEndpoint( ctx, mux, config.RPCListen, proxyOpts, ) @@ -130,8 +155,6 @@ func daemon(config *config, lisCfg *listenerCfg) error { log.Infof("REST proxy disabled") } - statusChan := make(chan loop.SwapInfo) - mainCtx, cancel := context.WithCancel(context.Background()) var wg sync.WaitGroup @@ -141,7 +164,7 @@ func daemon(config *config, lisCfg *listenerCfg) error { defer wg.Done() log.Infof("Starting swap client") - err := swapClient.Run(mainCtx, statusChan) + err := swapClient.Run(mainCtx, server.statusChan) if err != nil { log.Error(err) } @@ -159,25 +182,7 @@ func daemon(config *config, lisCfg *listenerCfg) error { defer wg.Done() log.Infof("Waiting for updates") - for { - select { - case swap := <-statusChan: - swapsLock.Lock() - swaps[swap.SwapHash] = swap - - for _, subscriber := range subscribers { - select { - case subscriber <- swap: - case <-mainCtx.Done(): - return - } - } - - swapsLock.Unlock() - case <-mainCtx.Done(): - return - } - } + server.processStatusUpdates(mainCtx) }() // Start the grpc server. diff --git a/loopd/start.go b/loopd/start.go index 321ed5c..1acc1ae 100644 --- a/loopd/start.go +++ b/loopd/start.go @@ -7,26 +7,16 @@ import ( "os" "path/filepath" "strings" - "sync" "github.com/jessevdk/go-flags" "github.com/lightninglabs/loop" "github.com/lightninglabs/loop/lndclient" "github.com/lightningnetwork/lnd/build" - "github.com/lightningnetwork/lnd/lntypes" ) const ( - defaultConfTarget = int32(6) -) - -var ( + defaultConfTarget = int32(6) defaultConfigFilename = "loopd.conf" - - swaps = make(map[lntypes.Hash]loop.SwapInfo) - subscribers = make(map[int]chan<- interface{}) - nextSubscriberID int - swapsLock sync.Mutex ) // RPCConfig holds optional options that can be used to make the loop daemon diff --git a/loopd/swapclient_server.go b/loopd/swapclient_server.go index 4f704ab..cd19b05 100644 --- a/loopd/swapclient_server.go +++ b/loopd/swapclient_server.go @@ -5,8 +5,10 @@ import ( "errors" "fmt" "sort" + "sync" "time" + "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/queue" "github.com/lightninglabs/loop" @@ -29,8 +31,13 @@ const ( // swapClientServer implements the grpc service exposed by loopd. type swapClientServer struct { - impl *loop.Client - lnd *lndclient.LndServices + impl *loop.Client + lnd *lndclient.LndServices + swaps map[lntypes.Hash]loop.SwapInfo + subscribers map[int]chan<- interface{} + statusChan chan loop.SwapInfo + nextSubscriberID int + swapsLock sync.Mutex } // LoopOut initiates an loop out swap with the given parameters. The call @@ -92,6 +99,7 @@ func (s *swapClientServer) LoopOut(ctx context.Context, return &looprpc.SwapResponse{ Id: hash.String(), + IdBytes: hash[:], HtlcAddress: htlc.String(), }, nil } @@ -129,6 +137,7 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) ( return &looprpc.SwapStatus{ Amt: int64(loopSwap.AmountRequested), Id: loopSwap.SwapHash.String(), + IdBytes: loopSwap.SwapHash[:], State: state, InitiationTime: loopSwap.InitiationTime.UnixNano(), LastUpdateTime: loopSwap.LastUpdate.UnixNano(), @@ -162,14 +171,14 @@ func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest, // Add this subscriber to the global subscriber list. Also create a // snapshot of all pending and completed swaps within the lock, to // prevent subscribers from receiving duplicate updates. - swapsLock.Lock() + s.swapsLock.Lock() - id := nextSubscriberID - nextSubscriberID++ - subscribers[id] = queue.ChanIn() + id := s.nextSubscriberID + s.nextSubscriberID++ + s.subscribers[id] = queue.ChanIn() var pendingSwaps, completedSwaps []loop.SwapInfo - for _, swap := range swaps { + for _, swap := range s.swaps { if swap.State.Type() == loopdb.StateTypePending { pendingSwaps = append(pendingSwaps, swap) } else { @@ -177,13 +186,13 @@ func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest, } } - swapsLock.Unlock() + s.swapsLock.Unlock() defer func() { queue.Stop() - swapsLock.Lock() - delete(subscribers, id) - swapsLock.Unlock() + s.swapsLock.Lock() + delete(s.subscribers, id) + s.swapsLock.Unlock() }() // Sort completed swaps new to old. @@ -234,6 +243,50 @@ func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest, } } +// ListSwaps returns a list of all currently known swaps and their current +// status. +func (s *swapClientServer) ListSwaps(_ context.Context, + _ *looprpc.ListSwapsRequest) (*looprpc.ListSwapsResponse, error) { + + var ( + rpcSwaps = make([]*looprpc.SwapStatus, len(s.swaps)) + idx = 0 + err error + ) + + // We can just use the server's in-memory cache as that contains the + // most up-to-date state including temporary failures which aren't + // persisted to disk. The swaps field is a map, that's why we need an + // additional index. + for _, swp := range s.swaps { + swp := swp + rpcSwaps[idx], err = s.marshallSwap(&swp) + if err != nil { + return nil, err + } + idx++ + } + return &looprpc.ListSwapsResponse{Swaps: rpcSwaps}, nil +} + +// SwapInfo returns all known details about a single swap. +func (s *swapClientServer) SwapInfo(_ context.Context, + req *looprpc.SwapInfoRequest) (*looprpc.SwapStatus, error) { + + swapHash, err := lntypes.MakeHash(req.Id) + if err != nil { + return nil, fmt.Errorf("error parsing swap hash: %v", err) + } + + // Just return the server's in-memory cache here too as we also want to + // return temporary failures to the client. + swp, ok := s.swaps[swapHash] + if !ok { + return nil, fmt.Errorf("swap with hash %s not found", req.Id) + } + return s.marshallSwap(&swp) +} + // LoopOutTerms returns the terms that the server enforces for loop out swaps. func (s *swapClientServer) LoopOutTerms(ctx context.Context, req *looprpc.TermsRequest) (*looprpc.TermsResponse, error) { @@ -345,6 +398,7 @@ func (s *swapClientServer) LoopIn(ctx context.Context, return &looprpc.SwapResponse{ Id: hash.String(), + IdBytes: hash[:], HtlcAddress: htlc.String(), }, nil } @@ -383,6 +437,36 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context, return &looprpc.TokensResponse{Tokens: rpcTokens}, nil } +// processStatusUpdates reads updates on the status channel and processes them. +// +// NOTE: This must run inside a goroutine as it blocks until the main context +// shuts down. +func (s *swapClientServer) processStatusUpdates(mainCtx context.Context) { + for { + select { + // On updates, refresh the server's in-memory state and inform + // subscribers about the changes. + case swp := <-s.statusChan: + s.swapsLock.Lock() + s.swaps[swp.SwapHash] = swp + + for _, subscriber := range s.subscribers { + select { + case subscriber <- swp: + case <-mainCtx.Done(): + return + } + } + + s.swapsLock.Unlock() + + // Server is shutting down. + case <-mainCtx.Done(): + return + } + } +} + // 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) { diff --git a/looprpc/client.pb.go b/looprpc/client.pb.go index 6898c86..4b240c6 100644 --- a/looprpc/client.pb.go +++ b/looprpc/client.pb.go @@ -363,7 +363,13 @@ type SwapResponse struct { //* //Swap identifier to track status in the update stream that is returned from //the Start() call. Currently this is the hash that locks the htlcs. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + //DEPRECATED: To make the API more consistent, this field is deprecated in + //favor of id_bytes and will be removed in a future release. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Deprecated: Do not use. + //* + //Swap identifier to track status in the update stream that is returned from + //the Start() call. Currently this is the hash that locks the htlcs. + IdBytes []byte `protobuf:"bytes,3,opt,name=id_bytes,json=idBytes,proto3" json:"id_bytes,omitempty"` //* //The address of the on-chain htlc. HtlcAddress string `protobuf:"bytes,2,opt,name=htlc_address,json=htlcAddress,proto3" json:"htlc_address,omitempty"` @@ -397,6 +403,7 @@ func (m *SwapResponse) XXX_DiscardUnknown() { var xxx_messageInfo_SwapResponse proto.InternalMessageInfo +// Deprecated: Do not use. func (m *SwapResponse) GetId() string { if m != nil { return m.Id @@ -404,6 +411,13 @@ func (m *SwapResponse) GetId() string { return "" } +func (m *SwapResponse) GetIdBytes() []byte { + if m != nil { + return m.IdBytes + } + return nil +} + func (m *SwapResponse) GetHtlcAddress() string { if m != nil { return m.HtlcAddress @@ -450,7 +464,13 @@ type SwapStatus struct { //* //Swap identifier to track status in the update stream that is returned from //the Start() call. Currently this is the hash that locks the htlcs. - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + //DEPRECATED: To make the API more consistent, this field is deprecated in + //favor of id_bytes and will be removed in a future release. + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` // Deprecated: Do not use. + //* + //Swap identifier to track status in the update stream that is returned from + //the Start() call. Currently this is the hash that locks the htlcs. + IdBytes []byte `protobuf:"bytes,11,opt,name=id_bytes,json=idBytes,proto3" json:"id_bytes,omitempty"` //* //Swap type Type SwapType `protobuf:"varint,3,opt,name=type,proto3,enum=looprpc.SwapType" json:"type,omitempty"` @@ -509,6 +529,7 @@ func (m *SwapStatus) GetAmt() int64 { return 0 } +// Deprecated: Do not use. func (m *SwapStatus) GetId() string { if m != nil { return m.Id @@ -516,6 +537,13 @@ func (m *SwapStatus) GetId() string { return "" } +func (m *SwapStatus) GetIdBytes() []byte { + if m != nil { + return m.IdBytes + } + return nil +} + func (m *SwapStatus) GetType() SwapType { if m != nil { return m.Type @@ -572,6 +600,120 @@ func (m *SwapStatus) GetCostOffchain() int64 { return 0 } +type ListSwapsRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListSwapsRequest) Reset() { *m = ListSwapsRequest{} } +func (m *ListSwapsRequest) String() string { return proto.CompactTextString(m) } +func (*ListSwapsRequest) ProtoMessage() {} +func (*ListSwapsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_014de31d7ac8c57c, []int{5} +} + +func (m *ListSwapsRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListSwapsRequest.Unmarshal(m, b) +} +func (m *ListSwapsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListSwapsRequest.Marshal(b, m, deterministic) +} +func (m *ListSwapsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListSwapsRequest.Merge(m, src) +} +func (m *ListSwapsRequest) XXX_Size() int { + return xxx_messageInfo_ListSwapsRequest.Size(m) +} +func (m *ListSwapsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListSwapsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListSwapsRequest proto.InternalMessageInfo + +type ListSwapsResponse struct { + //* + //The list of all currently known swaps and their status. + Swaps []*SwapStatus `protobuf:"bytes,1,rep,name=swaps,proto3" json:"swaps,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListSwapsResponse) Reset() { *m = ListSwapsResponse{} } +func (m *ListSwapsResponse) String() string { return proto.CompactTextString(m) } +func (*ListSwapsResponse) ProtoMessage() {} +func (*ListSwapsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_014de31d7ac8c57c, []int{6} +} + +func (m *ListSwapsResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListSwapsResponse.Unmarshal(m, b) +} +func (m *ListSwapsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListSwapsResponse.Marshal(b, m, deterministic) +} +func (m *ListSwapsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListSwapsResponse.Merge(m, src) +} +func (m *ListSwapsResponse) XXX_Size() int { + return xxx_messageInfo_ListSwapsResponse.Size(m) +} +func (m *ListSwapsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListSwapsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListSwapsResponse proto.InternalMessageInfo + +func (m *ListSwapsResponse) GetSwaps() []*SwapStatus { + if m != nil { + return m.Swaps + } + return nil +} + +type SwapInfoRequest struct { + //* + //The swap identifier which currently is the hash that locks the HTLCs. When + //using REST, this field must be encoded as base64. + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SwapInfoRequest) Reset() { *m = SwapInfoRequest{} } +func (m *SwapInfoRequest) String() string { return proto.CompactTextString(m) } +func (*SwapInfoRequest) ProtoMessage() {} +func (*SwapInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_014de31d7ac8c57c, []int{7} +} + +func (m *SwapInfoRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SwapInfoRequest.Unmarshal(m, b) +} +func (m *SwapInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SwapInfoRequest.Marshal(b, m, deterministic) +} +func (m *SwapInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapInfoRequest.Merge(m, src) +} +func (m *SwapInfoRequest) XXX_Size() int { + return xxx_messageInfo_SwapInfoRequest.Size(m) +} +func (m *SwapInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SwapInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SwapInfoRequest proto.InternalMessageInfo + +func (m *SwapInfoRequest) GetId() []byte { + if m != nil { + return m.Id + } + return nil +} + type TermsRequest struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -582,7 +724,7 @@ func (m *TermsRequest) Reset() { *m = TermsRequest{} } func (m *TermsRequest) String() string { return proto.CompactTextString(m) } func (*TermsRequest) ProtoMessage() {} func (*TermsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{5} + return fileDescriptor_014de31d7ac8c57c, []int{8} } func (m *TermsRequest) XXX_Unmarshal(b []byte) error { @@ -619,7 +761,7 @@ func (m *TermsResponse) Reset() { *m = TermsResponse{} } func (m *TermsResponse) String() string { return proto.CompactTextString(m) } func (*TermsResponse) ProtoMessage() {} func (*TermsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{6} + return fileDescriptor_014de31d7ac8c57c, []int{9} } func (m *TermsResponse) XXX_Unmarshal(b []byte) error { @@ -684,7 +826,7 @@ func (m *QuoteRequest) Reset() { *m = QuoteRequest{} } func (m *QuoteRequest) String() string { return proto.CompactTextString(m) } func (*QuoteRequest) ProtoMessage() {} func (*QuoteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{7} + return fileDescriptor_014de31d7ac8c57c, []int{10} } func (m *QuoteRequest) XXX_Unmarshal(b []byte) error { @@ -759,7 +901,7 @@ func (m *QuoteResponse) Reset() { *m = QuoteResponse{} } func (m *QuoteResponse) String() string { return proto.CompactTextString(m) } func (*QuoteResponse) ProtoMessage() {} func (*QuoteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_014de31d7ac8c57c, []int{8} + return fileDescriptor_014de31d7ac8c57c, []int{11} } func (m *QuoteResponse) XXX_Unmarshal(b []byte) error { @@ -825,7 +967,7 @@ 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} + return fileDescriptor_014de31d7ac8c57c, []int{12} } func (m *TokensRequest) XXX_Unmarshal(b []byte) error { @@ -859,7 +1001,7 @@ 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} + return fileDescriptor_014de31d7ac8c57c, []int{13} } func (m *TokensResponse) XXX_Unmarshal(b []byte) error { @@ -924,7 +1066,7 @@ 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} + return fileDescriptor_014de31d7ac8c57c, []int{14} } func (m *LsatToken) XXX_Unmarshal(b []byte) error { @@ -1009,6 +1151,9 @@ func init() { proto.RegisterType((*SwapResponse)(nil), "looprpc.SwapResponse") proto.RegisterType((*MonitorRequest)(nil), "looprpc.MonitorRequest") proto.RegisterType((*SwapStatus)(nil), "looprpc.SwapStatus") + proto.RegisterType((*ListSwapsRequest)(nil), "looprpc.ListSwapsRequest") + proto.RegisterType((*ListSwapsResponse)(nil), "looprpc.ListSwapsResponse") + proto.RegisterType((*SwapInfoRequest)(nil), "looprpc.SwapInfoRequest") proto.RegisterType((*TermsRequest)(nil), "looprpc.TermsRequest") proto.RegisterType((*TermsResponse)(nil), "looprpc.TermsResponse") proto.RegisterType((*QuoteRequest)(nil), "looprpc.QuoteRequest") @@ -1021,90 +1166,98 @@ func init() { func init() { proto.RegisterFile("client.proto", fileDescriptor_014de31d7ac8c57c) } var fileDescriptor_014de31d7ac8c57c = []byte{ - // 1322 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x72, 0x1a, 0xc7, - 0x16, 0xf6, 0xc0, 0x20, 0xe0, 0x30, 0x0c, 0xa3, 0x96, 0x2d, 0x21, 0xee, 0x75, 0x19, 0xcf, 0xbd, - 0x76, 0x88, 0x16, 0x26, 0xb6, 0x57, 0x71, 0x65, 0x43, 0x10, 0xb6, 0x50, 0x49, 0x82, 0x0c, 0xc8, - 0x55, 0xce, 0x66, 0xd2, 0x86, 0x96, 0x34, 0x15, 0xa6, 0x67, 0x3c, 0xdd, 0xd8, 0x52, 0xa5, 0xbc, - 0xc9, 0x2b, 0x64, 0x97, 0x65, 0xde, 0x20, 0x55, 0xd9, 0x65, 0x95, 0x67, 0xc8, 0x3e, 0xab, 0x3c, - 0x48, 0xaa, 0x7f, 0x66, 0x34, 0x88, 0xd8, 0x0b, 0xef, 0xe0, 0xeb, 0xaf, 0xbf, 0x3e, 0xe7, 0xf4, - 0x77, 0x4e, 0x0f, 0x58, 0xb3, 0x45, 0x40, 0x28, 0x7f, 0x14, 0x27, 0x11, 0x8f, 0x50, 0x79, 0x11, - 0x45, 0x71, 0x12, 0xcf, 0x5a, 0xff, 0x3d, 0x8f, 0xa2, 0xf3, 0x05, 0xe9, 0xe2, 0x38, 0xe8, 0x62, - 0x4a, 0x23, 0x8e, 0x79, 0x10, 0x51, 0xa6, 0x68, 0xee, 0xcf, 0x45, 0xb0, 0x8f, 0xa2, 0x28, 0x1e, - 0x2d, 0xb9, 0x47, 0xde, 0x2c, 0x09, 0xe3, 0xc8, 0x81, 0x22, 0x0e, 0x79, 0xd3, 0x68, 0x1b, 0x9d, - 0xa2, 0x27, 0x7e, 0x22, 0x04, 0xe6, 0x9c, 0x30, 0xde, 0x2c, 0xb4, 0x8d, 0x4e, 0xd5, 0x93, 0xbf, - 0x51, 0x17, 0x6e, 0x87, 0xf8, 0xd2, 0x67, 0xef, 0x70, 0xec, 0x27, 0xd1, 0x92, 0x07, 0xf4, 0xdc, - 0x3f, 0x23, 0xa4, 0x59, 0x94, 0xdb, 0x36, 0x43, 0x7c, 0x39, 0x79, 0x87, 0x63, 0x4f, 0xad, 0x3c, - 0x27, 0x04, 0x3d, 0x85, 0x6d, 0xb1, 0x21, 0x4e, 0x48, 0x8c, 0xaf, 0x56, 0xb6, 0x98, 0x72, 0xcb, - 0x56, 0x88, 0x2f, 0xc7, 0x72, 0x31, 0xb7, 0xa9, 0x0d, 0x56, 0x76, 0x8a, 0xa0, 0x96, 0x24, 0x15, - 0xb4, 0xba, 0x60, 0xfc, 0x1f, 0xec, 0x9c, 0xac, 0x08, 0x7c, 0x43, 0x72, 0xac, 0x4c, 0xae, 0x17, - 0x72, 0xe4, 0x42, 0x5d, 0xb0, 0xc2, 0x80, 0x92, 0x44, 0x0a, 0x95, 0x25, 0xa9, 0x16, 0xe2, 0xcb, - 0x63, 0x81, 0x09, 0xa5, 0x0e, 0x38, 0xa2, 0x66, 0x7e, 0xb4, 0xe4, 0xfe, 0xec, 0x02, 0x53, 0x4a, - 0x16, 0xcd, 0x4a, 0xdb, 0xe8, 0x98, 0x9e, 0xbd, 0x50, 0x15, 0xea, 0x2b, 0x14, 0xed, 0xc1, 0x26, - 0x7b, 0x47, 0x48, 0xec, 0xcf, 0x22, 0x7a, 0xe6, 0x73, 0x9c, 0x9c, 0x13, 0xde, 0xac, 0xb6, 0x8d, - 0x4e, 0xc9, 0x6b, 0xc8, 0x85, 0x7e, 0x44, 0xcf, 0xa6, 0x12, 0x46, 0xcf, 0x60, 0x57, 0x46, 0x1f, - 0x2f, 0x5f, 0x2f, 0x82, 0x99, 0xac, 0xbd, 0x3f, 0x27, 0x78, 0xbe, 0x08, 0x28, 0x69, 0x82, 0x94, - 0xdf, 0x11, 0x84, 0xf1, 0xf5, 0xfa, 0xbe, 0x5e, 0x76, 0x7f, 0x33, 0xa0, 0x2e, 0x2e, 0x67, 0x48, - 0x3f, 0x7c, 0x37, 0x37, 0x2b, 0x54, 0x58, 0xab, 0xd0, 0x5a, 0xee, 0xc5, 0xf5, 0xdc, 0x1f, 0x42, - 0x43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 0xbc, 0xab, 0xa6, 0xd3, 0xeb, 0x0d, 0xf9, 0x95, 0xfb, 0xf4, 0x9f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x55, 0xbe, 0xbc, 0x0e, 0x1c, 0x0b, 0x00, 0x00, + // 1446 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4d, 0x6e, 0xdb, 0x46, + 0x18, 0x0d, 0x25, 0xda, 0x92, 0x3e, 0x51, 0x14, 0x3d, 0x4e, 0x6c, 0x59, 0x6d, 0x10, 0x87, 0x6d, + 0x52, 0xc7, 0x8b, 0xa8, 0x71, 0x76, 0x41, 0x51, 0xc0, 0x91, 0x95, 0x58, 0x86, 0x7f, 0x54, 0x4a, + 0x0e, 0x90, 0x6c, 0x98, 0xb1, 0x38, 0xb6, 0x89, 0x8a, 0x1c, 0x86, 0x33, 0x4a, 0x6c, 0x04, 0xd9, + 0xf4, 0x00, 0xdd, 0x74, 0xd7, 0x65, 0x6f, 0x50, 0xa0, 0xbb, 0x1e, 0xa3, 0x57, 0xe8, 0x35, 0x0a, + 0x14, 0xf3, 0x23, 0x8a, 0xb2, 0xec, 0x2c, 0xb2, 0x33, 0xdf, 0xbc, 0x79, 0xf3, 0xcd, 0x37, 0x6f, + 0xde, 0xc8, 0x60, 0x0d, 0x47, 0x21, 0x89, 0xf9, 0xe3, 0x24, 0xa5, 0x9c, 0xa2, 0xd2, 0x88, 0xd2, + 0x24, 0x4d, 0x86, 0xcd, 0xaf, 0xcf, 0x28, 0x3d, 0x1b, 0x91, 0x16, 0x4e, 0xc2, 0x16, 0x8e, 0x63, + 0xca, 0x31, 0x0f, 0x69, 0xcc, 0x14, 0xcd, 0xfd, 0xbd, 0x08, 0xf6, 0x3e, 0xa5, 0xc9, 0xd1, 0x98, + 0x7b, 0xe4, 0xdd, 0x98, 0x30, 0x8e, 0x1c, 0x28, 0xe2, 0x88, 0x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, 0xac, 0x6f, 0xd3, 0x63, 0xb1, 0xc6, 0xe0, 0x32, + 0x21, 0x9e, 0x1c, 0x46, 0x1b, 0xb0, 0xc0, 0x38, 0xe6, 0xca, 0xc3, 0xf6, 0x16, 0x9a, 0xe1, 0x89, + 0x5a, 0x88, 0xa7, 0x08, 0xe8, 0x3b, 0xa8, 0x87, 0x71, 0xc8, 0x43, 0xe5, 0x00, 0x1e, 0x46, 0x13, + 0x33, 0xdb, 0x53, 0x78, 0x10, 0x46, 0xca, 0x86, 0x98, 0x71, 0x7f, 0x9c, 0x04, 0x98, 0x13, 0xc5, + 0x54, 0x96, 0xb6, 0x05, 0x7e, 0x2c, 0x61, 0xc9, 0xbc, 0xda, 0xa8, 0xd2, 0x5c, 0xa3, 0xd0, 0x3d, + 0xa8, 0x0e, 0x29, 0xe3, 0x3e, 0x23, 0xe9, 0x7b, 0x92, 0x4a, 0x3b, 0x17, 0x3d, 0x10, 0x50, 0x5f, + 0x22, 0x42, 0x43, 0x12, 0x68, 0x3c, 0x3c, 0xc7, 0x61, 0x2c, 0x5d, 0x5c, 0xf4, 0xe4, 0xa4, 0x23, + 0x05, 0x89, 0x33, 0x57, 0x94, 0xd3, 0x53, 0xc5, 0x01, 0x75, 0xc1, 0x24, 0x47, 0x63, 0x2e, 0x02, + 0x67, 0x3f, 0x64, 0x5c, 0x6c, 0x9b, 0x4d, 0xce, 0xe4, 0x47, 0x58, 0xca, 0x61, 0xda, 0x0c, 0x8f, + 0x60, 0x41, 0x78, 0x95, 0x35, 0x8c, 0xf5, 0xe2, 0x46, 0x75, 0x6b, 0x79, 0xae, 0x63, 0x63, 0xe6, + 0x29, 0x86, 0x7b, 0x1f, 0xea, 0x02, 0xec, 0xc6, 0xa7, 0x74, 0xe2, 0x7f, 0x3b, 0xb3, 0x92, 0x25, + 0x4e, 0xd0, 0xb5, 0xc1, 0x1a, 0x90, 0x34, 0xca, 0x96, 0xfc, 0x04, 0x35, 0xfd, 0xad, 0x97, 0x7b, + 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26, 0x36, 0x61, 0x91, 0x4b, 0x44, 0x3b, 0x6b, 0x7a, + 0x17, 0xf7, 0x19, 0xe6, 0x92, 0xec, 0x69, 0x86, 0xfb, 0x77, 0x01, 0x2a, 0x19, 0x2a, 0x3a, 0x7e, + 0x82, 0x19, 0xf1, 0x23, 0x3c, 0xc4, 0x29, 0xa5, 0xb1, 0xf6, 0x97, 0x25, 0xc0, 0x03, 0x8d, 0x89, + 0x8b, 0x32, 0xd9, 0xc7, 0x39, 0x66, 0xe7, 0xb2, 0x15, 0x96, 0x57, 0xd5, 0xd8, 0x2e, 0x66, 0xe7, + 0xe8, 0x11, 0x38, 0x13, 0x4a, 0x92, 0x92, 0x30, 0xc2, 0x67, 0x44, 0x67, 0x5b, 0x5d, 0xe3, 0x3d, + 0x0d, 0x8b, 0x4b, 0xae, 0x5c, 0xe6, 0x27, 0x38, 0x0c, 0xfc, 0x88, 0x61, 0xae, 0x9f, 0x41, 0x5b, + 0xe1, 0x3d, 0x1c, 0x06, 0x07, 0x0c, 0x73, 0xf4, 0x04, 0xee, 0xe4, 0xde, 0xca, 0x1c, 0x5d, 0xd9, + 0x18, 0xa5, 0xd9, 0x63, 0x99, 0x4d, 0xb9, 0x0f, 0x96, 0x48, 0x0d, 0x7f, 0x98, 0x12, 0xcc, 0x49, + 0xa0, 0x8d, 0x5c, 0x15, 0x58, 0x5b, 0x41, 0xa8, 0x01, 0x25, 0x72, 0x91, 0x84, 0x29, 0x09, 0x64, + 0x6a, 0x94, 0xbd, 0xc9, 0xa7, 0x98, 0xcc, 0x38, 0x4d, 0xf1, 0x19, 0xf1, 0x63, 0x1c, 0x11, 0x19, + 0x19, 0x15, 0xaf, 0xaa, 0xb1, 0x43, 0x1c, 0x91, 0xcd, 0x07, 0x50, 0x9e, 0xc4, 0x20, 0xb2, 0xa0, + 0xbc, 0x7f, 0x74, 0xd4, 0xf3, 0x8f, 0x8e, 0x07, 0xce, 0x2d, 0x54, 0x85, 0x92, 0xfc, 0xea, 0x1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00, 0xff, 0xff, 0x04, 0xc2, + 0xbc, 0x71, 0x9e, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1133,8 +1286,14 @@ type SwapClientClient interface { LoopIn(ctx context.Context, in *LoopInRequest, opts ...grpc.CallOption) (*SwapResponse, error) //* loop: `monitor` //Monitor will return a stream of swap updates for currently active swaps. - //TODO: add MonitorSync version for REST clients. Monitor(ctx context.Context, in *MonitorRequest, opts ...grpc.CallOption) (SwapClient_MonitorClient, error) + //* + //ListSwaps returns a list of all currently known swaps and their current + //status. + ListSwaps(ctx context.Context, in *ListSwapsRequest, opts ...grpc.CallOption) (*ListSwapsResponse, error) + //* + //SwapInfo returns all known details about a single swap. + SwapInfo(ctx context.Context, in *SwapInfoRequest, opts ...grpc.CallOption) (*SwapStatus, error) //* loop: `terms` //LoopOutTerms returns the terms that the server enforces for a loop out swap. LoopOutTerms(ctx context.Context, in *TermsRequest, opts ...grpc.CallOption) (*TermsResponse, error) @@ -1211,6 +1370,24 @@ func (x *swapClientMonitorClient) Recv() (*SwapStatus, error) { return m, nil } +func (c *swapClientClient) ListSwaps(ctx context.Context, in *ListSwapsRequest, opts ...grpc.CallOption) (*ListSwapsResponse, error) { + out := new(ListSwapsResponse) + err := c.cc.Invoke(ctx, "/looprpc.SwapClient/ListSwaps", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *swapClientClient) SwapInfo(ctx context.Context, in *SwapInfoRequest, opts ...grpc.CallOption) (*SwapStatus, error) { + out := new(SwapStatus) + err := c.cc.Invoke(ctx, "/looprpc.SwapClient/SwapInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *swapClientClient) LoopOutTerms(ctx context.Context, in *TermsRequest, opts ...grpc.CallOption) (*TermsResponse, error) { out := new(TermsResponse) err := c.cc.Invoke(ctx, "/looprpc.SwapClient/LoopOutTerms", in, out, opts...) @@ -1272,8 +1449,14 @@ type SwapClientServer interface { LoopIn(context.Context, *LoopInRequest) (*SwapResponse, error) //* loop: `monitor` //Monitor will return a stream of swap updates for currently active swaps. - //TODO: add MonitorSync version for REST clients. Monitor(*MonitorRequest, SwapClient_MonitorServer) error + //* + //ListSwaps returns a list of all currently known swaps and their current + //status. + ListSwaps(context.Context, *ListSwapsRequest) (*ListSwapsResponse, error) + //* + //SwapInfo returns all known details about a single swap. + SwapInfo(context.Context, *SwapInfoRequest) (*SwapStatus, error) //* loop: `terms` //LoopOutTerms returns the terms that the server enforces for a loop out swap. LoopOutTerms(context.Context, *TermsRequest) (*TermsResponse, error) @@ -1353,6 +1536,42 @@ func (x *swapClientMonitorServer) Send(m *SwapStatus) error { return x.ServerStream.SendMsg(m) } +func _SwapClient_ListSwaps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListSwapsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwapClientServer).ListSwaps(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/looprpc.SwapClient/ListSwaps", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwapClientServer).ListSwaps(ctx, req.(*ListSwapsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SwapClient_SwapInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SwapInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SwapClientServer).SwapInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/looprpc.SwapClient/SwapInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SwapClientServer).SwapInfo(ctx, req.(*SwapInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _SwapClient_LoopOutTerms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(TermsRequest) if err := dec(in); err != nil { @@ -1455,6 +1674,14 @@ var _SwapClient_serviceDesc = grpc.ServiceDesc{ MethodName: "LoopIn", Handler: _SwapClient_LoopIn_Handler, }, + { + MethodName: "ListSwaps", + Handler: _SwapClient_ListSwaps_Handler, + }, + { + MethodName: "SwapInfo", + Handler: _SwapClient_SwapInfo_Handler, + }, { MethodName: "LoopOutTerms", Handler: _SwapClient_LoopOutTerms_Handler, diff --git a/looprpc/client.pb.gw.go b/looprpc/client.pb.gw.go index 575b768..05bd907 100644 --- a/looprpc/client.pb.gw.go +++ b/looprpc/client.pb.gw.go @@ -62,6 +62,59 @@ func request_SwapClient_LoopIn_0(ctx context.Context, marshaler runtime.Marshale } +func request_SwapClient_Monitor_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (SwapClient_MonitorClient, runtime.ServerMetadata, error) { + var protoReq MonitorRequest + var metadata runtime.ServerMetadata + + stream, err := client.Monitor(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + +func request_SwapClient_ListSwaps_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListSwapsRequest + var metadata runtime.ServerMetadata + + msg, err := client.ListSwaps(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func request_SwapClient_SwapInfo_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SwapInfoRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.SwapInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + func request_SwapClient_LoopOutTerms_0(ctx context.Context, marshaler runtime.Marshaler, client SwapClientClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq TermsRequest var metadata runtime.ServerMetadata @@ -237,6 +290,66 @@ func RegisterSwapClientHandlerClient(ctx context.Context, mux *runtime.ServeMux, }) + mux.Handle("GET", pattern_SwapClient_Monitor_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_Monitor_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_Monitor_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_ListSwaps_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_ListSwaps_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_ListSwaps_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SwapClient_SwapInfo_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_SwapInfo_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_SwapInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_SwapClient_LoopOutTerms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -345,6 +458,12 @@ var ( pattern_SwapClient_LoopIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "in"}, "")) + pattern_SwapClient_Monitor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "monitor"}, "")) + + pattern_SwapClient_ListSwaps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "loop", "swaps"}, "")) + + pattern_SwapClient_SwapInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "loop", "swap", "id"}, "")) + pattern_SwapClient_LoopOutTerms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "loop", "out", "terms"}, "")) pattern_SwapClient_LoopOutQuote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "loop", "out", "quote", "amt"}, "")) @@ -361,6 +480,12 @@ var ( forward_SwapClient_LoopIn_0 = runtime.ForwardResponseMessage + forward_SwapClient_Monitor_0 = runtime.ForwardResponseStream + + forward_SwapClient_ListSwaps_0 = runtime.ForwardResponseMessage + + forward_SwapClient_SwapInfo_0 = runtime.ForwardResponseMessage + forward_SwapClient_LoopOutTerms_0 = runtime.ForwardResponseMessage forward_SwapClient_LoopOutQuote_0 = runtime.ForwardResponseMessage diff --git a/looprpc/client.proto b/looprpc/client.proto index e9b7a68..3f70fee 100644 --- a/looprpc/client.proto +++ b/looprpc/client.proto @@ -37,9 +37,31 @@ service SwapClient { /** loop: `monitor` 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) { + option (google.api.http) = { + get: "/v1/loop/monitor" + }; + } + + /** + ListSwaps returns a list of all currently known swaps and their current + status. + */ + rpc ListSwaps (ListSwapsRequest) returns (ListSwapsResponse) { + option (google.api.http) = { + get: "/v1/loop/swaps" + }; + } + + /** + SwapInfo returns all known details about a single swap. + */ + rpc SwapInfo (SwapInfoRequest) returns (SwapStatus) { + option (google.api.http) = { + get: "/v1/loop/swap/{id}" + }; + } /** loop: `terms` LoopOutTerms returns the terms that the server enforces for a loop out swap. @@ -206,11 +228,19 @@ message LoopInRequest { } message SwapResponse { + /** + Swap identifier to track status in the update stream that is returned from + the Start() call. Currently this is the hash that locks the htlcs. + DEPRECATED: To make the API more consistent, this field is deprecated in + favor of id_bytes and will be removed in a future release. + */ + string id = 1 [deprecated = true]; + /** Swap identifier to track status in the update stream that is returned from the Start() call. Currently this is the hash that locks the htlcs. */ - string id = 1; + bytes id_bytes = 3; /** The address of the on-chain htlc. @@ -231,8 +261,16 @@ message SwapStatus { /** Swap identifier to track status in the update stream that is returned from the Start() call. Currently this is the hash that locks the htlcs. + DEPRECATED: To make the API more consistent, this field is deprecated in + favor of id_bytes and will be removed in a future release. */ - string id = 2; + string id = 2 [deprecated = true]; + + /** + Swap identifier to track status in the update stream that is returned from + the Start() call. Currently this is the hash that locks the htlcs. + */ + bytes id_bytes = 11; /** Swap type @@ -319,6 +357,24 @@ enum SwapState { INVOICE_SETTLED = 5; } +message ListSwapsRequest { +} + +message ListSwapsResponse { + /** + The list of all currently known swaps and their status. + */ + repeated SwapStatus swaps = 1; +} + +message SwapInfoRequest { + /** + The swap identifier which currently is the hash that locks the HTLCs. When + using REST, this field must be encoded as base64. + */ + bytes id = 1; +} + message TermsRequest { } @@ -442,7 +498,7 @@ message LsatToken { 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. diff --git a/looprpc/client.swagger.json b/looprpc/client.swagger.json index 0acdb39..d84c4bc 100644 --- a/looprpc/client.swagger.json +++ b/looprpc/client.swagger.json @@ -110,6 +110,23 @@ ] } }, + "/v1/loop/monitor": { + "get": { + "summary": "* loop: `monitor`\nMonitor will return a stream of swap updates for currently active swaps.", + "operationId": "Monitor", + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "$ref": "#/x-stream-definitions/looprpcSwapStatus" + } + } + }, + "tags": [ + "SwapClient" + ] + } + }, "/v1/loop/out": { "post": { "summary": "* loop: `out`\nLoopOut initiates an loop out swap with the given parameters. The call\nreturns after the swap has been set up with the swap server. From that\npoint onwards, progress can be tracked via the SwapStatus stream that is\nreturned from Monitor().", @@ -205,6 +222,50 @@ ] } }, + "/v1/loop/swap/{id}": { + "get": { + "summary": "*\nSwapInfo returns all known details about a single swap.", + "operationId": "SwapInfo", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/looprpcSwapStatus" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "*\nThe swap identifier which currently is the hash that locks the HTLCs. When\nusing REST, this field must be encoded as base64.", + "in": "path", + "required": true, + "type": "string", + "format": "byte" + } + ], + "tags": [ + "SwapClient" + ] + } + }, + "/v1/loop/swaps": { + "get": { + "summary": "*\nListSwaps returns a list of all currently known swaps and their current\nstatus.", + "operationId": "ListSwaps", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/looprpcListSwapsResponse" + } + } + }, + "tags": [ + "SwapClient" + ] + } + }, "/v1/lsat/tokens": { "get": { "summary": "*\nGetLsatTokens returns all LSAT tokens the daemon ever paid for.", @@ -224,6 +285,18 @@ } }, "definitions": { + "looprpcListSwapsResponse": { + "type": "object", + "properties": { + "swaps": { + "type": "array", + "items": { + "$ref": "#/definitions/looprpcSwapStatus" + }, + "description": "*\nThe list of all currently known swaps and their status." + } + } + }, "looprpcLoopInRequest": { "type": "object", "properties": { @@ -387,6 +460,11 @@ "properties": { "id": { "type": "string", + "description": "*\nSwap identifier to track status in the update stream that is returned from\nthe Start() call. Currently this is the hash that locks the htlcs.\nDEPRECATED: To make the API more consistent, this field is deprecated in\nfavor of id_bytes and will be removed in a future release." + }, + "id_bytes": { + "type": "string", + "format": "byte", "description": "*\nSwap identifier to track status in the update stream that is returned from\nthe Start() call. Currently this is the hash that locks the htlcs." }, "htlc_address": { @@ -418,6 +496,11 @@ }, "id": { "type": "string", + "description": "*\nSwap identifier to track status in the update stream that is returned from\nthe Start() call. Currently this is the hash that locks the htlcs.\nDEPRECATED: To make the API more consistent, this field is deprecated in\nfavor of id_bytes and will be removed in a future release." + }, + "id_bytes": { + "type": "string", + "format": "byte", "description": "*\nSwap identifier to track status in the update stream that is returned from\nthe Start() call. Currently this is the hash that locks the htlcs." }, "type": {