Skip to content

Commit

Permalink
mnemonic constructor no longer returns a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestofIranon committed Jan 9, 2020
1 parent 98c8138 commit 02ccf4c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions mnemonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ func (m Mnemonic) ToPrivateKey(passPhrase string) (Ed25519PrivateKey, error) {
}

// Generate a random 24-word mnemonic
func GenerateMnemonic() (*Mnemonic, error) {
func GenerateMnemonic() (Mnemonic, error) {
entropy, err := bip39.NewEntropy(256)

if err != nil {
// It is only possible for there to be an error if the operating
// system's rng is unreadable
return nil, fmt.Errorf("could not retrieve random bytes from the operating system")
return Mnemonic{}, fmt.Errorf("could not retrieve random bytes from the operating system")
}

mnemonic, err := bip39.NewMnemonic(entropy)


// Note that this should never actually fail since it is being provided by library generated mnemonic
if err != nil {
// todo: return proper error
return nil, err
return Mnemonic{}, err
}

return &Mnemonic{mnemonic }, nil
return Mnemonic{mnemonic }, nil
}

// Create a mnemonic from a string of 24 words separated by spaces
Expand Down

0 comments on commit 02ccf4c

Please sign in to comment.