aries_cloudagent.ledger package

Submodules

aries_cloudagent.ledger.base module

Ledger base class.

class aries_cloudagent.ledger.base.BaseLedger[source]

Bases: abc.ABC

Base class for ledger.

LEDGER_TYPE = None
accept_txn_author_agreement(taa_record: dict, mechanism: str, accept_time: int = None)[source]

Save a new record recording the acceptance of the TAA.

did_to_nym(did: str) → str[source]

Remove the ledger’s DID prefix to produce a nym.

fetch_txn_author_agreement()[source]

Fetch the current AML and TAA from the ledger.

get_endpoint_for_did(did: str) → str[source]

Fetch the endpoint for a ledger DID.

Parameters:did – The DID to look up on the ledger or in the cache
get_key_for_did(did: str) → str[source]

Fetch the verkey for a ledger DID.

Parameters:did – The DID to look up on the ledger or in the cache
get_latest_txn_author_acceptance()[source]

Look up the latest TAA acceptance.

get_txn_author_agreement(reload: bool = False)[source]

Get the current transaction author agreement, fetching it if necessary.

nym_to_did(nym: str) → str[source]

Format a nym with the ledger’s DID prefix.

register_nym(did: str, verkey: str, alias: str = None, role: str = None)[source]

Register a nym on the ledger.

Parameters:
  • did – DID to register on the ledger.
  • verkey – The verification key of the keypair.
  • alias – Human-friendly alias to assign to the DID.
  • role – For permissioned ledgers, what role should the new DID have.
taa_digest(version: str, text: str)[source]

Generate the digest of a TAA record.

update_endpoint_for_did(did: str, endpoint: str) → bool[source]

Check and update the endpoint on the ledger.

Parameters:
  • did – The ledger DID
  • endpoint – The endpoint address

aries_cloudagent.ledger.error module

Ledger related errors.

exception aries_cloudagent.ledger.error.BadLedgerRequestError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.ledger.error.LedgerError

The current request cannot proceed.

exception aries_cloudagent.ledger.error.ClosedPoolError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.ledger.error.LedgerError

Indy pool is closed.

exception aries_cloudagent.ledger.error.LedgerConfigError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.ledger.error.LedgerError

Base class for ledger configuration errors.

exception aries_cloudagent.ledger.error.LedgerError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.core.error.BaseError

Base class for ledger errors.

exception aries_cloudagent.ledger.error.LedgerTransactionError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.ledger.error.LedgerError

The ledger rejected the transaction.

aries_cloudagent.ledger.indy module

Indy ledger implementation.

class aries_cloudagent.ledger.indy.IndyErrorHandler(message: str = None, error_cls: Type[aries_cloudagent.ledger.error.LedgerError] = <class 'aries_cloudagent.ledger.error.LedgerError'>)[source]

Bases: object

Trap IndyError and raise an appropriate LedgerError instead.

classmethod wrap_error(err_value: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f46eb8>, message: str = None, error_cls: Type[aries_cloudagent.ledger.error.LedgerError] = <class 'aries_cloudagent.ledger.error.LedgerError'>) → aries_cloudagent.ledger.error.LedgerError[source]

Create an instance of LedgerError from an IndyError.

class aries_cloudagent.ledger.indy.IndyLedger(pool_name: str, wallet: aries_cloudagent.wallet.base.BaseWallet, *, keepalive: int = 0, cache: aries_cloudagent.cache.base.BaseCache = None, cache_duration: int = 600, read_only: bool = False)[source]

Bases: aries_cloudagent.ledger.base.BaseLedger

Indy ledger class.

LEDGER_TYPE = 'indy'
accept_txn_author_agreement(taa_record: dict, mechanism: str, accept_time: int = None)[source]

Save a new record recording the acceptance of the TAA.

check_existing_schema(public_did: str, schema_name: str, schema_version: str, attribute_names: Sequence[str]) → str[source]

Check if a schema has already been published.

check_pool_config() → bool[source]

Check if a pool config has been created.

close()[source]

Close the pool ledger.

create_pool_config(genesis_transactions: str, recreate: bool = False)[source]

Create the pool ledger configuration.

credential_definition_id2schema_id(credential_definition_id)[source]

From a credential definition, get the identifier for its schema.

Parameters:credential_definition_id – The identifier of the credential definition from which to identify a schema
fetch_credential_definition(credential_definition_id: str)[source]

Get a credential definition from the ledger by id.

Parameters:credential_definition_id – The cred def id of the cred def to fetch
fetch_schema_by_id(schema_id: str)[source]

Get schema from ledger.

Parameters:schema_id – The schema id (or stringified sequence number) to retrieve
Returns:Indy schema dict
fetch_schema_by_seq_no(seq_no: int)[source]

Fetch a schema by its sequence number.

