Skip to content

Commit b14f3de

Browse files
committed
swapserver: add fetchl402 func
1 parent 6d5d210 commit b14f3de

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
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)