mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 08:37:37 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
29 lines
909 B
Go
29 lines
909 B
Go
package rpc
|
|
|
|
import (
|
|
"net/http"
|
|
"path/filepath"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v5/io/file"
|
|
"github.com/prysmaticlabs/prysm/v5/network/httputil"
|
|
"github.com/prysmaticlabs/prysm/v5/validator/accounts/wallet"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// Initialize returns metadata regarding whether the caller has authenticated and has a wallet.
|
|
func (s *Server) Initialize(w http.ResponseWriter, r *http.Request) {
|
|
_, span := trace.StartSpan(r.Context(), "validator.web.Initialize")
|
|
defer span.End()
|
|
walletExists, err := wallet.Exists(s.walletDir)
|
|
if err != nil {
|
|
httputil.HandleError(w, errors.Wrap(err, "Could not check if wallet exists").Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
authTokenPath := filepath.Join(s.walletDir, AuthTokenFileName)
|
|
httputil.WriteJson(w, &InitializeAuthResponse{
|
|
HasSignedUp: file.Exists(authTokenPath),
|
|
HasWallet: walletExists,
|
|
})
|
|
}
|