Use standard function to obtain best public key.

This commit is contained in:
Jim McDonald
2022-10-05 13:54:41 +00:00
parent 3c10131c45
commit 2c96ef958e
2 changed files with 1 additions and 19 deletions

View File

@@ -375,24 +375,6 @@ func walletAndAccountFromPath(ctx context.Context, path string) (e2wtypes.Wallet
return wallet, account, nil
}
// bestPublicKey returns the best public key for operations.
// It prefers the composite public key if present, otherwise the public key.
func bestPublicKey(account e2wtypes.Account) (e2types.PublicKey, error) {
var pubKey e2types.PublicKey
publicKeyProvider, isCompositePublicKeyProvider := account.(e2wtypes.AccountCompositePublicKeyProvider)
if isCompositePublicKeyProvider {
pubKey = publicKeyProvider.CompositePublicKey()
} else {
publicKeyProvider, isPublicKeyProvider := account.(e2wtypes.AccountPublicKeyProvider)
if isPublicKeyProvider {
pubKey = publicKeyProvider.PublicKey()
} else {
return nil, errors.New("account does not provide a public key")
}
}
return pubKey, nil
}
// remotesToEndpoints generates endpoints from remote addresses.
func remotesToEndpoints(remotes []string) ([]*dirk.Endpoint, error) {
endpoints := make([]*dirk.Endpoint, 0)

View File

@@ -77,7 +77,7 @@ In quiet mode this will return 0 if the validator information can be obtained, o
network, err := util.Network(ctx, eth2Client)
errCheck(err, "Failed to obtain network")
outputIf(debug, fmt.Sprintf("Network is %s", network))
pubKey, err := bestPublicKey(account)
pubKey, err := util.BestPublicKey(account)
if err == nil {
deposits, totalDeposited, err := graphData(network, pubKey.Marshal())
if err == nil && deposits > 0 {