substrate
Module for Substrate keys computation and derivation.
- class SubstrateConst
Bases:
object
Class container for Substrate constants.
- SEED_MIN_BYTE_LEN: int = 32
- class Substrate(priv_key: Optional[Union[bytes, IPrivateKey]], pub_key: Optional[Union[bytes, IPublicKey]], path: SubstratePath, coin_conf: SubstrateCoinConf)
Bases:
object
Substrate class. It allows to compute Substrate keys and addresses.
- classmethod FromSeed(seed_bytes: bytes, coin_type: SubstrateCoins) Substrate
Create a Substrate object from the specified seed.
- Parameters:
seed_bytes (bytes) – Seed bytes
coin_type (SubstrateCoins) – Coin type
- Returns:
Substrate object
- Return type:
Substrate object
- Raises:
TypeError – If coin_type is not of SubstrateCoins enum
ValueError – If the seed length is not valid
- classmethod FromSeedAndPath(seed_bytes: bytes, path: Union[str, SubstratePath], coin_type: SubstrateCoins) Substrate
Create a Substrate object from the specified seed and path.
- Parameters:
seed_bytes (bytes) – Seed bytes
path (str or SubstratePath object) – Path
coin_type (SubstrateCoins) – Coin type
- Returns:
Substrate object
- Return type:
Substrate object
- Raises:
TypeError – If coin_type is not of SubstrateCoins enum
ValueError – If the seed length is not valid
SubstratePathError – If the path is not valid
- classmethod FromPrivateKey(priv_key: Union[bytes, IPrivateKey], coin_type: SubstrateCoins) Substrate
Create a Substrate object from the specified private key.
- Parameters:
priv_key (bytes or IPrivateKey) – Private key
coin_type (SubstrateCoins) – Coin type
- Returns:
Substrate object
- Return type:
Substrate object
- Raises:
TypeError – If coin_type is not of SubstrateCoins enum
SubstrateKeyError – If the key is not valid
- classmethod FromPublicKey(pub_key: Union[bytes, IPublicKey], coin_type: SubstrateCoins) Substrate
Create a Substrate object from the specified public key.
- Parameters:
pub_key (bytes or IPublicKey) – Public key
coin_type (SubstrateCoins) – Coin type
- Returns:
Substrate object
- Return type:
Substrate object
- Raises:
TypeError – If coin_type is not of SubstrateCoins enum
SubstrateKeyError – If the key is not valid
- m_priv_key: Optional[SubstratePrivateKey]
- m_pub_key: SubstratePublicKey
- m_path: SubstratePath
- m_coin_conf: SubstrateCoinConf
- ChildKey(path_elem: Union[str, SubstratePathElem]) Substrate
Create and return a child key of the current one with the specified path element.
- Parameters:
path_elem (str or SubstratePathElem object) – Path element
- Returns:
Substrate object
- Return type:
Substrate object
- Raises:
SubstrateKeyError – If the index results in invalid keys
- DerivePath(path: Union[str, SubstratePath]) Substrate
Derive children keys from the specified path.
- Parameters:
path (str or SubstratePath object) – Path
- Returns:
Substrate object
- Return type:
Substrate object
- Raises:
SubstratePathError – If the path is not valid
- ConvertToPublic() None
Convert a private Substrate object into a public one.
- IsPublicOnly() bool
Get if it’s public-only.
- Returns:
True if public-only, false otherwise
- Return type:
bool
- CoinConf() SubstrateCoinConf
Return coin configuration.
- Returns:
SubstrateCoinConf object
- Return type:
SubstrateCoinConf object
- Path() SubstratePath
Return path.
- Returns:
SubstratePath object
- Return type:
SubstratePath object
- PrivateKey() SubstratePrivateKey
Return private key object.
- Returns:
SubstratePrivateKey object
- Return type:
SubstratePrivateKey object
- Raises:
SubstrateKeyError – If internal key is public-only
- PublicKey() SubstratePublicKey
Return public key object.
- Returns:
SubstratePublicKey object
- Return type:
SubstratePublicKey object