Skip to content

Commit

Permalink
check for mnenomic
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Jul 5, 2018
1 parent 7d45f93 commit 2595736
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
root, _ := hdwallet.New(hdwallet.Config{
root, _ := hdwallet.New(&hdwallet.Config{
Mnemonic: mnemonic,
Path: `m/44'/60'/0'/0`,
})
Expand Down
6 changes: 5 additions & 1 deletion hdwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ type Config struct {
}

// New ...
func New(config Config) (*Wallet, error) {
func New(config *Config) (*Wallet, error) {
if config.Path == "" {
config.Path = `m/44'/60'/0'/0`
}

if config.Mnemonic == "" {
return nil, errors.New("mnemonic is required")
}

seed := bip39.NewSeed(config.Mnemonic, "")
parts := strings.Split(config.Path, "/")
var err error
Expand Down
2 changes: 1 addition & 1 deletion hdwallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func TestNew(t *testing.T) {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
root, err := New(Config{
root, err := New(&Config{
Mnemonic: mnemonic,
Path: "m/44'/60'/0'/0",
})
Expand Down

0 comments on commit 2595736

Please sign in to comment.