Added generate_mnemonic method

This commit is contained in:
dhruvbaliyan 2022-08-09 14:23:17 +05:30
parent 973013cbdf
commit 930a1f1eb4
No known key found for this signature in database
GPG Key ID: C0123AC0FAE7CC73
2 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,7 @@
namespace bdk {};
namespace bdk {
[Throws=BdkError]
string generate_mnemonic(WordCount word_count);
};
[Error]
enum BdkError {

View File

@ -627,6 +627,12 @@ impl BumpFeeTxBuilder {
}
}
fn generate_mnemonic(word_count: WordCount) -> Result<String, BdkError> {
let mnemonic: GeneratedKey<_, BareCtx> =
Mnemonic::generate((word_count, Language::English)).unwrap();
Ok(mnemonic.to_string())
}
uniffi::deps::static_assertions::assert_impl_all!(Wallet: Sync, Send);
// The goal of these tests to to ensure `bdk-ffi` intermediate code correctly calls `bdk` APIs.