nectarstorage.interfaces module

class nectarstorage.interfaces.ConfigInterface(*_args, **_kwargs)

Bases: StoreInterface

The BaseKeyStore defines the interface for key storage

Note

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

class nectarstorage.interfaces.EncryptedKeyInterface(*_args, **_kwargs)

Bases: 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 nectarstorage.interfaces.EncryptedTokenInterface(*_args, **_kwargs)

Bases: TokenInterface

The EncryptedKeyInterface extends KeyInterface to work with encrypted tokens

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 nectarstorage.interfaces.KeyInterface(*_args, **_kwargs)

Bases: StoreInterface

The KeyInterface defines the interface for key storage.

Note

This class inherits nectarstorage.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(key)

Delete a pubkey/privatekey pair from the store

Parameters:

key (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 nectarstorage.interfaces.StoreInterface(*_args, **_kwargs)

Bases: MutableMapping

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

It behaves like a dictionary but allows returning None for missing keys and keeps a defaults mapping that can supply fallback values.

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

setdefault(key, value=None)

Allows to define default values on this store instance.

wipe()

Wipe the store

class nectarstorage.interfaces.TokenInterface(*_args, **_kwargs)

Bases: StoreInterface

The TokenInterface defines the interface for token storage.

Note

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

add(token, name=None)

Add a new token entry (correspondence has to be checked elsewhere!)

Parameters:
  • name (str) – Public identifier

  • token (str) – Token value

delete(key)

Delete a token entry from the store

Parameters:

key (str) – Public identifier

getPrivateKeyForPublicKey(pub)

Returns the (possibly encrypted) token that corresponds to a name

Parameters:

pub (str) – Public key

The encryption scheme is BIP38

getPublicNames()

Returns the public token names stored in the database

is_encrypted()

Returns True/False to indicate required use of unlock