Helper function to validate a mnemonic string */
| 30 | |
| 31 | /* Helper function to validate a mnemonic string */ |
| 32 | enum hsm_secret_error validate_mnemonic(const char *mnemonic) |
| 33 | { |
| 34 | struct words *words; |
| 35 | bool ok; |
| 36 | |
| 37 | tal_wally_start(); |
| 38 | if (bip39_get_wordlist("en", &words) != WALLY_OK) { |
| 39 | abort(); |
| 40 | } |
| 41 | |
| 42 | ok = (bip39_mnemonic_validate(words, mnemonic) == WALLY_OK); |
| 43 | |
| 44 | /* Wordlists can persist, so provide a common context! */ |
| 45 | tal_wally_end(notleak_with_children(tal(NULL, char))); |
| 46 | |
| 47 | if (!ok) |
| 48 | return HSM_SECRET_ERR_INVALID_MNEMONIC; |
| 49 | |
| 50 | return HSM_SECRET_OK; |
| 51 | } |
| 52 | |
| 53 | struct secret *get_encryption_key(const tal_t *ctx, const char *passphrase) |
| 54 | { |
no test coverage detected