graphenestorage.interfaces module

class graphenestorage.interfaces.ConfigInterface(*args, **kwargs)

Bases: graphenestorage.interfaces.StoreInterface

The BaseKeyStore defines the interface for key storage

Note

This class inherits graphenestorage.interfaces.StoreInterface and defines no additional configuration-specific methods.

class graphenestorage.interfaces.EncryptedKeyInterface(*args, **kwargs)

Bases: graphenestorage.interfaces.KeyInterface

The EncryptedKeyInterface extends KeyInterface to work with encrypted keys

is_encrypted()

Returns True/False to indicate required use of unlock

lock()

Lock the wallet again

locked()

is the wallet locked?

unlock(password)

Tries to unlock the wallet if required

Parameters:password (str) – Plain password
class graphenestorage.interfaces.KeyInterface(*args, **kwargs)

Bases: graphenestorage.interfaces.StoreInterface

The KeyInterface defines the interface for key storage.

Note

This class inherits graphenestorage.interfaces.StoreInterface and defines additional key-specific methods.

add(wif, pub=None)
Add a new public/private key pair (correspondence has to be
checked elsewhere!)
Parameters:
  • pub (str) – Public key
  • wif (str) – Private key
delete(pub)

Delete a pubkey/privatekey pair from the store

Parameters:pub (str) – Public key
getPrivateKeyForPublicKey(pub)
Returns the (possibly encrypted) private key that
corresponds to a public key
Parameters:pub (str) – Public key

The encryption scheme is BIP38

getPublicKeys()

Returns the public keys stored in the database

is_encrypted()

Returns True/False to indicate required use of unlock

class graphenestorage.interfaces.StoreInterface(*args, **kwargs)

Bases: dict

The store interface is the most general store that we can have.

It inherits dict and thus behaves like a dictionary. As such any key/value store can be used as store with or even without an adaptor.

Note

This class defines defaults that are used to return reasonable defaults for the library.

Warning

If you are trying to obtain a value for a key that does not exist in the store, the library will NOT raise but return a None value. This represents the biggest difference to a regular dict class.

Methods that need to be implemented:

  • def setdefault(cls, key, value)
  • def __init__(self, *args, **kwargs)
  • def __setitem__(self, key, value)
  • def __getitem__(self, key)
  • def __iter__(self)
  • def __len__(self)
  • def __contains__(self, key)

Note

Configuration and Key classes are subclasses of this to allow storing keys separate from configuration.

defaults = {}
delete(key)

Delete a key from the store

get(key, default=None)

Return the key if exists or a default value

items()

Returns all items off the store as tuples

classmethod setdefault(key, value)

Allows to define default values

wipe()

Wipe the store