mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 20:07:17 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package accounts
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"math"
|
|
|
|
"github.com/pkg/errors"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v3/validator/accounts/wallet"
|
|
"github.com/prysmaticlabs/prysm/v3/validator/keymanager"
|
|
)
|
|
|
|
// List pretty-prints accounts in the wallet.
|
|
func (acm *AccountsCLIManager) List(ctx context.Context) error {
|
|
if acm.listValidatorIndices {
|
|
client, _, err := acm.prepareBeaconClients(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return listValidatorIndices(ctx, acm.keymanager, *client)
|
|
}
|
|
return acm.keymanager.ListKeymanagerAccounts(ctx,
|
|
keymanager.ListKeymanagerAccountConfig{
|
|
ShowDepositData: acm.showDepositData,
|
|
ShowPrivateKeys: acm.showPrivateKeys,
|
|
WalletAccountsDir: acm.wallet.AccountsDir(),
|
|
KeymanagerConfigFileName: wallet.KeymanagerConfigFileName,
|
|
})
|
|
}
|
|
|
|
func listValidatorIndices(ctx context.Context, km keymanager.IKeymanager, client ethpb.BeaconNodeValidatorClient) error {
|
|
pubKeys, err := km.FetchValidatingPublicKeys(ctx)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not get validating public keys")
|
|
}
|
|
var pks [][]byte
|
|
for i := range pubKeys {
|
|
pks = append(pks, pubKeys[i][:])
|
|
}
|
|
req := ðpb.MultipleValidatorStatusRequest{PublicKeys: pks}
|
|
resp, err := client.MultipleValidatorStatus(ctx, req)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not request validator indices")
|
|
}
|
|
fmt.Println(au.BrightGreen("Validator indices:").Bold())
|
|
for i, idx := range resp.Indices {
|
|
if idx != math.MaxUint64 {
|
|
fmt.Printf("%#x: %d\n", pubKeys[i][0:4], idx)
|
|
}
|
|
}
|
|
return nil
|
|
}
|