Skip to content

Commit

Permalink
loopd: re-add GetLsatTokens method in gRPC
Browse files Browse the repository at this point in the history
This is needed not to break existing client binaries, e.g. `loop listauth`,
Terminal Web, RTL.

The API should be removed in a couple of releases. For now, GetLsatTokens
just prints a warning message about the API being deprecated and that the
client binary should be updated, and calls GetL402Tokens API, as a wrapper.

Type LsatToken used by GetLsatTokens in the past was renamed to L402Token,
but this does not affect binary encoding, so type L402Token can be used
(as part of TokensResponse) without breaking backward compatibility.

Updated release_notes.md.

See #730 (comment)
  • Loading branch information
starius committed Apr 25, 2024
1 parent 14dc8e1 commit b9e2a25
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 77 deletions.
4 changes: 4 additions & 0 deletions loopd/perms/perms.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ var RequiredPermissions = map[string][]bakery.Op{
Entity: "auth",
Action: "read",
}},
"/looprpc.SwapClient/GetLsatTokens": {{
Entity: "auth",
Action: "read",
}},
"/looprpc.SwapClient/SuggestSwaps": {{
Entity: "suggestions",
Action: "read",
Expand Down
15 changes: 15 additions & 0 deletions loopd/swapclient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,21 @@ func (s *swapClientServer) GetL402Tokens(ctx context.Context,
return &clientrpc.TokensResponse{Tokens: rpcTokens}, nil
}

// GetLsatTokens returns all tokens that are contained in the L402 token store.
// Deprecated: use GetL402Tokens.
// This API is provided to maintain backward compatibility with gRPC clients
// (e.g. `loop listauth`, Terminal Web, RTL).
// Type LsatToken used by GetLsatTokens in the past was renamed to L402Token,
// but this does not affect binary encoding, so we can use type L402Token here.
func (s *swapClientServer) GetLsatTokens(ctx context.Context,
req *clientrpc.TokensRequest) (*clientrpc.TokensResponse, error) {

log.Warnf("Received deprecated call GetLsatTokens. Please update the " +
"client software. Calling GetL402Tokens now.")

return s.GetL402Tokens(ctx, req)
}

// GetInfo returns basic information about the loop daemon and details to swaps
// from the swap store.
func (s *swapClientServer) GetInfo(ctx context.Context,
Expand Down
154 changes: 80 additions & 74 deletions looprpc/client.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions looprpc/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ service SwapClient {
*/
rpc GetL402Tokens (TokensRequest) returns (TokensResponse);

/* loop: `listauth`
Deprecated: use GetL402Tokens.
This API is provided to maintain backward compatibility with gRPC clients
(e.g. `loop listauth`, Terminal Web, RTL).
Type LsatToken used by GetLsatTokens in the past was renamed to L402Token,
but this does not affect binary encoding, so we can use type L402Token here.
*/
rpc GetLsatTokens (TokensRequest) returns (TokensResponse);

/* loop: `getinfo`
GetInfo gets basic information about the loop daemon.
*/
Expand Down

0 comments on commit b9e2a25

Please sign in to comment.