Browse Source

Merge #418: Add dialog for displaying seed phrase to JM-Qt

9dee0d7 Add dialog for displaying seed phrase to JM-Qt (chris-belcher)

Tree-SHA512: fa8b30c8078f85e9c877d23cff426fe031b74c2adff22609b59c0642ebfb7779986fbb7142906a707a4d1458db08823691d226ee80ca3154cc2cb04da89a86fb
master
chris-belcher 6 years ago
parent
commit
91f978d1d8
No known key found for this signature in database
GPG Key ID: EF734EA677F31129
  1. 50
      scripts/joinmarket-qt.py

50
scripts/joinmarket-qt.py

@ -1281,30 +1281,35 @@ class JMMainWindow(QMainWindow):
def initUI(self): def initUI(self):
self.statusBar().showMessage("Ready") self.statusBar().showMessage("Ready")
self.setGeometry(300, 300, 250, 150) self.setGeometry(300, 300, 250, 150)
exitAction = QAction(QIcon('exit.png'), '&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(qApp.quit)
generateAction = QAction('&Generate', self)
generateAction.setStatusTip('Generate new wallet')
generateAction.triggered.connect(self.generateWallet)
loadAction = QAction('&Load', self) loadAction = QAction('&Load', self)
loadAction.setStatusTip('Load wallet from file') loadAction.setStatusTip('Load wallet from file')
loadAction.triggered.connect(self.selectWallet) loadAction.triggered.connect(self.selectWallet)
generateAction = QAction('&Generate', self)
generateAction.setStatusTip('Generate new wallet')
generateAction.triggered.connect(self.generateWallet)
recoverAction = QAction('&Recover', self) recoverAction = QAction('&Recover', self)
recoverAction.setStatusTip('Recover wallet from seedphrase') recoverAction.setStatusTip('Recover wallet from seed phrase')
recoverAction.triggered.connect(self.recoverWallet) recoverAction.triggered.connect(self.recoverWallet)
aboutAction = QAction('About Joinmarket', self) showSeedAction = QAction('&Show seed', self)
aboutAction.triggered.connect(self.showAboutDialog) showSeedAction.setStatusTip('Show wallet seed phrase')
showSeedAction.triggered.connect(self.showSeedDialog)
exportPrivAction = QAction('&Export keys', self) exportPrivAction = QAction('&Export keys', self)
exportPrivAction.setStatusTip('Export all private keys to a file') exportPrivAction.setStatusTip('Export all private keys to a file')
exportPrivAction.triggered.connect(self.exportPrivkeysJson) exportPrivAction.triggered.connect(self.exportPrivkeysJson)
menubar = self.menuBar() exitAction = QAction(QIcon('exit.png'), '&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(qApp.quit)
aboutAction = QAction('About Joinmarket', self)
aboutAction.triggered.connect(self.showAboutDialog)
menubar = self.menuBar()
walletMenu = menubar.addMenu('&Wallet') walletMenu = menubar.addMenu('&Wallet')
walletMenu.addAction(loadAction) walletMenu.addAction(loadAction)
walletMenu.addAction(generateAction) walletMenu.addAction(generateAction)
walletMenu.addAction(recoverAction) walletMenu.addAction(recoverAction)
walletMenu.addAction(showSeedAction)
walletMenu.addAction(exportPrivAction) walletMenu.addAction(exportPrivAction)
walletMenu.addAction(exitAction) walletMenu.addAction(exitAction)
aboutMenu = menubar.addMenu('&About') aboutMenu = menubar.addMenu('&About')
@ -1610,6 +1615,21 @@ class JMMainWindow(QMainWindow):
return return
return str(text).strip() return str(text).strip()
def showSeedDialog(self):
if not self.wallet_service:
JMQtMessageBox(self,
"No wallet loaded.",
mbtype='crit',
title="Error")
return
try:
self.displayWords(*self.wallet_service.get_mnemonic_words())
except NotImplementedError:
JMQtMessageBox(self,
"Wallet does not support seed phrases",
mbtype='info',
title="Error")
def getPassword(self): def getPassword(self):
pd = PasswordDialog() pd = PasswordDialog()
while True: while True:
@ -1645,16 +1665,16 @@ class JMMainWindow(QMainWindow):
return self.walletname return self.walletname
def displayWords(self, words, mnemonic_extension): def displayWords(self, words, mnemonic_extension):
mb = QMessageBox() mb = QMessageBox(self)
seed_recovery_warning = [ seed_recovery_warning = [
"WRITE DOWN THIS WALLET RECOVERY SEED.", "WRITE DOWN THIS WALLET RECOVERY SEED.",
"If you fail to do this, your funds are", "If you fail to do this, your funds are",
"at risk. Do NOT ignore this step!!!" "at risk. Do NOT ignore this step!!!"
] ]
mb.setText("\n".join(seed_recovery_warning)) mb.setText("<br/>".join(seed_recovery_warning))
text = words text = "<strong>" + words + "</strong>"
if mnemonic_extension: if mnemonic_extension:
text += '\n\nMnemonic extension: ' + mnemonic_extension text += "<br/><br/>Seed extension: <strong>" + mnemonic_extension.decode("utf-8") + "</strong>"
mb.setInformativeText(text) mb.setInformativeText(text)
mb.setStandardButtons(QMessageBox.Ok) mb.setStandardButtons(QMessageBox.Ok)
ret = mb.exec_() ret = mb.exec_()

Loading…
Cancel
Save