Bip39 Functions =============== .. c:function:: int bip39_get_languages(char **output) Get the list of default supported languages for BIP39. .. note:: The string returned should be freed using `wally_free_string`. :return: See :ref:`error-codes` .. c:function:: int bip39_get_wordlist(const char *lang, struct words **output) Get the default word list for a language. :param lang: Language to use. Pass NULL to use the default English list. :param output: Destination for the resulting word list. .. note:: The returned structure should not be freed or modified. :return: See :ref:`error-codes` .. c:function:: int bip39_get_word(const struct words *w, size_t index, char **output) Get the 'index'th word from a word list. :param w: Word list to use. Pass NULL to use the default English list. :param index: The 0-based index of the word in ``w``. :param output: Destination for the resulting word. The string returned should be freed using `wally_free_string`. :return: See :ref:`error-codes` .. c:function:: const char *bip39_get_word_by_index(const struct words *w, size_t index) Get the 'index'th word from a word list. :param w: Word list to use. Pass NULL to use the default English list. :param index: The 0-based index of the word in ``w``. .. note:: Returns NULL if any argument is invalid or ``index`` is out of bounds. Unlike `bip39_get_word`, the resulting word must not be written to or freed. .. c:function:: int bip39_mnemonic_from_bytes(const struct words *w, const unsigned char *bytes, size_t bytes_len, char **output) Generate a mnemonic sentence from the entropy in ``bytes``. :param w: Word list to use. Pass NULL to use the default English list. :param bytes: Entropy to convert. :param bytes_len: The length of ``bytes`` in bytes. :param output: Destination for the resulting mnemonic sentence. .. note:: The string returned should be freed using `wally_free_string`. :return: See :ref:`error-codes` .. c:function:: int bip39_mnemonic_to_bytes(const struct words *w, const char *mnemonic, unsigned char *bytes_out, size_t len, size_t *written) Convert a mnemonic sentence into entropy at ``bytes_out``. :param w: Word list to use. Pass NULL to use the default English list. :param mnemonic: Mnemonic to convert. :param bytes_out: Destination for the resulting entropy. :param len: Size of ``bytes_out``. Passing `BIP39_ENTROPY_MAX_LEN` will ensure the buffer is large enough. :param written: Destination for the number of bytes written to ``bytes_out``. :return: See :ref:`variable-length-output-buffers` .. c:function:: int bip39_mnemonic_validate(const struct words *w, const char *mnemonic) Validate the checksum embedded in a mnemonic sentence. :param w: Word list to use. Pass NULL to use the default English list. :param mnemonic: Mnemonic to validate. :return: See :ref:`error-codes` .. c:function:: int bip39_mnemonic_to_seed(const char *mnemonic, const char *passphrase, unsigned char *bytes_out, size_t len, size_t *written) Convert a mnemonic into a binary seed. :param mnemonic: Mnemonic to convert. :param passphrase: Mnemonic passphrase or NULL if no passphrase is needed. :param bytes_out: The destination for the binary seed. :param len: Size of ``bytes_out``. Must be `BIP39_SEED_LEN_512`. :param written: Destination for the number of bytes written to ``bytes_out``. :return: See :ref:`variable-length-output-buffers` .. c:function:: int bip39_mnemonic_to_seed512(const char *mnemonic, const char *passphrase, unsigned char *bytes_out, size_t len) Convert a mnemonic into a binary seed of 512 bits. :param mnemonic: Mnemonic to convert. :param passphrase: Mnemonic passphrase or NULL if no passphrase is needed. :param bytes_out: The destination for the binary seed. :param len: Size of ``bytes_out``. Must be `BIP39_SEED_LEN_512`. .. note:: Identical to `bip39_mnemonic_to_seed` but returns a fixed size buffer. :return: See :ref:`error-codes` Bip39 Constants --------------- .. c:macro:: BIP39_ENTROPY_LEN_128 Valid entropy lengths .. c:macro:: BIP39_ENTROPY_LEN_160 .. c:macro:: BIP39_ENTROPY_LEN_192 .. c:macro:: BIP39_ENTROPY_LEN_224 .. c:macro:: BIP39_ENTROPY_LEN_256 .. c:macro:: BIP39_ENTROPY_LEN_288 .. c:macro:: BIP39_ENTROPY_LEN_320 .. c:macro:: BIP39_SEED_LEN_512 The required size of the output buffer for `bip39_mnemonic_to_seed` .. c:macro:: BIP39_ENTROPY_MAX_LEN Maximum entropy size (including up to 2 bytes for checksum) .. c:macro:: BIP39_WORDLIST_LEN The number of words in a BIP39 compliant wordlist