diff --git a/bitmessagemain.py b/bitmessagemain.py index 148bc8ad..d33c414e 100644 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -26,6 +26,7 @@ import ConfigParser from bitmessageui import * from newaddressdialog import * from newsubscriptiondialog import * +from regenerateaddresses import * from settings import * from about import * from help import * @@ -2398,7 +2399,7 @@ class singleWorker(QThread): fromStatus,fromAddressVersionNumber,fromStreamNumber,fromHash = decodeAddress(fromaddress) self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Doing work necessary to send the message.') printLock.acquire() - print 'Found the necessary message that needs to be sent with this pubkey.' + print 'Found a message in our database that needs to be sent with this pubkey.' print 'First 150 characters of message:', message[:150] printLock.release() @@ -2673,8 +2674,8 @@ class addressGenerator(QThread): else: if ripe.digest()[:1] == '\x00': break - print 'ripe.digest', ripe.digest().encode('hex') - print 'Address generator calculated', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, 'addresses at', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix/(time.time()-startTime),'keys per second.' + print 'Generated address with ripe digest:', ripe.digest().encode('hex') + print 'Address generator calculated', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, 'addresses at', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix/(time.time()-startTime),'addresses per second before finding one with the correct ripe-prefix.' if ripe.digest()[:2] == '\x00\x00': address = encodeAddress(2,self.streamNumber,ripe.digest()[2:]) elif ripe.digest()[:1] == '\x00': @@ -2686,12 +2687,12 @@ class addressGenerator(QThread): privSigningKey = '\x80'+potentialPrivSigningKey checksum = hashlib.sha256(hashlib.sha256(privSigningKey).digest()).digest()[0:4] privSigningKeyWIF = arithmetic.changebase(privSigningKey + checksum,256,58) - print 'privSigningKeyWIF',privSigningKeyWIF + #print 'privSigningKeyWIF',privSigningKeyWIF privEncryptionKey = '\x80'+potentialPrivEncryptionKey checksum = hashlib.sha256(hashlib.sha256(privEncryptionKey).digest()).digest()[0:4] privEncryptionKeyWIF = arithmetic.changebase(privEncryptionKey + checksum,256,58) - print 'privEncryptionKeyWIF',privEncryptionKeyWIF + #print 'privEncryptionKeyWIF',privEncryptionKeyWIF config.add_section(address) print 'self.label', self.label @@ -2753,7 +2754,6 @@ class addressGenerator(QThread): privSigningKey = '\x80'+potentialPrivSigningKey checksum = hashlib.sha256(hashlib.sha256(privSigningKey).digest()).digest()[0:4] privSigningKeyWIF = arithmetic.changebase(privSigningKey + checksum,256,58) - print 'privSigningKeyWIF',privSigningKeyWIF privEncryptionKey = '\x80'+potentialPrivEncryptionKey checksum = hashlib.sha256(hashlib.sha256(privEncryptionKey).digest()).digest()[0:4] @@ -2862,6 +2862,14 @@ class aboutDialog(QtGui.QDialog): self.parent = parent self.ui.labelVersion.setText('version ' + softwareVersion) +class regenerateAddressesDialog(QtGui.QDialog): + def __init__(self,parent): + QtGui.QWidget.__init__(self, parent) + self.ui = Ui_regenerateAddressesDialog() + self.ui.setupUi(self) + self.parent = parent + QtGui.QWidget.resize(self,QtGui.QWidget.sizeHint(self)) + class settingsDialog(QtGui.QDialog): def __init__(self,parent): QtGui.QWidget.__init__(self, parent) @@ -3008,6 +3016,8 @@ class MyForm(QtGui.QMainWindow): #FILE MENU and other buttons QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close) QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys) + QtCore.QObject.connect(self.ui.actionRegenerateDeterministicAddresses, QtCore.SIGNAL("triggered()"), self.click_actionRegenerateDeterministicAddresses) + QtCore.QObject.connect(self.ui.actionManageKeys, QtCore.SIGNAL("triggered()"), self.click_actionManageKeys) QtCore.QObject.connect(self.ui.pushButtonNewAddress, QtCore.SIGNAL("clicked()"), self.click_NewAddressDialog) QtCore.QObject.connect(self.ui.comboBoxSendFrom, QtCore.SIGNAL("activated(int)"),self.redrawLabelFrom) QtCore.QObject.connect(self.ui.pushButtonAddAddressBook, QtCore.SIGNAL("clicked()"), self.click_pushButtonAddAddressBook) @@ -3322,6 +3332,21 @@ class MyForm(QtGui.QMainWindow): self.openKeysFile() else: pass + + def click_actionRegenerateDeterministicAddresses(self): + self.regenerateAddressesDialogInstance = regenerateAddressesDialog(self) + if self.regenerateAddressesDialogInstance.exec_(): + if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "": + QMessageBox.about(self, "bad passphrase", "You must type your passphrase. If you don\'t have one then this is not the form for you.") + else: + streamNumberForAddress = int(self.regenerateAddressesDialogInstance.ui.lineEditStreamNumber.text()) + addressVersionNumber = int(self.regenerateAddressesDialogInstance.ui.lineEditAddressVersionNumber.text()) + self.addressGenerator = addressGenerator() + self.addressGenerator.setup(addressVersionNumber,streamNumberForAddress,"unused address",self.regenerateAddressesDialogInstance.ui.spinBoxNumberOfAddressesToMake.value(),self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text().toUtf8(),self.regenerateAddressesDialogInstance.ui.checkBoxEighteenByteRipe.isChecked()) + QtCore.QObject.connect(self.addressGenerator, SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"), self.writeNewAddressToTable) + QtCore.QObject.connect(self.addressGenerator, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) + self.addressGenerator.start() + self.ui.tabWidget.setCurrentIndex(3) def openKeysFile(self): if 'linux' in sys.platform: diff --git a/bitmessageui.py b/bitmessageui.py index f4513e11..9e8c0d69 100644 --- a/bitmessageui.py +++ b/bitmessageui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'bitmessageui.ui' # -# Created: Tue Dec 18 14:32:02 2012 +# Created: Thu Jan 24 15:29:31 2013 # by: PyQt4 UI code generator 4.9.4 # # WARNING! All changes made in this file will be lost! @@ -403,7 +403,10 @@ class Ui_MainWindow(object): self.actionAbout.setObjectName(_fromUtf8("actionAbout")) self.actionSettings = QtGui.QAction(MainWindow) self.actionSettings.setObjectName(_fromUtf8("actionSettings")) + self.actionRegenerateDeterministicAddresses = QtGui.QAction(MainWindow) + self.actionRegenerateDeterministicAddresses.setObjectName(_fromUtf8("actionRegenerateDeterministicAddresses")) self.menuFile.addAction(self.actionManageKeys) + self.menuFile.addAction(self.actionRegenerateDeterministicAddresses) self.menuFile.addAction(self.actionExit) self.menuSettings.addAction(self.actionSettings) self.menuHelp.addAction(self.actionHelp) @@ -506,5 +509,6 @@ class Ui_MainWindow(object): self.actionHelp.setText(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8)) self.actionAbout.setText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8)) self.actionSettings.setText(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8)) + self.actionRegenerateDeterministicAddresses.setText(QtGui.QApplication.translate("MainWindow", "Regenerate deterministic addresses", None, QtGui.QApplication.UnicodeUTF8)) import bitmessage_icons_rc diff --git a/bitmessageui.ui b/bitmessageui.ui index f644535b..19e94529 100644 --- a/bitmessageui.ui +++ b/bitmessageui.ui @@ -933,6 +933,7 @@ p, li { white-space: pre-wrap; } File + @@ -996,6 +997,11 @@ p, li { white-space: pre-wrap; } Settings + + + Regenerate deterministic addresses + + diff --git a/regenerateaddresses.py b/regenerateaddresses.py new file mode 100644 index 00000000..e47f6b6e --- /dev/null +++ b/regenerateaddresses.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'regenerateaddresses.ui' +# +# Created: Thu Jan 24 15:52:24 2013 +# by: PyQt4 UI code generator 4.9.4 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + _fromUtf8 = lambda s: s + +class Ui_regenerateAddressesDialog(object): + def setupUi(self, regenerateAddressesDialog): + regenerateAddressesDialog.setObjectName(_fromUtf8("regenerateAddressesDialog")) + regenerateAddressesDialog.resize(532, 332) + self.gridLayout_2 = QtGui.QGridLayout(regenerateAddressesDialog) + self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) + self.buttonBox = QtGui.QDialogButtonBox(regenerateAddressesDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.gridLayout_2.addWidget(self.buttonBox, 1, 0, 1, 1) + self.groupBox = QtGui.QGroupBox(regenerateAddressesDialog) + self.groupBox.setObjectName(_fromUtf8("groupBox")) + self.gridLayout = QtGui.QGridLayout(self.groupBox) + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.label_6 = QtGui.QLabel(self.groupBox) + self.label_6.setObjectName(_fromUtf8("label_6")) + self.gridLayout.addWidget(self.label_6, 1, 0, 1, 1) + self.lineEditPassphrase = QtGui.QLineEdit(self.groupBox) + self.lineEditPassphrase.setInputMethodHints(QtCore.Qt.ImhHiddenText|QtCore.Qt.ImhNoAutoUppercase|QtCore.Qt.ImhNoPredictiveText) + self.lineEditPassphrase.setEchoMode(QtGui.QLineEdit.Password) + self.lineEditPassphrase.setObjectName(_fromUtf8("lineEditPassphrase")) + self.gridLayout.addWidget(self.lineEditPassphrase, 2, 0, 1, 5) + self.label_11 = QtGui.QLabel(self.groupBox) + self.label_11.setObjectName(_fromUtf8("label_11")) + self.gridLayout.addWidget(self.label_11, 3, 0, 1, 3) + self.spinBoxNumberOfAddressesToMake = QtGui.QSpinBox(self.groupBox) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.spinBoxNumberOfAddressesToMake.sizePolicy().hasHeightForWidth()) + self.spinBoxNumberOfAddressesToMake.setSizePolicy(sizePolicy) + self.spinBoxNumberOfAddressesToMake.setMinimum(1) + self.spinBoxNumberOfAddressesToMake.setProperty("value", 8) + self.spinBoxNumberOfAddressesToMake.setObjectName(_fromUtf8("spinBoxNumberOfAddressesToMake")) + self.gridLayout.addWidget(self.spinBoxNumberOfAddressesToMake, 3, 3, 1, 1) + spacerItem = QtGui.QSpacerItem(132, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem, 3, 4, 1, 1) + self.label_2 = QtGui.QLabel(self.groupBox) + self.label_2.setObjectName(_fromUtf8("label_2")) + self.gridLayout.addWidget(self.label_2, 4, 0, 1, 1) + self.lineEditAddressVersionNumber = QtGui.QLineEdit(self.groupBox) + self.lineEditAddressVersionNumber.setEnabled(False) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.lineEditAddressVersionNumber.sizePolicy().hasHeightForWidth()) + self.lineEditAddressVersionNumber.setSizePolicy(sizePolicy) + self.lineEditAddressVersionNumber.setMaximumSize(QtCore.QSize(31, 16777215)) + self.lineEditAddressVersionNumber.setObjectName(_fromUtf8("lineEditAddressVersionNumber")) + self.gridLayout.addWidget(self.lineEditAddressVersionNumber, 4, 1, 1, 1) + spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem1, 4, 2, 1, 1) + self.label_3 = QtGui.QLabel(self.groupBox) + self.label_3.setObjectName(_fromUtf8("label_3")) + self.gridLayout.addWidget(self.label_3, 5, 0, 1, 1) + self.lineEditStreamNumber = QtGui.QLineEdit(self.groupBox) + self.lineEditStreamNumber.setEnabled(False) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.lineEditStreamNumber.sizePolicy().hasHeightForWidth()) + self.lineEditStreamNumber.setSizePolicy(sizePolicy) + self.lineEditStreamNumber.setMaximumSize(QtCore.QSize(31, 16777215)) + self.lineEditStreamNumber.setObjectName(_fromUtf8("lineEditStreamNumber")) + self.gridLayout.addWidget(self.lineEditStreamNumber, 5, 1, 1, 1) + spacerItem2 = QtGui.QSpacerItem(325, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem2, 5, 2, 1, 3) + self.checkBoxEighteenByteRipe = QtGui.QCheckBox(self.groupBox) + self.checkBoxEighteenByteRipe.setObjectName(_fromUtf8("checkBoxEighteenByteRipe")) + self.gridLayout.addWidget(self.checkBoxEighteenByteRipe, 6, 0, 1, 5) + self.label_4 = QtGui.QLabel(self.groupBox) + self.label_4.setWordWrap(True) + self.label_4.setObjectName(_fromUtf8("label_4")) + self.gridLayout.addWidget(self.label_4, 7, 0, 1, 5) + self.label = QtGui.QLabel(self.groupBox) + self.label.setWordWrap(True) + self.label.setObjectName(_fromUtf8("label")) + self.gridLayout.addWidget(self.label, 0, 0, 1, 5) + self.gridLayout_2.addWidget(self.groupBox, 0, 0, 1, 1) + + self.retranslateUi(regenerateAddressesDialog) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), regenerateAddressesDialog.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), regenerateAddressesDialog.reject) + QtCore.QMetaObject.connectSlotsByName(regenerateAddressesDialog) + + def retranslateUi(self, regenerateAddressesDialog): + regenerateAddressesDialog.setWindowTitle(QtGui.QApplication.translate("regenerateAddressesDialog", "Regenerate Existing Addresses", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("regenerateAddressesDialog", "Regenerate existing addresses", None, QtGui.QApplication.UnicodeUTF8)) + self.label_6.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "Passphrase", None, QtGui.QApplication.UnicodeUTF8)) + self.label_11.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "Number of addresses to make based on your passphrase:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "Address version Number:", None, QtGui.QApplication.UnicodeUTF8)) + self.lineEditAddressVersionNumber.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "2", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "Stream number:", None, QtGui.QApplication.UnicodeUTF8)) + self.lineEditStreamNumber.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "1", None, QtGui.QApplication.UnicodeUTF8)) + self.checkBoxEighteenByteRipe.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "Spend several minutes of extra computing time to make the address(es) 1 or 2 characters shorter", None, QtGui.QApplication.UnicodeUTF8)) + self.label_4.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "You must check (or not check) this box just like you did (or didn\'t) when you made your addresses the first time.", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("regenerateAddressesDialog", "If you have previously made deterministic addresses but lost them due to an accident (like hard drive failure), you can regenerate them here. If you used the random number generator to make your addresses then this form will be of no use to you.", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/regenerateaddresses.ui b/regenerateaddresses.ui new file mode 100644 index 00000000..2dbecf84 --- /dev/null +++ b/regenerateaddresses.ui @@ -0,0 +1,237 @@ + + + regenerateAddressesDialog + + + + 0 + 0 + 532 + 332 + + + + Regenerate Existing Addresses + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Regenerate existing addresses + + + + + + Passphrase + + + + + + + Qt::ImhHiddenText|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText + + + QLineEdit::Password + + + + + + + Number of addresses to make based on your passphrase: + + + + + + + + 0 + 0 + + + + 1 + + + 8 + + + + + + + Qt::Horizontal + + + + 132 + 20 + + + + + + + + Address version Number: + + + + + + + false + + + + 0 + 0 + + + + + 31 + 16777215 + + + + 2 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Stream number: + + + + + + + false + + + + 0 + 0 + + + + + 31 + 16777215 + + + + 1 + + + + + + + Qt::Horizontal + + + + 325 + 20 + + + + + + + + Spend several minutes of extra computing time to make the address(es) 1 or 2 characters shorter + + + + + + + You must check (or not check) this box just like you did (or didn't) when you made your addresses the first time. + + + true + + + + + + + If you have previously made deterministic addresses but lost them due to an accident (like hard drive failure), you can regenerate them here. If you used the random number generator to make your addresses then this form will be of no use to you. + + + true + + + + + + + + + + + + buttonBox + accepted() + regenerateAddressesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + regenerateAddressesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +