Utils#
- defichain.hdwallet.utils.generate_passphrase(length: int = 32) str #
Generate entropy hex string.
- Parameters:
length (int) – Passphrase length, default to 32.
- Returns:
str – Passphrase hex string.
>>> from defichain.hdwallet.utils import generate_passphrase >>> generate_passphrase(length=32) "N39rPfa3QvF2Tm2nPyoBpXNiBFXJywTz"
- defichain.hdwallet.utils.generate_entropy(strength: int = 128) str #
Generate entropy hex string.
- Parameters:
strength (int) – Entropy strength, default to 128.
- Returns:
str – Entropy hex string.
>>> from defichain.hdwallet.utils import generate_entropy >>> generate_entropy(strength=128) "ee535b143b0d9d1f87546f9df0d06b1a"
- defichain.hdwallet.utils.generate_mnemonic(language: str = 'english', strength: int = 256) str #
Generate mnemonic words.
- Parameters:
language (str) – Mnemonic language, default to english.
strength (int) – Entropy strength, default to 128.
- Returns:
str – Mnemonic words.
>>> from defichain.hdwallet.utils import generate_mnemonic >>> generate_mnemonic(language="french") "sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure"
- defichain.hdwallet.utils.is_entropy(entropy: str) bool #
Check entropy hex string.
- Parameters:
entropy (str) – entropy.
- Returns:
bool – Entropy valid/invalid.
>>> from defichain.hdwallet.utils import is_entropy >>> is_entropy(entropy="ee535b143b0d9d1f87546f9df0d06b1a") True
- defichain.hdwallet.utils.is_mnemonic(mnemonic: str, language: str | None = None) bool #
Check mnemonic words.
- Parameters:
mnemonic (str) – Mnemonic words.
language (str) – Mnemonic language, default to None.
- Returns:
bool – Mnemonic valid/invalid.
>>> from defichain.hdwallet.utils import is_mnemonic >>> is_mnemonic(mnemonic="sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure") True
- defichain.hdwallet.utils.get_entropy_strength(entropy: str) int #
Get entropy strength.
- Parameters:
entropy (str) – Entropy hex string.
- Returns:
int – Entropy strength.
>>> from defichain.hdwallet.utils import get_entropy_strength >>> get_entropy_strength(entropy="ee535b143b0d9d1f87546f9df0d06b1a") 128
- defichain.hdwallet.utils.get_mnemonic_strength(mnemonic: str, language: str | None = None) int #
Get mnemonic strength.
- Parameters:
mnemonic (str) – Mnemonic words.
language (str) – Mnemonic language, default to None.
- Returns:
int – Mnemonic strength.
>>> from defichain.hdwallet.utils import get_mnemonic_strength >>> get_mnemonic_strength(mnemonic="sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure") 128
- defichain.hdwallet.utils.get_mnemonic_language(mnemonic: str) str #
Get mnemonic language.
- Parameters:
mnemonic (str) – Mnemonic words.
- Returns:
str – Mnemonic language.
>>> from defichain.hdwallet.utils import get_mnemonic_language >>> get_mnemonic_language(mnemonic="sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure") "french"
- defichain.hdwallet.utils.entropy_to_mnemonic(entropy: str, language: str = 'english') str #
Get mnemonic from entropy hex string.
- Parameters:
entropy (str) – Entropy hex string.
language (str) – Mnemonic language, default to english.
- Returns:
str – Mnemonic words.
>>> from defichain.hdwallet.utils import entropy_to_mnemonic >>> entropy_to_mnemonic(entropy="ee535b143b0d9d1f87546f9df0d06b1a", language="korean") "학력 외침 주민 스위치 출연 연습 근본 여전히 울음 액수 귀신 마누라"
- defichain.hdwallet.utils.mnemonic_to_entropy(mnemonic: str, language: str | None = None) str #
Get entropy from mnemonic words.
- Parameters:
mnemonic (str) – Mnemonic words.
language (str) – Mnemonic language, default to english.
- Returns:
str – Enropy hex string.
>>> from defichain.hdwallet.utils import mnemonic_to_entropy >>> mnemonic_to_entropy(mnemonic="학력 외침 주민 스위치 출연 연습 근본 여전히 울음 액수 귀신 마누라", language="korean") "ee535b143b0d9d1f87546f9df0d06b1a"