From 0c36239b8be1654ae10049579d6bfd971ca4dacd Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Thu, 6 Oct 2022 18:19:38 +0000 Subject: [PATCH] Update output and associated documentation. --- cmd/account/derive/output.go | 6 ++++-- cmd/account/derive/run.go | 3 ++- docs/changingwithdrawalcredentials.md | 1 - docs/usage.md | 8 ++++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/account/derive/output.go b/cmd/account/derive/output.go index eae128f..90c643c 100644 --- a/cmd/account/derive/output.go +++ b/cmd/account/derive/output.go @@ -42,11 +42,13 @@ func output(ctx context.Context, data *dataOut) (string, error) { if data.showPrivateKey { builder.WriteString(fmt.Sprintf("Private key: %#x\n", data.key.Marshal())) } - builder.WriteString(fmt.Sprintf("Public key: %#x", data.key.PublicKey().Marshal())) if data.showWithdrawalCredentials { withdrawalCredentials := util.SHA256(data.key.PublicKey().Marshal()) withdrawalCredentials[0] = byte(0) // BLS_WITHDRAWAL_PREFIX - builder.WriteString(fmt.Sprintf("\nWithdrawal credentials: %#x", withdrawalCredentials)) + builder.WriteString(fmt.Sprintf("Withdrawal credentials: %#x\n", withdrawalCredentials)) + } + if !(data.showPrivateKey || data.showWithdrawalCredentials) { + builder.WriteString(fmt.Sprintf("Public key: %#x\n", data.key.PublicKey().Marshal())) } return builder.String(), nil diff --git a/cmd/account/derive/run.go b/cmd/account/derive/run.go index 2baaaa9..255de55 100644 --- a/cmd/account/derive/run.go +++ b/cmd/account/derive/run.go @@ -15,6 +15,7 @@ package accountderive import ( "context" + "strings" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -45,5 +46,5 @@ func Run(cmd *cobra.Command) (string, error) { return "", errors.Wrap(err, "failed to obtain output") } - return results, nil + return strings.TrimSuffix(results, "\n"), nil } diff --git a/docs/changingwithdrawalcredentials.md b/docs/changingwithdrawalcredentials.md index 1392574..d9bb7ab 100644 --- a/docs/changingwithdrawalcredentials.md +++ b/docs/changingwithdrawalcredentials.md @@ -112,7 +112,6 @@ ethdo account derive --mnemonic='abandon … art' --path='m/12381/3600/0/0' --sh again replacing the first '0' in the path with the validator number. This will provide an output similar to: ``` -Public key: 0x99b1f1d84d76185466d86c34bde1101316afddae76217aa86cd066979b19858c2c9d9e56eebc1e067ac54277a61790db Withdrawal credentials: 0x008ba1cc4b091b91c1202bba3f508075d6ff565c77e559f0803c0792e0302bf1 ``` diff --git a/docs/usage.md b/docs/usage.md index 200662c..e1dadc2 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -587,6 +587,14 @@ Validator commands focus on interaction with Ethereum 2 validators. $ ethdo validator credentials get --validator=Validators/1 ``` +#### `credentials set` + +`ethdo validator credentials set` updates withdrawal credentials from BLS "type 0" credentials to execution "type 1" credentials. Full information about using this command can be found in the [specific documentation](./changingwithdrawalcredentials.md). + +```sh +$ ethdo validator credentials set --validator=Validators/1 --execution-address=0x8f…9F --private-key=0x3b…9c +``` + #### `depositdata` `ethdo validator depositdata` generates the data required to deposit one or more Ethereum 2 validators. Options include: