twizard.create_storage: state API and abide by it - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 08a79252353476aed746ff4c1085cf108f314a23 DIR parent a3e1b2e00c04b72e7375b121f094d34e721fe6ed HTML Author: SomberNight <somber.night@protonmail.com> Date: Thu, 9 Apr 2020 19:08:17 +0200 wizard.create_storage: state API and abide by it none of the callers was handling the return None case properly... Diffstat: M electrum/base_wizard.py | 12 ++++++------ M electrum/storage.py | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) --- DIR diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py t@@ -28,7 +28,7 @@ import sys import copy import traceback from functools import partial -from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any, Dict, Optional +from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any, Dict, Optional, Union from . import bitcoin from . import keystore t@@ -611,12 +611,10 @@ class BaseWizard(Logger): encrypt_keystore=encrypt_keystore) self.terminate() - - def create_storage(self, path): + def create_storage(self, path) -> Tuple[WalletStorage, WalletDB]: if os.path.exists(path): raise Exception('file already exists at path') - if not self.pw_args: - return # FIXME + assert self.pw_args, f"pw_args not set?!" pw_args = self.pw_args self.pw_args = None # clean-up so that it can get GC-ed storage = WalletStorage(path) t@@ -630,7 +628,9 @@ class BaseWizard(Logger): db.write(storage) return storage, db - def terminate(self, *, storage: Optional[WalletStorage], db: Optional[WalletDB] = None): + def terminate(self, *, storage: WalletStorage = None, + db: WalletDB = None, + aborted: bool = False) -> None: raise NotImplementedError() # implemented by subclasses def show_xpub_and_add_cosigners(self, xpub): DIR diff --git a/electrum/storage.py b/electrum/storage.py t@@ -189,7 +189,6 @@ class WalletStorage(Logger): s = '' self.pubkey = ec_key.get_public_key_hex() self.decrypted = s - return s def encrypt_before_writing(self, plaintext: str) -> str: s = plaintext