Skip to content

Commit f00b9b6

Browse files
authored
Merge pull request #672 from sputn1ck/fetchl402
swapserverrpc: Add Fetchl402 call
2 parents 63403d1 + b14f3de commit f00b9b6

File tree

5 files changed

+367
-178
lines changed

5 files changed

+367
-178
lines changed

server_mock_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,7 @@ func (s *serverMock) PushKey(_ context.Context, _ loopdb.ProtocolVersion,
273273

274274
return nil
275275
}
276+
277+
func (s *serverMock) FetchL402(_ context.Context) error {
278+
return nil
279+
}

swap_server_client.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ type swapServerClient interface {
135135
PushKey(ctx context.Context,
136136
protocolVersion loopdb.ProtocolVersion, swapHash lntypes.Hash,
137137
clientInternalPrivateKey [32]byte) error
138+
139+
// FetchL402 is a helper function that tries to fetch an l402 token
140+
// from the server.
141+
FetchL402(ctx context.Context) error
138142
}
139143

140144
type grpcSwapServerClient struct {
@@ -790,6 +794,18 @@ func (s *grpcSwapServerClient) PushKey(ctx context.Context,
790794
return err
791795
}
792796

797+
// FetchL402 is a helper function that tries to fetch an l402 token from the
798+
// server.
799+
func (s *grpcSwapServerClient) FetchL402(ctx context.Context) error {
800+
req := &looprpc.FetchL402Request{}
801+
802+
rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout)
803+
defer rpcCancel()
804+
805+
_, err := s.server.FetchL402(rpcCtx, req)
806+
return err
807+
}
808+
793809
func rpcRouteCancel(details *outCancelDetails) (
794810
*looprpc.CancelLoopOutSwapRequest_RouteCancel, error) {
795811

0 commit comments

Comments
 (0)