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

stellar-hd-wallet #78

Merged
merged 11 commits into from
Dec 28, 2017
Merged

stellar-hd-wallet #78

merged 11 commits into from
Dec 28, 2017

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented Sep 21, 2017

Implements BIP-39 and BIP-44 for Stellar keys derivation.

TODO:

"github.com/tyler-smith/go-bip39"
)

var wordsCount uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why we should support customizable entropy. Seems complicated to use: we don't document the various valid values and users probably won't understand the implications of using a smaller number of words.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Switched to 256-bit entropy.

@@ -0,0 +1,62 @@
package derive
Copy link
Contributor

@nullstyle nullstyle Oct 5, 2017

Choose a reason for hiding this comment

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

We should probably move this file underneath internal to prevent external imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to #150

@bartekn
Copy link
Contributor Author

bartekn commented Nov 16, 2017

OK, I think this is ready for review, merge and release (version 0.0.1). Added tests and information that this is EXPERIMENTAL software.

@bartekn bartekn changed the title [WIP] stellar-hd-wallet stellar-hd-wallet Nov 16, 2017
readString()
}

println("WARNING! Store the words above in a save place!")

Choose a reason for hiding this comment

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

Typo: save -> safe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@nullstyle nullstyle left a comment

Choose a reason for hiding this comment

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

LGTM! However, please include a CHANGELOG.md and README.md files so that the build scripts can package the tool.

@bartekn bartekn dismissed nullstyle’s stale review December 28, 2017 17:25

Added requested files.

nikhilsaraf
nikhilsaraf previously approved these changes Dec 28, 2017
Copy link
Contributor

@nikhilsaraf nikhilsaraf left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Please look at the comments inline, I think a few things can be streamlined in a follow-on commit.

Words string
Passphrase string
Error string
Output string
Copy link
Contributor

Choose a reason for hiding this comment

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

it's hard to tell expected output vs input values without reading the test cases. Could use want as a prefix for expected values, which is go convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

},
}

for _, test := range tests {
Copy link
Contributor

Choose a reason for hiding this comment

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

should use subtests, t.Run -- test output is much easier to read and work with, mentioned this pattern in previous reviews as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

)

var reader = bufio.NewReader(os.Stdin)
var out io.Writer = os.Stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

could put these vars on a struct and these functions can hang off that struct. then when testing we can inject the inputs to the struct to be buffer inputs (prefilled) and outputs so testing is easier. while in production we can pass in the standard input and output buffers

These changes would also make this file a more generally usable utility outside of just the stellar-hd-wallet tool and we could move it to /support

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think we can do this in a separate PR if there is a need for such struct.

However, this doesn't solve the issue - we would still need to have a global variable (struct object this time) and overwrite it's fields. I think the long term fix would be something like this:

  1. Create the App struct that will contain RunE methods for each command.
  2. Have the IO struct object in App struct.

Then we can create App object an overwrite IO in a cleaner way. Let's do it in the next version.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes that's right, we should use dependency injection for this IO struct rather than using a global var. ok to leave this for the next PR.

words := strings.Split(test.Words, " ")
input := fmt.Sprintf("%d\n%s\n%s\n", len(words), strings.Join(words, "\n"), test.Passphrase)

// Global variables, AFAIK there is no elegant way to pass it to cobra.Command
Copy link
Contributor

Choose a reason for hiding this comment

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

see my comment below in io.go about using a struct to avoid the global vars. You may need to create a common function that is called by the cobra command, and test that function rather than the cobra command to achieve the dependency injection needed

@nikhilsaraf
Copy link
Contributor

thanks for the changes, LGTM! 👍

@bartekn bartekn merged commit 3534889 into master Dec 28, 2017
@bartekn bartekn deleted the stellar-hd-wallet branch September 10, 2018 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants