From b14f3defd81750118f47e65a2c5b693f01b47f3e Mon Sep 17 00:00:00 2001 From: sputn1ck Date: Mon, 11 Dec 2023 21:05:13 +0100 Subject: [PATCH] swapserver: add fetchl402 func --- server_mock_test.go | 4 ++++ swap_server_client.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/server_mock_test.go b/server_mock_test.go index daef960..18ae09f 100644 --- a/server_mock_test.go +++ b/server_mock_test.go @@ -273,3 +273,7 @@ func (s *serverMock) PushKey(_ context.Context, _ loopdb.ProtocolVersion, return nil } + +func (s *serverMock) FetchL402(_ context.Context) error { + return nil +} diff --git a/swap_server_client.go b/swap_server_client.go index 4a199ce..359c4dc 100644 --- a/swap_server_client.go +++ b/swap_server_client.go @@ -135,6 +135,10 @@ type swapServerClient interface { PushKey(ctx context.Context, protocolVersion loopdb.ProtocolVersion, swapHash lntypes.Hash, clientInternalPrivateKey [32]byte) error + + // FetchL402 is a helper function that tries to fetch an l402 token + // from the server. + FetchL402(ctx context.Context) error } type grpcSwapServerClient struct { @@ -790,6 +794,18 @@ func (s *grpcSwapServerClient) PushKey(ctx context.Context, return err } +// FetchL402 is a helper function that tries to fetch an l402 token from the +// server. +func (s *grpcSwapServerClient) FetchL402(ctx context.Context) error { + req := &looprpc.FetchL402Request{} + + rpcCtx, rpcCancel := context.WithTimeout(ctx, globalCallTimeout) + defer rpcCancel() + + _, err := s.server.FetchL402(rpcCtx, req) + return err +} + func rpcRouteCancel(details *outCancelDetails) ( *looprpc.CancelLoopOutSwapRequest_RouteCancel, error) {