Browse Source

wizard.create_storage: state API and abide by it

none of the callers was handling the return None case properly...
hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
08a7925235
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/base_wizard.py
  2. 1
      electrum/storage.py

12
electrum/base_wizard.py

@ -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
@ -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)
@ -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):

1
electrum/storage.py

@ -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

Loading…
Cancel
Save