mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
ead9a83d8d
* WIP * Refactor to use iface.ValidatorClient instead of ethpb.BeaconNodeValidatorClient * Add mocks for iface.ValidatorClient * Fix mocks * Update update-mockgen.sh * Fix warnings * Fix config_setting syntax * Use custom build settings * WIP * WIP * WIP * WIP * WIP * WIP * Fix endpoint address and reduce timeout * Revert most e2e changes * Use e2e.TestParams.Ports.PrysmBeaconNodeGatewayPort * Fix BeaconRESTApiProviderFlag port * Revert e2e changes
65 lines
2.0 KiB
Go
65 lines
2.0 KiB
Go
package accounts
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v3/cmd"
|
|
"github.com/prysmaticlabs/prysm/v3/cmd/validator/flags"
|
|
"github.com/prysmaticlabs/prysm/v3/validator/accounts"
|
|
"github.com/prysmaticlabs/prysm/v3/validator/accounts/userprompt"
|
|
"github.com/prysmaticlabs/prysm/v3/validator/client"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func accountsDelete(c *cli.Context) error {
|
|
w, km, err := walletWithKeymanager(c)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
dialOpts := client.ConstructDialOptions(
|
|
c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
|
|
c.String(flags.CertFlag.Name),
|
|
c.Uint(flags.GrpcRetriesFlag.Name),
|
|
c.Duration(flags.GrpcRetryDelayFlag.Name),
|
|
)
|
|
grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",")
|
|
|
|
opts := []accounts.Option{
|
|
accounts.WithWallet(w),
|
|
accounts.WithKeymanager(km),
|
|
accounts.WithGRPCDialOpts(dialOpts),
|
|
accounts.WithBeaconRPCProvider(c.String(flags.BeaconRPCProviderFlag.Name)),
|
|
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
|
|
accounts.WithGRPCHeaders(grpcHeaders),
|
|
}
|
|
|
|
// Get full set of public keys from the keymanager.
|
|
validatingPublicKeys, err := km.FetchValidatingPublicKeys(c.Context)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(validatingPublicKeys) == 0 {
|
|
return errors.New("wallet is empty, no accounts to delete")
|
|
}
|
|
// Filter keys either from CLI flag or from interactive session.
|
|
filteredPubKeys, err := accounts.FilterPublicKeysFromUserInput(
|
|
c,
|
|
flags.DeletePublicKeysFlag,
|
|
validatingPublicKeys,
|
|
userprompt.SelectAccountsDeletePromptText,
|
|
)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not filter public keys for deletion")
|
|
}
|
|
opts = append(opts, accounts.WithFilteredPubKeys(filteredPubKeys))
|
|
opts = append(opts, accounts.WithWalletKeyCount(len(validatingPublicKeys)))
|
|
opts = append(opts, accounts.WithDeletePublicKeys(c.IsSet(flags.DeletePublicKeysFlag.Name)))
|
|
|
|
acc, err := accounts.NewCLIManager(opts...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return acc.Delete(c.Context)
|
|
}
|