Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Add keys new and keys mnemonic commands #2155

Closed
wants to merge 4 commits into from

Conversation

mslipper
Copy link
Contributor

@mslipper mslipper commented Aug 27, 2018

Closes #2091.

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@mslipper
Copy link
Contributor Author

Two notes about this PR:

  1. I found it really difficult to cleanly test prompts without writing what amounts to a testing framework for them. I can do this, but I wanted to clear it with you guys first.
  2. I nolint: gocyclo'd two methods. Their cyclomatic complexity comes from error-checking if statements. I didn't think that the methods were overly complex, however I'm happy to refactor if you'd like me to.

@codecov
Copy link

codecov bot commented Aug 27, 2018

Codecov Report

Merging #2155 into develop will increase coverage by 0.07%.
The diff coverage is 71.25%.

@@             Coverage Diff             @@
##           develop    #2155      +/-   ##
===========================================
+ Coverage    63.62%   63.69%   +0.07%     
===========================================
  Files          136      136              
  Lines         8270     8325      +55     
===========================================
+ Hits          5262     5303      +41     
- Misses        2652     2660       +8     
- Partials       356      362       +6

@alexanderbez alexanderbez changed the title Add keys new and keys mnemonic commands WIP: Add keys new and keys mnemonic commands Aug 27, 2018
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mslipper thanks for contribution! I left some feedback. Also, a pending log update needs to be added.

I have yet to test this, once other reviews have been added and addressed, I'll test.

Also, we should probably mark the old command as deprecated in the short/long text, no?

func mnemonicCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "mnemonic",
Short: "Creates a new mnemonic for use in key generation. Uses system entropy by default.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Generate a mnemonic from system or user-supplied entropy wording is slightly better here.

)

const (
flagEntropy = "user"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to flagUserEntropy?

return outputMnemonic(kb, nil)
}

stdin := client.BufferStdin()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having all this signal handling and go-routine handling seems a bit off to have here. Why not have a helper function in client/input.go that utilizes GetString or some variant? This would cleanup the command handler a lot.

}()

go func() {
fmt.Println("Please provide entropy using your keyboard and press enter.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the prompt can be simplified down to: Please provide entropy:, no?

return NewMnemonicWithEntropy(len, nil)
}

func NewMnemonicWithEntropy(sLen ValidSentenceLen, providedEntropy []byte) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing godoc.

@rigelrozanski
Copy link
Contributor

is this still WIP?

@jackzampolin jackzampolin changed the title WIP: Add keys new and keys mnemonic commands R4R: Add keys new and keys mnemonic commands Aug 29, 2018
@mslipper
Copy link
Contributor Author

@rigelrozanski it's good to go from my perspective.

@ebuchman
Copy link
Member

Sorry, maybe I didn't communicate it well enough, but I tackled this in #2090

@ebuchman
Copy link
Member

Want to take a look at that and see if there's anything from here we should bring over? There's a few other refactors/pkg movement there

@rigelrozanski
Copy link
Contributor

@ebuchman Retrospective - I think that it would have been more clear if your PR was tackling 2091 to use the language "Closing" instead of "Ref"

@mslipper mslipper closed this Aug 31, 2018
@alexanderbez
Copy link
Contributor

I think that it would have been more clear if your PR was tackling 2091 to use the language "Closing" instead of "Ref"

++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants