peerplays.storage module

class peerplays.storage.Configuration

Bases: peerplays.storage.DataDir

This is the configuration storage that stores key/value pairs in the config table of the SQLite3 database.

checkBackup()

Backup the SQL database every 7 days

config_defaults = {'node': 'wss://api1.peerplays.download', 'rpcpassword': '', 'rpcuser': ''}

Default configuration

create_table()

Create the new table in the SQLite database

delete(key)

Delete a key from the configuration store

exists_table()

Check if the database table exists

get(key, default=None)

Return the key if exists or a default value

items()
class peerplays.storage.DataDir

Bases: object

This class ensures that the user’s data is stored in its OS preotected user directory:

OSX:

  • ~/Library/Application Support/<AppName>

Windows:

  • C:Documents and Settings<User>Application DataLocal Settings<AppAuthor><AppName>
  • C:Documents and Settings<User>Application Data<AppAuthor><AppName>

Linux:

  • ~/.local/share/<AppName>

Furthermore, it offers an interface to generated backups in the backups/ directory every now and then.

appauthor = 'Peerplays Blockchain Standards Association'
appname = 'peerplays'
clean_data()

Delete files older than 70 days

data_dir = '/home/docs/.local/share/peerplays'
mkdir_p()

Ensure that the directory in which the data is stored exists

refreshBackup()

Make a new backup

sqlDataBaseFile = '/home/docs/.local/share/peerplays/peerplays.sqlite'
sqlite3_backup(dbfile, backupdir)

Create timestamped database copy

storageDatabase = 'peerplays.sqlite'
class peerplays.storage.Key

Bases: peerplays.storage.DataDir

This is the key storage that stores the public key and the (possibly encrypted) private key in the keys table in the SQLite3 database.

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

Create the new table in the SQLite database

delete(pub)

Delete the key identified as pub

Parameters:pub (str) – Public key
exists_table()

Check if the database table exists

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

updateWif(pub, wif)

Change the wif to a pubkey

Parameters:
  • pub (str) – Public key
  • wif (str) – Private key
wipe(sure=False)

Purge the entire wallet. No keys will survive this!

class peerplays.storage.MasterPassword(password)

Bases: object

The keys are encrypted with a Masterpassword that is stored in the configurationStore. It has a checksum to verify correctness of the password

changePassword(newpassword)

Change the password

config_key = 'encrypted_master_password'

This key identifies the encrypted master password stored in the confiration

decryptEncryptedMaster()

Decrypt the encrypted masterpassword

decrypted_master = ''
deriveChecksum(s)

Derive the checksum

getEncryptedMaster()

Obtain the encrypted masterkey

newMaster()

Generate a new random masterpassword

password = ''
saveEncrytpedMaster()

Store the encrypted master password in the configuration store

static wipe(sure=False)