mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
wizard: fix regression: unencrypted wallets were not getting upgraded
fixes #5177
This commit is contained in:
parent
bf1c1c2a11
commit
12b98fa251
7 changed files with 25 additions and 6 deletions
|
@ -28,7 +28,7 @@ import sys
|
||||||
import copy
|
import copy
|
||||||
import traceback
|
import traceback
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any, Dict
|
from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any, Dict, Optional
|
||||||
|
|
||||||
from . import bitcoin
|
from . import bitcoin
|
||||||
from . import keystore
|
from . import keystore
|
||||||
|
@ -137,7 +137,7 @@ class BaseWizard(object):
|
||||||
exc = None
|
exc = None
|
||||||
def on_finished():
|
def on_finished():
|
||||||
if exc is None:
|
if exc is None:
|
||||||
self.terminate()
|
self.terminate(storage=storage)
|
||||||
else:
|
else:
|
||||||
raise exc
|
raise exc
|
||||||
def do_upgrade():
|
def do_upgrade():
|
||||||
|
@ -571,6 +571,9 @@ class BaseWizard(object):
|
||||||
storage.load_plugins()
|
storage.load_plugins()
|
||||||
return storage
|
return storage
|
||||||
|
|
||||||
|
def terminate(self, *, storage: Optional[WalletStorage] = None):
|
||||||
|
raise NotImplementedError() # implemented by subclasses
|
||||||
|
|
||||||
def show_xpub_and_add_cosigners(self, xpub):
|
def show_xpub_and_add_cosigners(self, xpub):
|
||||||
self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('choose_keystore'))
|
self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('choose_keystore'))
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,8 @@ class Daemon(DaemonThread):
|
||||||
storage.decrypt(password)
|
storage.decrypt(password)
|
||||||
if storage.requires_split():
|
if storage.requires_split():
|
||||||
return
|
return
|
||||||
|
if storage.requires_upgrade():
|
||||||
|
return
|
||||||
if storage.get_action():
|
if storage.get_action():
|
||||||
return
|
return
|
||||||
wallet = Wallet(storage)
|
wallet = Wallet(storage)
|
||||||
|
|
|
@ -557,7 +557,15 @@ class ElectrumWindow(App):
|
||||||
wizard = Factory.InstallWizard(self.electrum_config, self.plugins)
|
wizard = Factory.InstallWizard(self.electrum_config, self.plugins)
|
||||||
wizard.path = path
|
wizard.path = path
|
||||||
wizard.bind(on_wizard_complete=self.on_wizard_complete)
|
wizard.bind(on_wizard_complete=self.on_wizard_complete)
|
||||||
wizard.run('new')
|
storage = WalletStorage(path, manual_upgrades=True)
|
||||||
|
if not storage.file_exists():
|
||||||
|
wizard.run('new')
|
||||||
|
elif storage.is_encrypted():
|
||||||
|
raise Exception("Kivy GUI does not support encrypted wallet files.")
|
||||||
|
elif storage.requires_upgrade():
|
||||||
|
wizard.upgrade_storage(storage)
|
||||||
|
else:
|
||||||
|
raise Exception("unexpected storage file situation")
|
||||||
if not ask_if_wizard:
|
if not ask_if_wizard:
|
||||||
launch_wizard()
|
launch_wizard()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -971,8 +971,9 @@ class InstallWizard(BaseWizard, Widget):
|
||||||
t = threading.Thread(target = target)
|
t = threading.Thread(target = target)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
def terminate(self, **kwargs):
|
def terminate(self, *, storage=None):
|
||||||
storage = self.create_storage(self.path)
|
if storage is None:
|
||||||
|
storage = self.create_storage(self.path)
|
||||||
self.dispatch('on_wizard_complete', storage)
|
self.dispatch('on_wizard_complete', storage)
|
||||||
|
|
||||||
def choice_dialog(self, **kwargs):
|
def choice_dialog(self, **kwargs):
|
||||||
|
|
|
@ -479,7 +479,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||||
def action_dialog(self, action, run_next):
|
def action_dialog(self, action, run_next):
|
||||||
self.run(action)
|
self.run(action)
|
||||||
|
|
||||||
def terminate(self):
|
def terminate(self, **kwargs):
|
||||||
self.accept_signal.emit()
|
self.accept_signal.emit()
|
||||||
|
|
||||||
def waiting_dialog(self, task, msg, on_finished=None):
|
def waiting_dialog(self, task, msg, on_finished=None):
|
||||||
|
|
|
@ -219,6 +219,8 @@ class WalletStorage(PrintError):
|
||||||
self.db.set_modified(True)
|
self.db.set_modified(True)
|
||||||
|
|
||||||
def requires_upgrade(self):
|
def requires_upgrade(self):
|
||||||
|
if not self.is_past_initial_decryption():
|
||||||
|
raise Exception("storage not yet decrypted!")
|
||||||
return self.db.requires_upgrade()
|
return self.db.requires_upgrade()
|
||||||
|
|
||||||
def upgrade(self):
|
def upgrade(self):
|
||||||
|
|
|
@ -192,6 +192,9 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||||
verbosity_filter = 'w'
|
verbosity_filter = 'w'
|
||||||
|
|
||||||
def __init__(self, storage: WalletStorage):
|
def __init__(self, storage: WalletStorage):
|
||||||
|
if storage.requires_upgrade():
|
||||||
|
raise Exception("storage must be upgraded before constructing wallet")
|
||||||
|
|
||||||
AddressSynchronizer.__init__(self, storage)
|
AddressSynchronizer.__init__(self, storage)
|
||||||
|
|
||||||
# saved fields
|
# saved fields
|
||||||
|
|
Loading…
Add table
Reference in a new issue