Keyrings¶
Notice
The keyring manager contains methods for easily managing wallet operations.
The keyring classes stores the account data and keys.
Hierarchical Deterministic Keyring¶
This keyring type stores account data and keys for hierarchical deterministic (HD) wallets (see, keyring manager). Here private keys (accounts) are generated from a master/root seed. Thus, HD wallets supports multiple chains and accounts per wallet.
Parameters
Parameter |
Type |
Description |
|---|---|---|
accounts |
|
Read more about account classes here. |
hd_path |
|
Path used to derive accounts from master/root key. The DAG chain has the ID 1137. Thus, the DAG derivation path is “m/44’/1137’/0’/0” + the BIP44 index for the account. |
extended_key |
|
The extended key can be used to derive accounts. |
root_key |
|
Derive child (BIP index) from |
network |
|
“Constellation” or “Ethereum”. |
mnemonic |
|
12 words seed phrase. |
Full List of HD Keyring Methods¶
- class pypergraph.keyring.keyrings.hd_keyring.HdKeyring(*, accounts: ~typing.List[~pypergraph.keyring.accounts.ecdsa_account.EcdsaAccount] = <factory>, hd_path: str | None = None, mnemonic: str | None = None, extended_key: str | None = None, root_key: ~bip32utils.BIP32Key.BIP32Key | None = None, network: str | None = None)[source]¶
Bases:
BaseModelHierarchical Deterministic Keyring: BIP32
- accounts: List[EcdsaAccount]¶
- add_account_at(index: int = 0) DagAccount | EthAccount | EcdsaAccount[source]¶
Add account class object with a signing key to the keyring being constructed.
- Parameters:
index – Account number (bipIndex).
- Returns:
EcdsaAccount or DagAccount class object (dag_keyring.accounts) with signing key at self.wallet.
- create(mnemonic: str, hd_path: str, network: str, number_of_accounts: int = 1) Self[source]¶
Create a hierarchical deterministic keyring.
- Parameters:
mnemonic – Mnemonic phrase.
hd_path – The derivation path for the coin chain (without index).
network – The network associated with the coin.
number_of_accounts – How many accounts (indexes) to create.
- Returns:
Hierarchical deterministic keyring.
- create_accounts(number_of_accounts: int = 0) List[Dict][source]¶
When adding an account (after accounts have been removed), it will add back the ones removed first.
- Parameters:
number_of_accounts – The number of accounts to create.
- Returns List[dict]:
A list of dictionaries with bip44 index.
- create_from_extended_key(extended_key: str, network: NetworkId, number_of_accounts: int) Self[source]¶
- deserialize(data: dict)[source]¶
Deserialize then add account (bip44_index) to the keyring being constructed.
- Parameters:
data
- extended_key: str | None¶
- get_account_by_address(address: str) DagAccount | EthAccount[source]¶
- hd_path: str | None¶
- mnemonic: str | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- network: str | None¶
- root_key: BIP32Key | None¶
Simple Keyring¶
The simple keyring stores simple account data and private key. Unlike the HD keyring above, simple keyrings only supports one private key per account.
Parameters
Parameter |
Type |
Description |
|---|---|---|
account |
|
Read more about account classes here. |
network |
|
“Constellation” or “Ethereum” is currently supported. |
Full List of Simple Keyring Methods¶
- class pypergraph.keyring.keyrings.simple_keyring.SimpleKeyring(*, account: EcdsaAccount = None, network: str = 'Constellation')[source]¶
Bases:
BaseModel- account: EcdsaAccount¶
- get_account_by_address(address: str)[source]¶
Get the account matching the specified address.
- Returns:
Account class or None is nothing matches.
- get_accounts() List[DagAccount | EthAccount | Any][source]¶
Get all accounts in the simple keyring.
- Returns:
List of account classes (only one).
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- network: str¶