wizard.create_storage: state API and abide by it
none of the callers was handling the return None case properly...
This commit is contained in:
@@ -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, Optional
|
from typing import List, TYPE_CHECKING, Tuple, NamedTuple, Any, Dict, Optional, Union
|
||||||
|
|
||||||
from . import bitcoin
|
from . import bitcoin
|
||||||
from . import keystore
|
from . import keystore
|
||||||
@@ -611,12 +611,10 @@ class BaseWizard(Logger):
|
|||||||
encrypt_keystore=encrypt_keystore)
|
encrypt_keystore=encrypt_keystore)
|
||||||
self.terminate()
|
self.terminate()
|
||||||
|
|
||||||
|
def create_storage(self, path) -> Tuple[WalletStorage, WalletDB]:
|
||||||
def create_storage(self, path):
|
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
raise Exception('file already exists at path')
|
raise Exception('file already exists at path')
|
||||||
if not self.pw_args:
|
assert self.pw_args, f"pw_args not set?!"
|
||||||
return # FIXME
|
|
||||||
pw_args = self.pw_args
|
pw_args = self.pw_args
|
||||||
self.pw_args = None # clean-up so that it can get GC-ed
|
self.pw_args = None # clean-up so that it can get GC-ed
|
||||||
storage = WalletStorage(path)
|
storage = WalletStorage(path)
|
||||||
@@ -630,7 +628,9 @@ class BaseWizard(Logger):
|
|||||||
db.write(storage)
|
db.write(storage)
|
||||||
return storage, db
|
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
|
raise NotImplementedError() # implemented by subclasses
|
||||||
|
|
||||||
def show_xpub_and_add_cosigners(self, xpub):
|
def show_xpub_and_add_cosigners(self, xpub):
|
||||||
|
|||||||
@@ -189,7 +189,6 @@ class WalletStorage(Logger):
|
|||||||
s = ''
|
s = ''
|
||||||
self.pubkey = ec_key.get_public_key_hex()
|
self.pubkey = ec_key.get_public_key_hex()
|
||||||
self.decrypted = s
|
self.decrypted = s
|
||||||
return s
|
|
||||||
|
|
||||||
def encrypt_before_writing(self, plaintext: str) -> str:
|
def encrypt_before_writing(self, plaintext: str) -> str:
|
||||||
s = plaintext
|
s = plaintext
|
||||||
|
|||||||
Reference in New Issue
Block a user