Struct iop_keyvault_wasm::JsBip39
source · [−]pub struct JsBip39 { /* private fields */ }
Expand description
Tool for generating, validating and parsing BIP-0039 phrases in different supported languages.
Implementations
sourceimpl JsBip39
impl JsBip39
sourcepub fn new(lang_code: &str) -> Result<JsBip39, JsValue>
pub fn new(lang_code: &str) -> Result<JsBip39, JsValue>
Creates an object that can handle BIP39 phrases in a given language. (e.g. ‘en’)
sourcepub fn generate(&self) -> Result<JsBip39Phrase, JsValue>
pub fn generate(&self) -> Result<JsBip39Phrase, JsValue>
Creates a new phrase using the CSPRNG available on the platform.
sourcepub fn entropy(&self, entropy: &[u8]) -> Result<JsBip39Phrase, JsValue>
pub fn entropy(&self, entropy: &[u8]) -> Result<JsBip39Phrase, JsValue>
Creates a new phrase using the 256 bits of entropy provided in a buffer. IOP encourages using 24 word phrases everywhere.
sourcepub fn short_entropy(&self, entropy: &[u8]) -> Result<JsBip39Phrase, JsValue>
pub fn short_entropy(&self, entropy: &[u8]) -> Result<JsBip39Phrase, JsValue>
Creates a new phrase using the entropy provided in a buffer. This method is only for compatibility with other wallets. Check the BIP39 standard for the buffer sizes allowed.
sourcepub fn validate_phrase(&self, phrase: &str) -> Result<(), JsValue>
pub fn validate_phrase(&self, phrase: &str) -> Result<(), JsValue>
Validates a whole BIP39 mnemonic phrase. Because the phrase contains some checksum, the whole phrase can be invalid even when each word itself is valid. Note also, that the standards only allows NFKD normalization of Unicode codepoints, and a single space between words, but this library is more tolerant and provides normalization for those.
sourcepub fn list_words(&self, prefix: &str) -> Box<[JsValue]>
pub fn list_words(&self, prefix: &str) -> Box<[JsValue]>
Lists all words in the BIP39 dictionary, which start with the given prefix.
Can be used in 3 different ways:
- When the prefix is empty, the sorted list of all words are returned
- When the prefix is a partial word, the returned list can be used for auto-completion
- When the returned list is empty, the prefix is not a valid word in the dictionary
sourcepub fn phrase(&self, phrase: &str) -> Result<JsBip39Phrase, JsValue>
pub fn phrase(&self, phrase: &str) -> Result<JsBip39Phrase, JsValue>
Validates a whole 24-word BIP39 mnemonic phrase and returns an intermediate object that can be
later converted into a Seed
with an optional password.
sourcepub fn short_phrase(&self, phrase: &str) -> Result<JsBip39Phrase, JsValue>
pub fn short_phrase(&self, phrase: &str) -> Result<JsBip39Phrase, JsValue>
Validates a whole BIP39 mnemonic phrase and returns an intermediate object similar to {@link phrase}. This method is only for compatibility with other wallets. Check the BIP39 standard for the number of words allowed.
Trait Implementations
sourceimpl FromWasmAbi for JsBip39
impl FromWasmAbi for JsBip39
sourceimpl IntoWasmAbi for JsBip39
impl IntoWasmAbi for JsBip39
sourceimpl OptionFromWasmAbi for JsBip39
impl OptionFromWasmAbi for JsBip39
sourceimpl OptionIntoWasmAbi for JsBip39
impl OptionIntoWasmAbi for JsBip39
sourceimpl RefFromWasmAbi for JsBip39
impl RefFromWasmAbi for JsBip39
type Anchor = Ref<'static, JsBip39>
type Anchor = Ref<'static, JsBip39>
The type that holds the reference to Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous. Read more
sourceunsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
Recover a Self::Anchor
from Self::Abi
. Read more
sourceimpl RefMutFromWasmAbi for JsBip39
impl RefMutFromWasmAbi for JsBip39
Auto Trait Implementations
impl RefUnwindSafe for JsBip39
impl Send for JsBip39
impl Sync for JsBip39
impl Unpin for JsBip39
impl UnwindSafe for JsBip39
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
sourcefn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
. Read more