validate method
Validates the given mnemonic string, optionally with a password.
Implementation
void validate(Mnemonic mnemonic, {String password = ""}) {
/// Validates the number of words in the mnemonic.
TonMnemonicGeneratorUtils.validateWordsNum(mnemonic.wordsCount());
/// Checks if the mnemonic requires a passphrase but one is not provided.
if (password.isNotEmpty &&
!TonEntropyGeneratorUtils.isPasswordNeed(mnemonic)) {
throw const MnemonicException("Invalid Ton mnemonic. is Basic seed.");
}
/// Generates entropy from the mnemonic and passphrase, then checks if it is a basic seed.
if (!TonEntropyGeneratorUtils.isBasicSeed(
TonEntropyGeneratorUtils.generateEnteropy(mnemonic,
password: password))) {
throw const MnemonicException("Invalid Ton mnemonic.");
}
}