Refactored config file (keys.dat) mangement to use helper_config.py and not specify filename throughout code
This commit is contained in:
parent
bfdb04716a
commit
86ce3de50d
|
@ -35,7 +35,7 @@ print 'Uncomment these next four lines to create new deterministic addresses.'
|
|||
#print jsonDeterministicAddresses
|
||||
#print json.loads(jsonDeterministicAddresses)
|
||||
|
||||
#print 'Uncomment this next line to print the first deterministic address that would be generated with the given passphrase. This will Not add it to the Bitmessage interface or the keys.dat file.'
|
||||
#print 'Uncomment this next line to print the first deterministic address that would be generated with the given passphrase. This will Not add it to the Bitmessage interface or the '+helper_config.getFileName()+' file.'
|
||||
#print api.getDeterministicAddress('asdfasdfqwser'.encode('base64'),3,1)
|
||||
|
||||
#print 'Uncomment this line to subscribe to an address. (You must use your own address, this one is invalid).'
|
||||
|
|
|
@ -26,7 +26,7 @@ from class_singleListener import *
|
|||
from class_addressGenerator import *
|
||||
|
||||
# Helper Functions
|
||||
import helper_startup
|
||||
import helper_config
|
||||
import helper_bootstrap
|
||||
|
||||
def connectToStream(streamNumber):
|
||||
|
@ -496,7 +496,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
fromAddressEnabled = shared.config.getboolean(
|
||||
fromAddress, 'enabled')
|
||||
except:
|
||||
return 'API Error 0013: Could not find your fromAddress in the keys.dat file.'
|
||||
return 'API Error 0013: Could not find your fromAddress in the '+helper_config.getFileName()+' file.'
|
||||
if not fromAddressEnabled:
|
||||
return 'API Error 0014: Your fromAddress is disabled. Cannot send.'
|
||||
|
||||
|
@ -560,7 +560,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
fromAddressEnabled = shared.config.getboolean(
|
||||
fromAddress, 'enabled')
|
||||
except:
|
||||
return 'API Error 0013: could not find your fromAddress in the keys.dat file.'
|
||||
return 'API Error 0013: could not find your fromAddress in the '+helper_config.getFileName()+' file.'
|
||||
ackdata = OpenSSL.rand(32)
|
||||
toAddress = '[Broadcast subscribers]'
|
||||
ripe = ''
|
||||
|
@ -706,7 +706,7 @@ if __name__ == "__main__":
|
|||
signal.signal(signal.SIGINT, helper_generic.signal_handler)
|
||||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
||||
helper_startup.loadConfig()
|
||||
helper_config.loadConfig()
|
||||
|
||||
helper_bootstrap.knownNodes()
|
||||
helper_bootstrap.dns()
|
||||
|
|
|
@ -29,6 +29,7 @@ import os
|
|||
from pyelliptic.openssl import OpenSSL
|
||||
import pickle
|
||||
import platform
|
||||
import helper_config
|
||||
|
||||
try:
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
@ -72,11 +73,10 @@ class MyForm(QtGui.QMainWindow):
|
|||
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
shared.config.remove_section(addressInKeysFile)
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig();
|
||||
|
||||
# Configure Bitmessage to start on startup (or remove the
|
||||
# configuration) based on the setting in the keys.dat file
|
||||
# configuration) based on the setting in the config file
|
||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
# Auto-startup for Windows
|
||||
RUN_PATH = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
|
@ -924,23 +924,19 @@ class MyForm(QtGui.QMainWindow):
|
|||
def click_actionManageKeys(self):
|
||||
if 'darwin' in sys.platform or 'linux' in sys.platform:
|
||||
if shared.appdata == '':
|
||||
# reply = QtGui.QMessageBox.information(self, 'keys.dat?','You
|
||||
# may manage your keys by editing the keys.dat file stored in
|
||||
# the same directory as this program. It is important that you
|
||||
# back up this file.', QMessageBox.Ok)
|
||||
reply = QtGui.QMessageBox.information(self, 'keys.dat?', _translate(
|
||||
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok)
|
||||
reply = QtGui.QMessageBox.information(self, helper_config.getFileName()+'?', _translate(
|
||||
"MainWindow", "You may manage your keys by editing the "+helper_config.getFileName()+" file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok)
|
||||
|
||||
else:
|
||||
QtGui.QMessageBox.information(self, 'keys.dat?', _translate(
|
||||
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok)
|
||||
QtGui.QMessageBox.information(self, helper_config.getFileName()+'?', _translate(
|
||||
"MainWindow", "You may manage your keys by editing the "+helper_config.getFileName()+" file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok)
|
||||
elif sys.platform == 'win32' or sys.platform == 'win64':
|
||||
if shared.appdata == '':
|
||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate(
|
||||
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open "+helper_config.getFileName()+"?"), _translate(
|
||||
"MainWindow", "You may manage your keys by editing the "+helper_config.getFileName()+" file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
else:
|
||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate(
|
||||
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open "+helper_config.getFileName()+"?"), _translate(
|
||||
"MainWindow", "You may manage your keys by editing the "+helper_config.getFileName()+" file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
if reply == QtGui.QMessageBox.Yes:
|
||||
self.openKeysFile()
|
||||
|
||||
|
@ -974,9 +970,9 @@ class MyForm(QtGui.QMainWindow):
|
|||
|
||||
def openKeysFile(self):
|
||||
if 'linux' in sys.platform:
|
||||
subprocess.call(["xdg-open", shared.appdata + 'keys.dat'])
|
||||
subprocess.call(["xdg-open", helper_config.getFilepath()])
|
||||
else:
|
||||
os.startfile(shared.appdata + 'keys.dat')
|
||||
os.startfile(helper_config.getFilepath())
|
||||
|
||||
def changeEvent(self, event):
|
||||
if event.type() == QtCore.QEvent.WindowStateChange:
|
||||
|
@ -1783,8 +1779,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
# shared.config.set('bitmessagesettings', 'maxcores',
|
||||
# str(self.settingsDialogInstance.ui.comboBoxMaxCores.currentText()))
|
||||
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
if 'win32' in sys.platform or 'win64' in sys.platform:
|
||||
# Auto-startup for Windows
|
||||
|
@ -1802,19 +1797,18 @@ class MyForm(QtGui.QMainWindow):
|
|||
pass
|
||||
|
||||
if shared.appdata != '' and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
|
||||
# Write the keys.dat file to disk in the new location
|
||||
# Write the config file to disk in the new location
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put('movemessagstoprog')
|
||||
shared.sqlLock.release()
|
||||
with open('keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
# Write the knownnodes.dat file to disk in the new location
|
||||
shared.knownNodesLock.acquire()
|
||||
output = open('knownnodes.dat', 'wb')
|
||||
pickle.dump(shared.knownNodes, output)
|
||||
output.close()
|
||||
shared.knownNodesLock.release()
|
||||
os.remove(shared.appdata + 'keys.dat')
|
||||
os.remove(shared.appdata + helper_config.getFileName())
|
||||
os.remove(shared.appdata + 'knownnodes.dat')
|
||||
shared.appdata = ''
|
||||
|
||||
|
@ -1825,23 +1819,21 @@ class MyForm(QtGui.QMainWindow):
|
|||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put('movemessagstoappdata')
|
||||
shared.sqlLock.release()
|
||||
# Write the keys.dat file to disk in the new location
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
# Write the config file to disk in the new location
|
||||
helper_config.saveConfig()
|
||||
# Write the knownnodes.dat file to disk in the new location
|
||||
shared.knownNodesLock.acquire()
|
||||
output = open(shared.appdata + 'knownnodes.dat', 'wb')
|
||||
pickle.dump(shared.knownNodes, output)
|
||||
output.close()
|
||||
shared.knownNodesLock.release()
|
||||
os.remove('keys.dat')
|
||||
os.remove(helper_config.getFileName())
|
||||
os.remove('knownnodes.dat')
|
||||
|
||||
def click_radioButtonBlacklist(self):
|
||||
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'white':
|
||||
shared.config.set('bitmessagesettings', 'blackwhitelist', 'black')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
# self.ui.tableWidgetBlacklist.clearContents()
|
||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||
self.loadBlackWhiteList()
|
||||
|
@ -1850,8 +1842,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
def click_radioButtonWhitelist(self):
|
||||
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
|
||||
shared.config.set('bitmessagesettings', 'blackwhitelist', 'white')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
# self.ui.tableWidgetBlacklist.clearContents()
|
||||
self.ui.tableWidgetBlacklist.setRowCount(0)
|
||||
self.loadBlackWhiteList()
|
||||
|
@ -1931,8 +1922,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
shared.config.set(str(addressAtCurrentRow), 'mailinglistname', str(
|
||||
self.dialog.ui.lineEditMailingListName.text().toUtf8()))
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow, 1).setTextColor(QtGui.QColor(137, 04, 177))
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
self.rerenderInboxToLabels()
|
||||
|
||||
def click_NewAddressDialog(self):
|
||||
|
@ -2442,8 +2432,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
addressAtCurrentRow = str(
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow, 1).text())
|
||||
shared.config.set(addressAtCurrentRow, 'enabled', 'true')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
self.ui.tableWidgetYourIdentities.item(
|
||||
currentRow, 0).setTextColor(QtGui.QColor(0, 0, 0))
|
||||
self.ui.tableWidgetYourIdentities.item(
|
||||
|
@ -2467,8 +2456,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
currentRow, 2).setTextColor(QtGui.QColor(128, 128, 128))
|
||||
if shared.safeConfigGetBoolean(addressAtCurrentRow, 'mailinglist'):
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow, 1).setTextColor(QtGui.QColor(137, 04, 177))
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
shared.reloadMyAddressHashes()
|
||||
|
||||
def on_action_YourIdentitiesClipboard(self):
|
||||
|
@ -2561,8 +2549,7 @@ class MyForm(QtGui.QMainWindow):
|
|||
currentRow, 1).text()
|
||||
shared.config.set(str(addressAtCurrentRow), 'label', str(
|
||||
self.ui.tableWidgetYourIdentities.item(currentRow, 0).text().toUtf8()))
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
self.rerenderComboBoxSendFrom()
|
||||
# self.rerenderInboxFromLabels()
|
||||
self.rerenderInboxToLabels()
|
||||
|
|
|
@ -173,7 +173,7 @@ class Ui_NewAddressDialog(object):
|
|||
NewAddressDialog.setWindowTitle(_translate("NewAddressDialog", "Create new Address", None))
|
||||
self.label.setText(_translate("NewAddressDialog", "Here you may generate as many addresses as you like. Indeed, creating and abandoning addresses is encouraged. You may generate addresses by using either random numbers or by using a passphrase. If you use a passphrase, the address is called a \"deterministic\" address.\n"
|
||||
"The \'Random Number\' option is selected by default but deterministic addresses have several pros and cons:", None))
|
||||
self.label_5.setText(_translate("NewAddressDialog", "<html><head/><body><p><span style=\" font-weight:600;\">Pros:<br/></span>You can recreate your addresses on any computer from memory. <br/>You need-not worry about backing up your keys.dat file as long as you can remember your passphrase. <br/><span style=\" font-weight:600;\">Cons:<br/></span>You must remember (or write down) your passphrase if you expect to be able to recreate your keys if they are lost. <br/>You must remember the address version number and the stream number along with your passphrase. <br/>If you choose a weak passphrase and someone on the Internet can brute-force it, they can read your messages and send messages as you.</p></body></html>", None))
|
||||
self.label_5.setText(_translate("NewAddressDialog", "<html><head/><body><p><span style=\" font-weight:600;\">Pros:<br/></span>You can recreate your addresses on any computer from memory. <br/>You need-not worry about backing up your private keys as long as you can remember your passphrase. <br/><span style=\" font-weight:600;\">Cons:<br/></span>You must remember (or write down) your passphrase if you expect to be able to recreate your keys if they are lost. <br/>You must remember the address version number and the stream number along with your passphrase. <br/>If you choose a weak passphrase and someone on the Internet can brute-force it, they can read your messages and send messages as you.</p></body></html>", None))
|
||||
self.radioButtonRandomAddress.setText(_translate("NewAddressDialog", "Use a random number generator to make an address", None))
|
||||
self.radioButtonDeterministicAddress.setText(_translate("NewAddressDialog", "Use a passphrase to make addresses", None))
|
||||
self.checkBoxEighteenByteRipe.setText(_translate("NewAddressDialog", "Spend several minutes of extra computing time to make the address(es) 1 or 2 characters shorter", None))
|
||||
|
|
|
@ -9,6 +9,7 @@ import highlevelcrypto
|
|||
from addresses import *
|
||||
from pyelliptic import arithmetic
|
||||
import tr
|
||||
import helper_config
|
||||
|
||||
class addressGenerator(threading.Thread):
|
||||
|
||||
|
@ -114,8 +115,7 @@ class addressGenerator(threading.Thread):
|
|||
address, 'privSigningKey', privSigningKeyWIF)
|
||||
shared.config.set(
|
||||
address, 'privEncryptionKey', privEncryptionKeyWIF)
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
# It may be the case that this address is being generated
|
||||
# as a result of a call to the API. Let us put the result
|
||||
|
@ -226,8 +226,7 @@ class addressGenerator(threading.Thread):
|
|||
address, 'privSigningKey', privSigningKeyWIF)
|
||||
shared.config.set(
|
||||
address, 'privEncryptionKey', privEncryptionKeyWIF)
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
shared.UISignalQueue.put(('writeNewAddressToTable', (
|
||||
label, address, str(streamNumber))))
|
||||
|
|
|
@ -125,7 +125,7 @@ class singleWorker(threading.Thread):
|
|||
except Exception as err:
|
||||
shared.printLock.acquire()
|
||||
sys.stderr.write(
|
||||
'Error within doPOWForMyV2Pubkey. Could not read the keys from the keys.dat file for a requested address. %s\n' % err)
|
||||
'Error within doPOWForMyV2Pubkey. Could not read the keys from the '+helper_config.getFileName()+' file for a requested address. %s\n' % err)
|
||||
shared.printLock.release()
|
||||
return
|
||||
|
||||
|
@ -170,8 +170,7 @@ class singleWorker(threading.Thread):
|
|||
shared.UISignalQueue.put(('updateStatusBar', ''))
|
||||
shared.config.set(
|
||||
myAddress, 'lastpubkeysendtime', str(int(time.time())))
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
def doPOWForMyV3Pubkey(self, hash): # This function also broadcasts out the pubkey message once it is done with the POW
|
||||
myAddress = shared.myAddressesByHash[hash]
|
||||
|
@ -192,7 +191,7 @@ class singleWorker(threading.Thread):
|
|||
except Exception as err:
|
||||
shared.printLock.acquire()
|
||||
sys.stderr.write(
|
||||
'Error within doPOWForMyV3Pubkey. Could not read the keys from the keys.dat file for a requested address. %s\n' % err)
|
||||
'Error within doPOWForMyV3Pubkey. Could not read the keys from the '+helper_config.getFileName()+' file for a requested address. %s\n' % err)
|
||||
shared.printLock.release()
|
||||
return
|
||||
|
||||
|
@ -246,8 +245,7 @@ class singleWorker(threading.Thread):
|
|||
shared.UISignalQueue.put(('updateStatusBar', ''))
|
||||
shared.config.set(
|
||||
myAddress, 'lastpubkeysendtime', str(int(time.time())))
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
def sendBroadcast(self):
|
||||
shared.sqlLock.acquire()
|
||||
|
@ -271,7 +269,7 @@ class singleWorker(threading.Thread):
|
|||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the "+helper_config.getFileName()+" file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
|
@ -345,7 +343,7 @@ class singleWorker(threading.Thread):
|
|||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the "+helper_config.getFileName()+" file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
|
@ -639,7 +637,7 @@ class singleWorker(threading.Thread):
|
|||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the "+helper_config.getFileName()+" file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
|
@ -685,7 +683,7 @@ class singleWorker(threading.Thread):
|
|||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the "+helper_config.getFileName()+" file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
|
|
|
@ -5,6 +5,7 @@ import time
|
|||
import shutil # used for moving the messages.dat file
|
||||
import sys
|
||||
import os
|
||||
import helper_config
|
||||
|
||||
# This thread exists because SQLITE3 is so un-threadsafe that we must
|
||||
# submit queries to it and it puts results back in a different queue. They
|
||||
|
@ -82,8 +83,7 @@ class sqlThread(threading.Thread):
|
|||
shared.config.set('bitmessagesettings', 'sockspassword', '')
|
||||
shared.config.set('bitmessagesettings', 'keysencrypted', 'false')
|
||||
shared.config.set('bitmessagesettings', 'messagesencrypted', 'false')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
# People running earlier versions of PyBitmessage do not have the
|
||||
# usedpersonally field in their pubkeys table. Let's add it.
|
||||
|
@ -94,8 +94,7 @@ class sqlThread(threading.Thread):
|
|||
self.conn.commit()
|
||||
|
||||
shared.config.set('bitmessagesettings', 'settingsversion', '3')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
# People running earlier versions of PyBitmessage do not have the
|
||||
# encodingtype field in their inbox and sent tables or the read field
|
||||
|
@ -115,8 +114,7 @@ class sqlThread(threading.Thread):
|
|||
self.conn.commit()
|
||||
|
||||
shared.config.set('bitmessagesettings', 'settingsversion', '4')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
if shared.config.getint('bitmessagesettings', 'settingsversion') == 4:
|
||||
shared.config.set('bitmessagesettings', 'defaultnoncetrialsperbyte', str(
|
||||
|
@ -131,8 +129,7 @@ class sqlThread(threading.Thread):
|
|||
shared.config.set(
|
||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0')
|
||||
shared.config.set('bitmessagesettings', 'settingsversion', '6')
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
helper_config.saveConfig()
|
||||
|
||||
# From now on, let us keep a 'version' embedded in the messages.dat
|
||||
# file so that when we make changes to the database, the database
|
||||
|
|
|
@ -3,6 +3,7 @@ import socket
|
|||
import defaultKnownNodes
|
||||
import pickle
|
||||
import time
|
||||
import helper_config
|
||||
|
||||
def knownNodes():
|
||||
try:
|
||||
|
@ -17,7 +18,7 @@ def knownNodes():
|
|||
shared.knownNodes = pickle.load(pickleFile)
|
||||
pickleFile.close()
|
||||
if shared.config.getint('bitmessagesettings', 'settingsversion') > 6:
|
||||
print 'Bitmessage cannot read future versions of the keys file (keys.dat). Run the newer version of Bitmessage.'
|
||||
print 'Bitmessage cannot read future versions of the keys file ('+helper_config.getFileName()+'). Run the newer version of Bitmessage.'
|
||||
raise SystemExit
|
||||
|
||||
|
||||
|
|
|
@ -4,21 +4,28 @@ import sys
|
|||
import os
|
||||
|
||||
storeConfigFilesInSameDirectoryAsProgramByDefault = False # The user may de-select Portable Mode in the settings if they want the config files to stay in the application data folder.
|
||||
filename = 'keys.dat'
|
||||
|
||||
def getFileName():
|
||||
return filename
|
||||
|
||||
def getFilePath():
|
||||
return shared.appdata + filename
|
||||
|
||||
def loadConfig():
|
||||
# First try to load the config file (the keys.dat file) from the program
|
||||
# First try to load the config file (as defiend in 'filename') from the program
|
||||
# directory
|
||||
shared.config.read('keys.dat')
|
||||
shared.config.read(getFilePath())
|
||||
try:
|
||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||
print 'Loading config files from same directory as program'
|
||||
shared.appdata = ''
|
||||
except:
|
||||
# Could not load the keys.dat file in the program directory. Perhaps it
|
||||
# Could not load the config file in the program directory. Perhaps it
|
||||
# is in the appdata directory.
|
||||
shared.appdata = shared.lookupAppdataFolder()
|
||||
shared.config = ConfigParser.SafeConfigParser()
|
||||
shared.config.read(shared.appdata + 'keys.dat')
|
||||
shared.config.read(getFilePath())
|
||||
try:
|
||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||
print 'Loading existing config files from', shared.appdata
|
||||
|
@ -74,5 +81,11 @@ def loadConfig():
|
|||
print 'Creating new config files in', shared.appdata
|
||||
if not os.path.exists(shared.appdata):
|
||||
os.makedirs(shared.appdata)
|
||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||
|
||||
saveConfig();
|
||||
|
||||
|
||||
def saveConfig():
|
||||
|
||||
with open(getFilePath(), 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
|
@ -21,6 +21,7 @@ import socket
|
|||
import random
|
||||
import highlevelcrypto
|
||||
import shared
|
||||
import helper_config
|
||||
|
||||
config = ConfigParser.SafeConfigParser()
|
||||
myECCryptorObjects = {}
|
||||
|
@ -201,7 +202,7 @@ def decodeWalletImportFormat(WIFstring):
|
|||
|
||||
def reloadMyAddressHashes():
|
||||
printLock.acquire()
|
||||
print 'reloading keys from keys.dat file'
|
||||
print 'reloading keys from '+helper_config.getFileName()+' file'
|
||||
printLock.release()
|
||||
myECCryptorObjects.clear()
|
||||
myAddressesByHash.clear()
|
||||
|
|
Reference in New Issue
Block a user