feat: add display trait to mnemonic

This commit is contained in:
Matthew 2024-06-12 20:03:51 -05:00
parent 84f1329e84
commit 94d31ff7ed
No known key found for this signature in database
GPG Key ID: 8D4FCD82DD54DDD2
2 changed files with 6 additions and 4 deletions

View File

@ -454,6 +454,7 @@ interface BumpFeeTxBuilder {
// bdk crate - descriptor module // bdk crate - descriptor module
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
[Traits=(Display)]
interface Mnemonic { interface Mnemonic {
constructor(WordCount word_count); constructor(WordCount word_count);
@ -462,8 +463,6 @@ interface Mnemonic {
[Name=from_entropy, Throws=Bip39Error] [Name=from_entropy, Throws=Bip39Error]
constructor(sequence<u8> entropy); constructor(sequence<u8> entropy);
string as_string();
}; };
interface DerivationPath { interface DerivationPath {

View File

@ -1,4 +1,5 @@
use crate::error::{Bip32Error, Bip39Error, DescriptorKeyError}; use crate::error::{Bip32Error, Bip39Error, DescriptorKeyError};
use std::fmt::Display;
use bdk_wallet::bitcoin::bip32::DerivationPath as BdkDerivationPath; use bdk_wallet::bitcoin::bip32::DerivationPath as BdkDerivationPath;
use bdk_wallet::bitcoin::key::Secp256k1; use bdk_wallet::bitcoin::key::Secp256k1;
@ -44,9 +45,11 @@ impl Mnemonic {
.map(Mnemonic) .map(Mnemonic)
.map_err(Bip39Error::from) .map_err(Bip39Error::from)
} }
}
pub(crate) fn as_string(&self) -> String { impl Display for Mnemonic {
self.0.to_string() fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
} }
} }