Browse Source

wallet recovery in Qt

master
Adam Gibson 8 years ago
parent
commit
1bd0e041d9
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 46
      scripts/joinmarket-qt.py

46
scripts/joinmarket-qt.py

@ -1275,13 +1275,7 @@ class JMMainWindow(QMainWindow):
"Private keys exported to: " + privkeys_fn + '.csv', "Private keys exported to: " + privkeys_fn + '.csv',
title="Success") title="Success")
def recoverWallet(self): def seedEntry(self):
if get_network() == 'testnet':
JMQtMessageBox(self,
'recover from seedphrase not supported for testnet',
mbtype='crit',
title="Error")
return
d = QDialog(self) d = QDialog(self)
d.setModal(1) d.setModal(1)
d.setWindowTitle('Recover from seed') d.setWindowTitle('Recover from seed')
@ -1299,23 +1293,24 @@ class JMMainWindow(QMainWindow):
layout.addLayout(hbox, 3, 0) layout.addLayout(hbox, 3, 0)
result = d.exec_() result = d.exec_()
if result != QDialog.Accepted: if result != QDialog.Accepted:
return return None
msg = str(message_e.toPlainText()) return str(message_e.toPlainText())
words = msg.split() #splits on any number of ws chars
if not len(words) == 12: def recoverWallet(self):
success = wallet_generate_recover_bip39("recover", "wallets",
"wallet.json",
callbacks=(None, self.seedEntry,
self.getPasswordKey,
self.getWalletName))
if not success:
JMQtMessageBox(self, JMQtMessageBox(self,
"You did not provide 12 words, aborting.", "Failed to recover wallet.",
mbtype='warn', mbtype='warn',
title="Error") title="Error")
else: return
try: JMQtMessageBox(self, 'Wallet saved to ' + self.walletname,
seed = mn_decode(words) title="Wallet created")
self.initWallet(seed=seed) self.initWallet(seed=self.walletname)
except ValueError as e:
JMQtMessageBox(self,
"Could not decode seedphrase: " + repr(e),
mbtype='warn',
title="Error")
def selectWallet(self, testnet_seed=None): def selectWallet(self, testnet_seed=None):
if jm_single().config.get("BLOCKCHAIN", "blockchain_source") != "regtest": if jm_single().config.get("BLOCKCHAIN", "blockchain_source") != "regtest":
@ -1456,8 +1451,8 @@ class JMMainWindow(QMainWindow):
ret = mb.exec_() ret = mb.exec_()
def initWallet(self, seed=None): def initWallet(self, seed=None):
'''Creates a new mainnet '''Creates a new wallet if seed not provided.
wallet Initializes by syncing.
''' '''
if not seed: if not seed:
success = wallet_generate_recover_bip39("generate", success = wallet_generate_recover_bip39("generate",
@ -1473,10 +1468,7 @@ class JMMainWindow(QMainWindow):
return return
JMQtMessageBox(self, 'Wallet saved to ' + self.walletname, JMQtMessageBox(self, 'Wallet saved to ' + self.walletname,
title="Wallet created") title="Wallet created")
self.loadWalletFromBlockchain(self.walletname, pwd=self.textpassword) self.loadWalletFromBlockchain(self.walletname, pwd=self.textpassword)
else:
print('no seed to do')
def get_wallet_printout(wallet): def get_wallet_printout(wallet):
"""Given a joinmarket wallet, retrieve the list of """Given a joinmarket wallet, retrieve the list of

Loading…
Cancel
Save