Parameters:seq_no – schema ledger sequence number
Returns:Indy schema dict
fetch_txn_author_agreement()[source]

Fetch the current AML and TAA from the ledger.

get_credential_definition(credential_definition_id: str)[source]

Get a credential definition from the cache if available, otherwise the ledger.

Parameters:credential_definition_id – The schema id of the schema to fetch cred def for
get_endpoint_for_did(did: str) → str[source]

Fetch the endpoint for a ledger DID.

Parameters:did – The DID to look up on the ledger or in the cache
get_indy_storage() → aries_cloudagent.storage.indy.IndyStorage[source]

Get an IndyStorage instance for the current wallet.

get_key_for_did(did: str) → str[source]

Fetch the verkey for a ledger DID.

Parameters:did – The DID to look up on the ledger or in the cache
get_latest_txn_author_acceptance()[source]

Look up the latest TAA acceptance.

get_schema(schema_id: str)[source]

Get a schema from the cache if available, otherwise fetch from the ledger.

Parameters:schema_id – The schema id (or stringified sequence number) to retrieve
get_txn_author_agreement(reload: bool = False)[source]

Get the current transaction author agreement, fetching it if necessary.

nym_to_did(nym: str) → str[source]

Format a nym with the ledger’s DID prefix.

open()[source]

Open the pool ledger, creating it if necessary.

register_nym(did: str, verkey: str, alias: str = None, role: str = None)[source]

Register a nym on the ledger.

Parameters:
  • did – DID to register on the ledger.
  • verkey – The verification key of the keypair.
  • alias – Human-friendly alias to assign to the DID.
  • role – For permissioned ledgers, what role should the new DID have.
send_credential_definition(schema_id: str, tag: str = None)[source]

Send credential definition to ledger and store relevant key matter in wallet.

Parameters:
  • schema_id – The schema id of the schema to create cred def for
  • tag – Option tag to distinguish multiple credential definitions
send_schema(schema_name: str, schema_version: str, attribute_names: Sequence[str])[source]

Send schema to ledger.

Parameters:
  • schema_name – The schema name
  • schema_version – The schema version
  • attribute_names – A list of schema attributes
taa_digest(version: str, text: str)[source]

Generate the digest of a TAA record.

taa_rough_timestamp() → int[source]

Get a timestamp accurate to the day.

Anything more accurate is a privacy concern.

update_endpoint_for_did(did: str, endpoint: str) → bool[source]

Check and update the endpoint on the ledger.

Parameters:
  • did – The ledger DID
  • endpoint – The endpoint address
  • transport_vk – The endpoint transport verkey

aries_cloudagent.ledger.provider module

Default ledger provider classes.

class aries_cloudagent.ledger.provider.LedgerProvider[source]

Bases: aries_cloudagent.config.base.BaseProvider

Provider for the default ledger implementation.

LEDGER_CLASSES = {'indy': 'aries_cloudagent.ledger.indy.IndyLedger'}
provide(settings: aries_cloudagent.config.base.BaseSettings, injector: aries_cloudagent.config.base.BaseInjector)[source]

Create and open the ledger instance.

aries_cloudagent.ledger.routes module

Ledger admin routes.

class aries_cloudagent.ledger.routes.AMLRecordSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Ledger AML record.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.ledger.routes.TAAAcceptSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Input schema for accepting the TAA.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.ledger.routes.TAAAcceptanceSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

TAA acceptance record.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.ledger.routes.TAAInfoSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Transaction author agreement info.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.ledger.routes.TAARecordSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Ledger TAA record.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.ledger.routes.TAAResultSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Result schema for a transaction author agreement.

opts = <marshmallow.schema.SchemaOpts object>
aries_cloudagent.ledger.routes.get_did_endpoint(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf69aeff28>)[source]

Request handler for getting a verkey for a DID from the ledger.

Parameters:request – aiohttp request object
aries_cloudagent.ledger.routes.get_did_verkey(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf69aeff28>)[source]

Request handler for getting a verkey for a DID from the ledger.

Parameters:request – aiohttp request object
aries_cloudagent.ledger.routes.ledger_accept_taa(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf69aeff28>)[source]

Request handler for accepting the current transaction author agreement.

Parameters:request – aiohttp request object
Returns:The DID list response
aries_cloudagent.ledger.routes.ledger_get_taa(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf69aeff28>)[source]

Request handler for fetching the transaction author agreement.

Parameters:request – aiohttp request object
Returns:The TAA information including the AML
aries_cloudagent.ledger.routes.register(app: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf69aeff28>)[source]

Register routes.

aries_cloudagent.ledger.routes.register_ledger_nym(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf69aeff28>)[source]

Request handler for registering a NYM with the ledger.

Parameters:request – aiohttp request object

aries_cloudagent.ledger.util module

Ledger utilities.