Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add display trait to mnemonic #558

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ interface BumpFeeTxBuilder {
// bdk crate - descriptor module
// ------------------------------------------------------------------------

[Traits=(Display)]
interface Mnemonic {
constructor(WordCount word_count);

Expand All @@ -462,8 +463,6 @@ interface Mnemonic {

[Name=from_entropy, Throws=Bip39Error]
constructor(sequence<u8> entropy);

string as_string();
};

interface DerivationPath {
Expand Down
7 changes: 5 additions & 2 deletions bdk-ffi/src/keys.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::error::{Bip32Error, Bip39Error, DescriptorKeyError};
use std::fmt::Display;

use bdk_wallet::bitcoin::bip32::DerivationPath as BdkDerivationPath;
use bdk_wallet::bitcoin::key::Secp256k1;
Expand Down Expand Up @@ -44,9 +45,11 @@ impl Mnemonic {
.map(Mnemonic)
.map_err(Bip39Error::from)
}
}

pub(crate) fn as_string(&self) -> String {
self.0.to_string()
impl Display for Mnemonic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

Expand Down
Loading