You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
9866649 Added Mnemonic Interface (dhruvbaliyan)
Pull request description:
### Description
This PR adds `interface Mnemonic` which will make the API to generate new DescriptorSecretKey have type-safe arguments.
<!-- Describe the purpose of this PR, what's being adding and/or fixed -->
### Notes to the reviewers
This PR doesn't have any issue linked to it, as it was discusses on a call during the implementation of `DescriptorSecretKey` (PR #154). It was discussed to make `Mnemonic` an interface and use that instead of string `Mnemonic` so that the API to generate `DescriptorSecretKey` doesn't have any potential failure (like in case it's provided with incorrect Mnemonic words).
APIs added
```
// generates and returns Mnemonic with random entropy
Mnemonic::new(word_count: WordCount) -> Self { ... }
// converts string Mnemonic to Mnemonic type with error (in case of incorrect string Mnemonic)
Mnemonic::from_str(mnemonic: String) -> Result<Self, BdkError> { ... }
// generates and returns Mnemonic with given entropy
Mnemonic::from_entropy(entropy: Vec<u8>) -> Result<Self, BdkError> {...}
// view mnemonic as string
Mnemonic::as_string(&self) -> String { ... }
```
Along with some changes to `DescriptorSecretKey::new()` to fit these new APIs
### Changelog notice
```
- Added Struct Mnemonic with following methods [#219]
- new(word_count: WordCount) generates and returns Mnemonic with random entropy
- from_str(mnemonic: String) converts string Mnemonic to Mnemonic type with error
- from_entropy(entropy: Vec<u8>) generates and returns Mnemonic with given entropy
- as_string() view Mnemonic as string
- API removed [#219]
- generate_mnemonic(word_count: WordCount)
[#219](#219)
```
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [x] I've added docs for the new feature
#### Bugfixes:
* [x] This pull request breaks the existing API
* Top level function `generate_mnemonic(...)` was removed
ACKs for top commit:
thunderbiscuit:
ACK 9866649.
notmandatory:
ACK 9866649
Tree-SHA512: 45f9158beb6fe7bfe2a901c3f17126db855fe0b4b479ecb2a16381e06a415eed295fe6be3c840bd1d1fc8cffaf58bd97dc27bdc1e82699367a827d700e8fd09b
0 commit comments