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

[] (default) or list of DagAccount or EthAccount

Read more about account classes here.

hd_path

None (default) or str

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

None (default) or str

The extended key can be used to derive accounts.

root_key

None (default) or BIP32Key

Derive child (BIP index) from root_key to derive the signing key for the BIP32 account. Here the package bip32utils is used.

network

None (default) or str

“Constellation” or “Ethereum”.

mnemonic

None (default) or str

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: BaseModel

Hierarchical 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

export_account(account) str[source]
extended_key: str | None
get_account_by_address(address: str) DagAccount | EthAccount[source]
get_accounts() List[source]
get_extended_public_key() str[source]
get_hd_path() str[source]
get_network() str[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].

model_serialize() Dict[str, Any][source]
network: str | None
remove_account(account)[source]
remove_last_added_account()[source]
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

[] (default) or list of DagAccount or EthAccount

Read more about account classes here.

network

str = “Constellation” (default)

“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
add_account_at(index: int)[source]

Not supported for SimpleKeyring

create_for_network(network, private_key: str) Self[source]
deserialize(network: str, accounts: list)[source]
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).

get_state()[source]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_serialize() Dict[str, Any][source]
network: str
remove_account(account)[source]

Not supported for SimpleKeyring