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

Impossible to convert from entropy to mnemonic in example.c #32

Open
AlexInsa opened this issue Dec 10, 2019 · 0 comments
Open

Impossible to convert from entropy to mnemonic in example.c #32

AlexInsa opened this issue Dec 10, 2019 · 0 comments
Assignees

Comments

@AlexInsa
Copy link

With the file example.c, it is not possible to use the functionality "-e entropy_file", because the return of the function entropy_to_mnemonic is not well treated.

Indeed, according to the documentation of the function entropy_to_mnemonic in mnemonics.h, and according to this associated source code in mnemonics.c the function returns the

length of mnemonic phrase in characters or negative error code in case of failure

However, in the example.c file, in the function convert_entropy_to_mnemonics, the variable return_code is compared to 0 :

/* Converting entropy to a mnemonic phrase using the default dictionary. */
    return_code = entropy_to_mnemonic(NULL, entropy, entropy_len, &mnemonic);

    if (return_code != 0) {
        printf("Error: Could not convert entropy.\n");
        return;
    }

This means that, if the entropy_to_mnemonic function returns the correct output (the length of the mnemonic phrase), then the program stops and prints that an error occurred.

One of the possible patch would be to change the error return check :

if (return_code != 0) {

by

if (return_code <= 0) {

in example.c

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

No branches or pull requests

2 participants