Seeds¶
- class hdwallet.seeds.SEEDS¶
A class that manages a dictionary of seeds classes.
This class provides methods to retrieve names and classes of various seeds implementations, as well as methods to validate and access specific seeds classes by name.
Here are available SEED names:
Name
Class
Algorand
BIP39
Cardano
Electrum-V1
Electrum-V2
Monero
- classmethod names() List[str]¶
Get the list of seed class names.
- Returns:
A list of seed class names.
- Return type:
List[str]
- classmethod classes() List[Type[ISeed]]¶
Get the list of seed classes.
- Returns:
A list of seed classes.
- Return type:
List[Type[ISeed]]
- classmethod seed(name: str) Type[ISeed]¶
Retrieve an seed class by its name.
- Parameters:
name (str) – The name of the seed class.
- Returns:
The seed class corresponding to the given name.
- Return type:
Type[ISeed]
- classmethod is_seed(name) bool¶
Check if a given name is a valid seed name.
- Parameters:
name (str) – The name to check.
- Returns:
True if the name is valid, False otherwise.
- Return type:
bool
>>> from hdwallet.seeds import SEEDS
>>> SEEDS.names()
['Algorand', 'BIP39', 'Cardano', 'Electrum-V1', 'Electrum-V2', 'Monero']
>>> SEEDS.classes()
[<class 'hdwallet.seeds.algorand.AlgorandSeed'>, <class 'hdwallet.seeds.bip39.BIP39Seed'>, <class 'hdwallet.seeds.cardano.CardanoSeed'>, <class 'hdwallet.seeds.electrum.v1.ElectrumV1Seed'>, <class 'hdwallet.seeds.electrum.v2.ElectrumV2Seed'>, <class 'hdwallet.seeds.monero.MoneroSeed'>]
>>> from hdwallet.seeds import BIP39Seed
>>> SEEDS.seed(name="Algorand")
<class 'hdwallet.seeds.algorand.AlgorandSeed'>
>>> SEEDS.seed(name="BIP39")
<class 'hdwallet.seeds.bip39.BIP39Seed'>
>>> SEEDS.seed(name="BIP39") == BIP39Seed
True
>>> SEEDS.is_seed(name="Electrum-V2")
True
- class hdwallet.seeds.iseed.ISeed(seed: str, **kwargs)¶
- classmethod is_valid(seed: str) bool¶
Checks if the given seed is valid.
- Parameters:
seed (str) – Hex string representing seed
- Returns:
True if is valid, False otherwise.
- Return type:
bool
- seed() str¶
Retrieves the seed associated with the current instance.
- Returns:
The seed as a string.
- Return type:
str
- class hdwallet.seeds.algorand.AlgorandSeed(seed: str, **kwargs)¶
This class generates a root extended private key from a given seed using the Algorand standard. The Algorand standard defines a method for generating mnemonic phrases and converting them into a binary seed used for hierarchical deterministic wallets.
Note
This class inherits from the
ISeedclass, thereby ensuring that all functions are accessible.- classmethod name() str¶
Get the name of the seeds class.
- Returns:
The name of the seeds class.
- Return type:
str
- classmethod from_mnemonic(mnemonic: str | IMnemonic, **kwargs) str¶
Converts a mnemonic phrase to its corresponding seed.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be decoded. Can be a string or an instance of IMnemonic.
- Returns:
The decoded entropy as a string.
- Return type:
str
>>> from hdwallet.seeds.algorand import AlgorandSeed
>>> AlgorandSeed.from_mnemonic(mnemonic="outer special dice battle mouse afraid half nut marble reason journey north hole measure mango cargo learn actress slogan analyst lunar marriage gaze above twelve")
'ea3cf47a345148120cad973dc4ecf06459b627e6b022f6b3c09785804221168c'
>>> algorand_seed: AlgorandSeed = AlgorandSeed(seed="ea3cf47a345148120cad973dc4ecf06459b627e6b022f6b3c09785804221168c")
>>> algorand_seed.name()
'Algorand'
>>> algorand_seed.seed()
'ea3cf47a345148120cad973dc4ecf06459b627e6b022f6b3c09785804221168c'
- class hdwallet.seeds.bip39.BIP39Seed(seed: str, **kwargs)¶
This class generates a root extended private key from a given seed using the BIP39 standard. The BIP39 standard defines a method for generating mnemonic phrases and converting them into a binary seed used for hierarchical deterministic wallets.
Note
This class inherits from the
ISeedclass, thereby ensuring that all functions are accessible.- classmethod name() str¶
Get the name of the seeds class.
- Returns:
The name of the seeds class.
- Return type:
str
- classmethod from_mnemonic(mnemonic: str | IMnemonic, passphrase: str | None = None) str¶
Converts a mnemonic phrase to its corresponding seed.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be decoded. Can be a string or an instance of IMnemonic.
passphrase (Optional[str]) – An optional passphrase used for additional security when decoding the mnemonic phrase.
- Returns:
The decoded seed as a string.
- Return type:
str
>>> from hdwallet.seeds.bip39 import BIP39Seed
>>> bip39_seed.from_mnemonic(mnemonic="인생 생활 일반 통계 근육 근래 기온 사랑 관심 양주 국제 피아노")
'b43f7e1a19a71f3fab6f7a125e3c1c11789c1144a91c480928f1bdf48e083e623db7ff6abf865696388899cd49d7299601bba77afd95d1c0bfe897284aaadda2'
>>> bip39_seed: BIP39Seed = BIP39Seed(seed="b43f7e1a19a71f3fab6f7a125e3c1c11789c1144a91c480928f1bdf48e083e623db7ff6abf865696388899cd49d7299601bba77afd95d1c0bfe897284aaadda2")
>>> bip39_seed.name()
'BIP39'
>>> bip39_seed.seed()
'b43f7e1a19a71f3fab6f7a125e3c1c11789c1144a91c480928f1bdf48e083e623db7ff6abf865696388899cd49d7299601bba77afd95d1c0bfe897284aaadda2'
- class hdwallet.seeds.cardano.CardanoSeed(seed: str, cardano_type: str = 'byron-icarus', passphrase: str | None = None)¶
This class generates a root extended private key from a given seed using the cardano standard. The cardano standard defines a method for generating mnemonic phrases and converting them into a binary seed used for hierarchical deterministic wallets.
Note
This class inherits from the
ISeedclass, thereby ensuring that all functions are accessible.- classmethod name() str¶
Get the name of the seeds class.
- Returns:
The name of the seeds class.
- Return type:
str
- cardano_type() str¶
Returns the Cardano type associated with this instance.
- Returns:
The Cardano type as a string.
- Return type:
str
- classmethod is_valid(seed: str, cardano_type: str = 'byron-icarus') bool¶
Checks if the given seed is valid.
- Parameters:
seed (str) – Hex string representing seed
cardano_type (str, optional) – The type of Cardano seed. Defaults to Cardano.TYPES.BYRON_ICARUS.
- Returns:
True if is valid, False otherwise.
- Return type:
bool
- classmethod from_mnemonic(mnemonic: str | IMnemonic, passphrase: str | None = None, cardano_type: str = 'byron-icarus') str¶
Generates a Cardano wallet seed based on the specified cardano_type.
This method allows generating different types of Cardano wallet seeds based on the cardano_type parameter.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be used for seed generation. Can be a string or an instance of IMnemonic.
passphrase (Optional[str]) – Optional passphrase used for seed derivation, default is None.
cardano_type (str) – Specifies the type of Cardano seed to generate. Default is Byron Icarus. Valid options are defined in Cardano.TYPES.
- Returns:
The generated Cardano wallet seed as a string.
- Return type:
str
- classmethod generate_byron_icarus(mnemonic: str | IMnemonic) str¶
Generates a Byron Icarus seed from a given mnemonic phrase.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be used for seed generation. Can be a string or an instance of IMnemonic.
- Returns:
The derived Byron Icarus seed as a string.
- Return type:
str
- classmethod generate_byron_ledger(mnemonic: str | IMnemonic, passphrase: str | None = None) str¶
Generates a Byron Ledger seed from a given mnemonic phrase and optional passphrase.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be used for seed generation. Can be a string or an instance of IMnemonic.
passphrase (Optional[str]) – An optional passphrase to be used in the seed generation process.
- Returns:
The derived Byron Ledger seed as a string.
- Return type:
str
- classmethod generate_byron_legacy(mnemonic: str | IMnemonic) str¶
Generates a Byron Legacy seed from a given mnemonic phrase.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be used for seed generation. Can be a string or an instance of IMnemonic.
- Returns:
The derived Byron Legacy seed as a string.
- Return type:
str
- classmethod generate_shelley_icarus(mnemonic: str | IMnemonic) str¶
Generates a Shelley Icarus seed from a given mnemonic phrase.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be used for seed generation. Can be a string or an instance of IMnemonic.
- Returns:
The derived Shelley Icarus seed as a string.
- Return type:
str
- classmethod generate_shelley_ledger(mnemonic: str, passphrase: str | None = None) str¶
Generates a Shelley ledger seed from a given mnemonic phrase and optional passphrase.
- Parameters:
mnemonic (str) – The mnemonic phrase to be used for seed generation.
passphrase (Optional[str]) – An optional passphrase to strengthen the security of the seed. Defaults to None.
- Returns:
The derived Shelley ledger seed as a string.
- Return type:
str
>>> from hdwallet.seeds.cardano import CardanoSeed
>>>CardanoSeed.from_mnemonic(mnemonic="возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно")
'1d9eb3c129f55ca568f20ff85df8ac7c'
>>> cardano_seed: CardanoSeed = CardanoSeed(seed="1d9eb3c129f55ca568f20ff85df8ac7c")
>>> cardano_seed.name()
'Cardano'
>>> cardano_seed.seed()
'1d9eb3c129f55ca568f20ff85df8ac7c'
>>> cardano_seed.generate_byron_icarus(mnemonic="возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно")
'1d9eb3c129f55ca568f20ff85df8ac7c'
>>> cardano_seed.generate_byron_ledger(mnemonic="возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно")
'638a38b69826d3f43539061739363c45b1bc8831c2c0c6f94e2e66e1e3d56de9fdfa86d53615b3c98df4f12de384c3b392e156689d66a2d51759d66422b17117'
>>> cardano_seed.generate_byron_legacy(mnemonic="возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно")
'bf4c9d6ffb5dc8e958f3e545ed2cb0dabbd4cefce4b9e89d70a95aae45aa102e'
>>> cardano_seed.generate_shelley_icarus(mnemonic="возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно")
'1d9eb3c129f55ca568f20ff85df8ac7c'
>>> cardano_seed.generate_shelley_ledger(mnemonic="возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно")
'638a38b69826d3f43539061739363c45b1bc8831c2c0c6f94e2e66e1e3d56de9fdfa86d53615b3c98df4f12de384c3b392e156689d66a2d51759d66422b17117'
- class hdwallet.seeds.electrum.v1.ElectrumV1Seed(seed: str, **kwargs)¶
This class generates a root extended private key from a given seed using the Electrum-V1 standard. The Electrum-V1 standard defines a method for generating mnemonic phrases and converting them into a binary seed used for hierarchical deterministic wallets.
Note
This class inherits from the
ISeedclass, thereby ensuring that all functions are accessible.- classmethod name() str¶
Get the name of the seeds class.
- Returns:
The name of the seeds class.
- Return type:
str
- classmethod from_mnemonic(mnemonic: str | IMnemonic, **kwargs) str¶
Converts an Electrum V1 mnemonic phrase to its corresponding hashed entropy.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be decoded. Can be a string or an instance of IMnemonic.
- Returns:
The hashed entropy as a string.
- Return type:
str
>>>from hdwallet.seeds.electrum.v1 import ElectrumV1Seed >>>ElectrumV1Seed.from_mnemonic(mnemonic=”stretch sister juice brother youth egg salt join lesson cover grin journey”) ‘98cc82dcea53272eb75f244a38b93b0e182ef4c7c0ca012b6b4622c970f5842b’ >>>electrumv1_seed: ElectrumV1Seed = ElectrumV1Seed(seed=”98cc82dcea53272eb75f244a38b93b0e182ef4c7c0ca012b6b4622c970f5842b”) >>>electrumv1_seed.name() ‘Electrum-V1’ >>> electrumv1_seed.seed() ‘98cc82dcea53272eb75f244a38b93b0e182ef4c7c0ca012b6b4622c970f5842b’
- class hdwallet.seeds.electrum.v2.ElectrumV2Seed(seed: str, **kwargs)¶
This class generates a root extended private key from a given seed using the Electrum-V2 standard. The Electrum-V2 standard defines a method for generating mnemonic phrases and converting them into a binary seed used for hierarchical deterministic wallets.
Note
This class inherits from the
ISeedclass, thereby ensuring that all functions are accessible.- classmethod name() str¶
Get the name of the seeds class.
- Returns:
The name of the seeds class.
- Return type:
str
- classmethod from_mnemonic(mnemonic: str | IMnemonic, passphrase: str | None = None, mnemonic_type='standard') str¶
Converts an Electrum V2 mnemonic phrase to its corresponding seed.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be decoded. Can be a string or an instance of IMnemonic.
passphrase (Optional[str]) – An optional passphrase to strengthen the security of the seed. Defaults to None.
mnemonic_type (str) – The type of Electrum V2 mnemonic, defaults to STANDARD.
- Returns:
The derived seed as a string.
- Return type:
str
>>> from hdwallet.seeds.electrum.v2 import ElectrumV2Seed
>>> ElectrumV2Seed.from_mnemonic(mnemonic="servo privado viaduto caixote agachar inspetor albergue seleto cuspir apontar obedecer tacho")
'a15b1990667046d688eb0fed7fd8789487c0b919dff86778bf31b5abb83a5d8471bcc9d4a1d2f97eef84ab334bbb30804b4001f73ae7b02353c1e2040f758bb5'
>>> electrumv2_seed: ElectrumV2Seed = ElectrumV2Seed(seed="a15b1990667046d688eb0fed7fd8789487c0b919dff86778bf31b5abb83a5d8471bcc9d4a1d2f97eef84ab334bbb30804b4001f73ae7b02353c1e2040f758bb5")
>>> electrumv2_seed.name()
'Electrum-V2'
>>> electrumv2_seed.seed()
'a15b1990667046d688eb0fed7fd8789487c0b919dff86778bf31b5abb83a5d8471bcc9d4a1d2f97eef84ab334bbb30804b4001f73ae7b02353c1e2040f758bb5'
- class hdwallet.seeds.monero.MoneroSeed(seed: str, **kwargs)¶
This class generates a root extended private key from a given seed using the Monero standard. The Monero standard defines a method for generating mnemonic phrases and converting them into a binary seed used for hierarchical deterministic wallets.
Note
This class inherits from the
ISeedclass, thereby ensuring that all functions are accessible.- classmethod name() str¶
Get the name of the seeds class.
- Returns:
The name of the seeds class.
- Return type:
str
- classmethod from_mnemonic(mnemonic: str | IMnemonic, **kwargs) str¶
Converts a mnemonic phrase to its corresponding seed.
- Parameters:
mnemonic (Union[str, IMnemonic]) – The mnemonic phrase to be decoded. Can be a string or an instance of IMnemonic.
- Returns:
The decoded entropy as a string.
- Return type:
str
>>> from hdwallet.seeds.monero import MoneroSeed
>>> MoneroSeed.from_mnemonic(mnemonic="签 箱 些 芽 企 靠 除 森 页 摇 降 咱")
'14910059f5fa36208f3f431447a7037e'
>>>monero_seed: MoneroSeed = MoneroSeed(seed="14910059f5fa36208f3f431447a7037e")
>>> monero_seed.name()
'Monero'
>>> monero_seed.seed()
'14910059f5fa36208f3f431447a7037e'