Utils

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 hdwallet.utils import generate_passphrase
>>> generate_passphrase(length=32)
"N39rPfa3QvF2Tm2nPyoBpXNiBFXJywTz"
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 hdwallet.utils import generate_entropy
>>> generate_entropy(strength=128)
"ee535b143b0d9d1f87546f9df0d06b1a"
hdwallet.utils.generate_mnemonic(language: str = 'english', strength: int = 128) str

Generate mnemonic words.

Parameters
  • language (str) – Mnemonic language, default to english.

  • strength (int) – Entropy strength, default to 128.

Returns

str – Mnemonic words.

>>> from hdwallet.utils import generate_mnemonic
>>> generate_mnemonic(language="french")
"sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure"
hdwallet.utils.is_entropy(entropy: str) bool

Check entropy hex string.

Parameters

entropy (str) – Mnemonic words.

Returns

bool – Entropy valid/invalid.

>>> from hdwallet.utils import is_entropy
>>> is_entropy(entropy="ee535b143b0d9d1f87546f9df0d06b1a")
True
hdwallet.utils.is_mnemonic(mnemonic: str, language: Optional[str] = None) bool

Check mnemonic words.

Parameters
  • mnemonic (str) – Mnemonic words.

  • language (str) – Mnemonic language, default to None.

Returns

bool – Mnemonic valid/invalid.

>>> from hdwallet.utils import is_mnemonic
>>> is_mnemonic(mnemonic="sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure")
True
hdwallet.utils.get_entropy_strength(entropy: str) int

Get entropy strength.

Parameters

entropy (str) – Entropy hex string.

Returns

int – Entropy strength.

>>> from hdwallet.utils import get_entropy_strength
>>> get_entropy_strength(entropy="ee535b143b0d9d1f87546f9df0d06b1a")
128
hdwallet.utils.get_mnemonic_strength(mnemonic: str, language: Optional[str] = None) int

Get mnemonic strength.

Parameters
  • mnemonic (str) – Mnemonic words.

  • language (str) – Mnemonic language, default to None.

Returns

int – Mnemonic strength.

>>> from hdwallet.utils import get_mnemonic_strength
>>> get_mnemonic_strength(mnemonic="sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure")
128
hdwallet.utils.get_mnemonic_language(mnemonic: str) str

Get mnemonic language.

Parameters

mnemonic (str) – Mnemonic words.

Returns

str – Mnemonic language.

>>> from hdwallet.utils import get_mnemonic_language
>>> get_mnemonic_language(mnemonic="sceptre capter séquence girafe absolu relatif fleur zoologie muscle sirop saboter parure")
"french"
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 hdwallet.utils import entropy_to_mnemonic
>>> entropy_to_mnemonic(entropy="ee535b143b0d9d1f87546f9df0d06b1a", language="korean")
"학력 외침 주민 스위치 출연 연습 근본 여전히 울음 액수 귀신 마누라"
hdwallet.utils.mnemonic_to_entropy(mnemonic: str, language: Optional[str] = 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 hdwallet.utils import mnemonic_to_entropy
>>> mnemonic_to_entropy(mnemonic="학력 외침 주민 스위치 출연 연습 근본 여전히 울음 액수 귀신 마누라", language="korean")
"ee535b143b0d9d1f87546f9df0d06b1a"