mirror of
https://github.com/wealdtech/ethdo.git
synced 2026-01-10 06:28:07 -05:00
generateOperationFromMnemonicAndValidator err++
This commit is contained in:
@@ -193,7 +193,7 @@ func (c *command) generateOperationFromMnemonicAndValidator(ctx context.Context)
|
||||
if c.debug {
|
||||
fmt.Fprintf(os.Stderr, "Gone %d indices without finding the validator, not scanning any further\n", maxDistance)
|
||||
}
|
||||
break
|
||||
return fmt.Errorf("failed to find validator using the provided mnemonic, index=%s, pubkey=%#x", c.validator, validatorInfo.Pubkey)
|
||||
}
|
||||
validatorKeyPath := fmt.Sprintf("m/12381/3600/%d/0/0", i)
|
||||
validatorPrivkey, err := ethutil.PrivateKeyFromSeedAndPath(seed, validatorKeyPath)
|
||||
@@ -220,6 +220,24 @@ func (c *command) generateOperationFromMnemonicAndValidator(ctx context.Context)
|
||||
}
|
||||
|
||||
func (c *command) generateOperationsFromMnemonicAndPrivateKey(ctx context.Context) error {
|
||||
// TODO: determine if this method is only for a single account. If so we
|
||||
// can add tests to verify that the 0'th account of the seed has the same
|
||||
// private key as the one provided by the user.
|
||||
/*
|
||||
// check that the see from the mnemonic is the same as the one from the private key
|
||||
seed_from_mnemonic, err := util.SeedFromMnemonic(c.mnemonic)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
seed_from_private_key, err := util.SeedFromPrivateKey(c.privateKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !bytes.Equal(seed_from_mnemonic, seed_from_private_key) {
|
||||
return errors.New("the seed from the mnemonic and the seed from the private key are not the same")
|
||||
}
|
||||
*/
|
||||
|
||||
// Functionally identical to a simple scan, so use that.
|
||||
return c.generateOperationsFromMnemonic(ctx)
|
||||
}
|
||||
|
||||
@@ -269,6 +269,17 @@ func TestGenerateOperationFromMnemonicAndValidator(t *testing.T) {
|
||||
},
|
||||
err: "invalid withdrawal address: failed to obtain execution address: encoding/hex: invalid byte: U+0072 'r'",
|
||||
},
|
||||
{
|
||||
name: "InvalidWithdrawalAddressBeyondMaxDistance",
|
||||
command: &command{
|
||||
mnemonic: "struggle kangaroo horn sniff cradle soft ethics thunder cycle illegal flock unaware dynamic cinnamon play enforce card tennis inform parent surprise bring relax tail",
|
||||
validator: "1",
|
||||
chainInfo: chainInfo,
|
||||
signedOperations: make([]*capella.SignedBLSToExecutionChange, 0),
|
||||
withdrawalAddressStr: "0x8c1Ff978036F2e9d7CC382Eff7B4c8c53C22ac15",
|
||||
},
|
||||
err: "failed to find validator using the provided mnemonic, index=1, pubkey=0xb3d89e2f29c712c6a9f8e5a269b97617c4a94dd6f6662ab3b07ce9e5434573f15b5c988cd14bbd5804f77156a8af1cfa",
|
||||
},
|
||||
{
|
||||
name: "UnknownValidatorPubKey",
|
||||
command: &command{
|
||||
|
||||
Reference in New Issue
Block a user