1
0

cleanup storage and fix tracvis test

This commit is contained in:
ThomasV
2017-03-06 08:33:35 +01:00
parent ee2e9f6092
commit 411832c4ce
10 changed files with 62 additions and 71 deletions

View File

@@ -162,13 +162,12 @@ class ElectrumGui:
wallet = self.daemon.get_wallet(path)
if not wallet:
storage = WalletStorage(path)
if not storage.file_exists or storage.is_encrypted():
if not storage.file_exists() or storage.is_encrypted():
wizard = InstallWizard(self.config, self.app, self.plugins, storage)
wallet = wizard.run_and_get_wallet()
if not wallet:
return
else:
storage.read(None)
wallet = Wallet(storage)
wallet.start_threads(self.daemon.network)
self.daemon.add_wallet(wallet)

View File

@@ -6,7 +6,7 @@ from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
import electrum
from electrum.wallet import Wallet, WalletStorage
from electrum import Wallet, WalletStorage
from electrum.util import UserCancelled, InvalidPassword
from electrum.base_wizard import BaseWizard
from electrum.i18n import _
@@ -167,12 +167,12 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
vbox.addLayout(hbox)
self.pw_e = None
if not self.storage.file_exists:
if not self.storage.file_exists():
msg = _("This file does not exist.") + '\n' \
+ _("Press 'Next' to create this wallet, or chose another file.")
vbox.addWidget(QLabel(msg))
elif self.storage.file_exists and self.storage.is_encrypted():
elif self.storage.file_exists() and self.storage.is_encrypted():
msg = _("This file is encrypted.") + '\n' + _('Enter your password or choose another file.')
vbox.addWidget(QLabel(msg))
hbox2 = QHBoxLayout()
@@ -195,20 +195,19 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
while True:
update_layout()
if self.storage.file_exists and not self.storage.is_encrypted():
self.storage.read(None)
if self.storage.file_exists() and not self.storage.is_encrypted():
break
if not self.loop.exec_():
return
if not self.storage.file_exists:
if not self.storage.file_exists():
break
if self.storage.file_exists and self.storage.is_encrypted():
if self.storage.file_exists() and self.storage.is_encrypted():
password = unicode(self.pw_e.text())
try:
self.storage.read(password)
self.storage.decrypt(password)
break
except InvalidPassword as e:
QMessageBox.information(None, _('Error'), str(e), _('OK'))

View File

@@ -1,7 +1,7 @@
from decimal import Decimal
_ = lambda x:x
#from i18n import _
from electrum.wallet import WalletStorage, Wallet
from electrum import WalletStorage, Wallet
from electrum.util import format_satoshis, set_verbosity, StoreDict
from electrum.bitcoin import is_valid, COIN, TYPE_ADDRESS
from electrum.network import filter_protocol
@@ -19,8 +19,9 @@ class ElectrumGui:
if not storage.file_exists:
print "Wallet not found. try 'electrum create'"
exit()
password = getpass.getpass('Password:', stream=None) if storage.is_encrypted() else None
storage.read(password)
if storage.is_encrypted():
password = getpass.getpass('Password:', stream=None)
storage.decrypt(password)
self.done = 0
self.last_balance = ""

View File

@@ -22,8 +22,9 @@ class ElectrumGui:
if not storage.file_exists:
print "Wallet not found. try 'electrum create'"
exit()
password = getpass.getpass('Password:', stream=None) if storage.is_encrypted() else None
storage.read(password)
if storage.is_encrypted():
password = getpass.getpass('Password:', stream=None)
storage.decrypt(password)
self.wallet = Wallet(storage)
self.wallet.start_threads(self.network)
self.contacts = StoreDict(self.config, 'contacts')