mirror of
https://github.com/wealdtech/ethdo.git
synced 2026-01-09 14:07:56 -05:00
post review changes
This commit is contained in:
@@ -43,7 +43,6 @@ type command struct {
|
||||
path string
|
||||
privateKey string
|
||||
validator string
|
||||
allValidators bool
|
||||
withdrawalAddressStr string
|
||||
forkVersion string
|
||||
genesisValidatorsRoot string
|
||||
@@ -88,7 +87,6 @@ func newCommand(_ context.Context) (*command, error) {
|
||||
signedOperationsInput: viper.GetString("signed-operations"),
|
||||
|
||||
validator: viper.GetString("validator"),
|
||||
allValidators: viper.GetBool("all-validators"),
|
||||
withdrawalAddressStr: viper.GetString("withdrawal-address"),
|
||||
forkVersion: viper.GetString("fork-version"),
|
||||
genesisValidatorsRoot: viper.GetString("genesis-validators-root"),
|
||||
|
||||
@@ -127,9 +127,9 @@ func (c *command) obtainOperations(ctx context.Context) error {
|
||||
return c.generateOperationsFromValidatorAndPrivateKey(ctx)
|
||||
}
|
||||
|
||||
if c.allValidators && c.privateKey != "" {
|
||||
if c.privateKey != "" {
|
||||
// Use all validators from chain info and a private key for the withdrawal address.
|
||||
return c.generateOperationsFromChainInfoAndPrivateKey(ctx)
|
||||
return c.generateOperationsFromPrivateKey(ctx)
|
||||
}
|
||||
|
||||
return errors.New("unsupported combination of inputs; see help for details of supported combinations")
|
||||
@@ -318,14 +318,14 @@ func (c *command) generateOperationsFromValidatorAndPrivateKey(ctx context.Conte
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *command) generateOperationsFromChainInfoAndPrivateKey(ctx context.Context) error {
|
||||
for _, validatorInfo := range c.chainInfo.Validators {
|
||||
withdrawalAccount, err := util.ParseAccount(ctx, c.privateKey, nil, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (c *command) generateOperationsFromPrivateKey(ctx context.Context) error {
|
||||
withdrawalAccount, err := util.ParseAccount(ctx, c.privateKey, nil, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// skip validators which withdrawal key don't match with supplied withdrawal account public key
|
||||
for _, validatorInfo := range c.chainInfo.Validators {
|
||||
// Skip validators which withdrawal key don't match with supplied withdrawal account public key.
|
||||
pubkey, err := util.BestPublicKey(withdrawalAccount)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -333,7 +333,6 @@ func (c *command) generateOperationsFromChainInfoAndPrivateKey(ctx context.Conte
|
||||
withdrawalCredentials := ethutil.SHA256(pubkey.Marshal())
|
||||
withdrawalCredentials[0] = byte(0) // BLS_WITHDRAWAL_PREFIX
|
||||
if !bytes.Equal(withdrawalCredentials, validatorInfo.WithdrawalCredentials) {
|
||||
fmt.Printf("Skipping validator due to withdrawal credentials mismatch index=%v pubkey=%v\n", validatorInfo.Index, validatorInfo.Pubkey.String())
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ func init() {
|
||||
validatorCredentialsFlags(validatorCredentialsSetCmd)
|
||||
validatorCredentialsSetCmd.Flags().Bool("prepare-offline", false, "Create files for offline use")
|
||||
validatorCredentialsSetCmd.Flags().String("validator", "", "Validator for which to set validator credentials")
|
||||
validatorCredentialsSetCmd.Flags().Bool("all-validators", false, "Use all Validators in chain-info to set validator credentials")
|
||||
validatorCredentialsSetCmd.Flags().String("withdrawal-account", "", "Account with which the validator's withdrawal credentials were set")
|
||||
validatorCredentialsSetCmd.Flags().String("withdrawal-address", "", "Execution address to which to direct withdrawals")
|
||||
validatorCredentialsSetCmd.Flags().String("signed-operations", "", "Use pre-defined JSON signed operation as created by --json to transmit the credentials change operation (reads from change-operations.json if not present)")
|
||||
@@ -75,9 +74,6 @@ func validatorCredentialsSetBindings() {
|
||||
if err := viper.BindPFlag("validator", validatorCredentialsSetCmd.Flags().Lookup("validator")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := viper.BindPFlag("all-validators", validatorCredentialsSetCmd.Flags().Lookup("all-validators")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := viper.BindPFlag("signed-operations", validatorCredentialsSetCmd.Flags().Lookup("signed-operations")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ Similar to the previous section, however instead of specifying the mnemonic, it
|
||||
|
||||
|
||||
```
|
||||
ethdo validator credentials set --all-validators --private-key=0x3b…9c --withdrawal-address=0x8f…9F
|
||||
ethdo validator credentials set --private-key=0x3b…9c --withdrawal-address=0x8f…9F
|
||||
```
|
||||
|
||||
#### Using an account
|
||||
|
||||
Reference in New Issue
Block a user