mirror of
https://github.com/wealdtech/ethdo.git
synced 2026-01-09 14:07:56 -05:00
Merge pull request #56 from joaocenoura/master
Allow ethdo credential set to use all validators from offline-preparation.json
This commit is contained in:
@@ -135,6 +135,11 @@ func (c *command) obtainOperations(ctx context.Context) error {
|
||||
return c.generateOperationsFromValidatorAndPrivateKey(ctx)
|
||||
}
|
||||
|
||||
if c.privateKey != "" {
|
||||
// Have a private key.
|
||||
return c.generateOperationsFromPrivateKey(ctx)
|
||||
}
|
||||
|
||||
return errors.New("unsupported combination of inputs; see help for details of supported combinations")
|
||||
}
|
||||
|
||||
@@ -321,6 +326,32 @@ func (c *command) generateOperationsFromValidatorAndPrivateKey(ctx context.Conte
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *command) generateOperationsFromPrivateKey(ctx context.Context) error {
|
||||
// Extract withdrawal account public key from supplied private key.
|
||||
withdrawalAccount, err := util.ParseAccount(ctx, c.privateKey, nil, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pubkey, err := util.BestPublicKey(withdrawalAccount)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
withdrawalCredentials := ethutil.SHA256(pubkey.Marshal())
|
||||
withdrawalCredentials[0] = byte(0) // BLS_WITHDRAWAL_PREFIX
|
||||
|
||||
for _, validatorInfo := range c.chainInfo.Validators {
|
||||
// Skip validators which withdrawal key don't match with supplied withdrawal account public key.
|
||||
if !bytes.Equal(withdrawalCredentials, validatorInfo.WithdrawalCredentials) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := c.generateOperationFromAccount(ctx, validatorInfo, withdrawalAccount); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *command) obtainOperationsFromFileOrInput(ctx context.Context) error {
|
||||
// Start off by attempting to use the provided signed operations.
|
||||
if c.signedOperationsInput != "" {
|
||||
|
||||
@@ -210,6 +210,14 @@ ethdo validator credentials set --mnemonic="abandon abandon abandon … art" --p
|
||||
|
||||
Note that it is possible for there to be multiple validators that use the provided private key for a withdrawal address, in which case an operation will be generated for each validator that is eligible for change.
|
||||
|
||||
#### Using withdrawal private key only.
|
||||
Similar to the previous section, however instead of specifying the mnemonic, it will select multiple validators that use provided private key for their withdrawal address.
|
||||
|
||||
|
||||
```
|
||||
ethdo validator credentials set --private-key=0x3b…9c --withdrawal-address=0x8f…9F
|
||||
```
|
||||
|
||||
#### Using an account
|
||||
If you used `ethdo` to generate your validator deposit data you will likely have used a separate account to generate the withdrawal credentials. You can specify the accout of the validator and the accout of the withdrawal credentials to generate and broadcast the credentials change operation with the following command:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user