bhive.storage module¶
-
class
bhive.storage.Configuration¶ Bases:
bhive.storage.DataDirThis 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= {'client_id': '', 'hot_sign_redirect_uri': None, 'node': ['https://anyx.io', 'https://api.openhive.network', 'https://api.hive.blog', 'https://api.hivekings.com'], 'oauth_base_url': 'https://hiveconnect.com/oauth2/', 'order-expiration': 604800, 'password_storage': 'environment', 'rpcpassword': '', 'rpcuser': '', 'sc2_api_url': 'https://hiveconnect.com/api/'}¶
-
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()¶
-
nodelist= [{'url': 'https://api.openhive.network', 'version': '0.23.0', 'type': 'appbase', 'owner': 'hiveio', 'score': 40}, {'url': 'https://api.hive.blog', 'version': '0.23.0', 'type': 'appbase', 'owner': 'hiveio', 'score': 40}, {'url': 'https://api.hivekings.com', 'version': '0.23.0', 'type': 'appbase', 'owner': 'hivekings', 'score': 25}, {'url': 'https://anyx.io', 'version': '0.23.0', 'type': 'appbase', 'owner': 'anyx', 'score': 70}]¶ Default configuration
-
nodes= ['https://anyx.io', 'https://api.openhive.network', 'https://api.hive.blog', 'https://api.hivekings.com']¶
-
-
class
bhive.storage.DataDir¶ Bases:
objectThis 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.
-
appname= 'bhive'¶
-
clean_data()¶ Delete files older than 70 days
-
data_dir= '/home/thecrazygm/.local/share/bhive'¶
-
mkdir_p()¶ Ensure that the directory in which the data is stored exists
-
recover_with_latest_backup(backupdir='backups')¶ Replace database with latest backup
-
refreshBackup()¶ Make a new backup
-
sqlDataBaseFile= '/home/thecrazygm/.local/share/bhive/bhive.sqlite'¶
-
sqlite3_backup(backupdir)¶ Create timestamped database copy
-
sqlite3_copy(src, dst)¶ Copy sql file from src to dst
-
storageDatabase= 'bhive.sqlite'¶
-
class
bhive.storage.Key¶ Bases:
bhive.storage.DataDirThis 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(prefix='STM')¶ 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
bhive.storage.MasterPassword(password)¶ Bases:
objectThe 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)¶ Remove all keys from configStorage
-
-
class
bhive.storage.Token¶ Bases:
bhive.storage.DataDirThis is the token storage that stores the public username and the (possibly encrypted) token in the token table in the SQLite3 database.
-
add(name, token)¶ Add a new public/private token pair (correspondence has to be checked elsewhere!)
- Parameters
name (str) – Public name
token (str) – Private token
-
create_table()¶ Create the new table in the SQLite database
-
delete(name)¶ Delete the key identified as name
- Parameters
name (str) – Public name
-
exists_table()¶ Check if the database table exists
-
getPublicNames()¶ Returns the public names stored in the database
-
getTokenForPublicName(name)¶ Returns the (possibly encrypted) private token that corresponds to a public name
- Parameters
pub (str) – Public name
The encryption scheme is BIP38
-
updateToken(name, token)¶ Change the token to a name
- Parameters
name (str) – Public name
token (str) – Private token
-
wipe(sure=False)¶ Purge the entire wallet. No keys will survive this!
-