Skip to content

Commit

Permalink
looprpc: add FetchL402 rpc
Browse files Browse the repository at this point in the history
This commit adds the FetchL402 rpc to the client proto, which will allow
users to force fetching an L402 without doing a loop out or in.
  • Loading branch information
sputn1ck committed Oct 30, 2024
1 parent e9f1a1a commit 830220a
Show file tree
Hide file tree
Showing 7 changed files with 785 additions and 571 deletions.
4 changes: 4 additions & 0 deletions loopd/perms/perms.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ var RequiredPermissions = map[string][]bakery.Op{
Entity: "auth",
Action: "read",
}},
"/looprpc.SwapClient/FetchL402Token": {{
Entity: "auth",
Action: "write",
}},
"/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 @@ -991,6 +991,21 @@ func (s *swapClientServer) GetLsatTokens(ctx context.Context,
return s.GetL402Tokens(ctx, req)
}

// FetchL402Token fetches a L402 Token from the server. This is required to
// listen for server notifications such as reservations. If a token is already
// in the local L402, nothing will happen.
func (s *swapClientServer) FetchL402Token(ctx context.Context,
_ *looprpc.FetchL402TokenRequest) (*looprpc.FetchL402TokenResponse,
error) {

err := s.impl.Server.FetchL402(ctx)
if err != nil {
return nil, err
}

return &looprpc.FetchL402TokenResponse{}, nil
}

// 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
Loading

0 comments on commit 830220a

Please sign in to comment.