keystore: get_private_keys should not return None
closes https://github.com/spesmilo/electrum/issues/10200
This commit is contained in:
@@ -2592,14 +2592,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
||||
if bitcoin.is_address(addr):
|
||||
return addr
|
||||
|
||||
def get_pk(*, raise_on_error=False):
|
||||
def get_pk(*, raise_on_error=False) -> Sequence[str]:
|
||||
text = str(keys_e.toPlainText())
|
||||
return keystore.get_private_keys(text, raise_on_error=raise_on_error)
|
||||
|
||||
def on_edit():
|
||||
valid_privkeys = False
|
||||
try:
|
||||
valid_privkeys = get_pk(raise_on_error=True) is not None
|
||||
valid_privkeys = bool(get_pk(raise_on_error=True))
|
||||
except Exception as e:
|
||||
button.setToolTip(f'{_("Error")}: {repr(e)}')
|
||||
else:
|
||||
|
||||
@@ -1134,7 +1134,7 @@ def is_address_list(text: str) -> bool:
|
||||
return bool(parts) and all(bitcoin.is_address(x) for x in parts)
|
||||
|
||||
|
||||
def get_private_keys(text: str, *, allow_spaces_inside_key=True, raise_on_error=False) -> Optional[Sequence[str]]:
|
||||
def get_private_keys(text: str, *, allow_spaces_inside_key=True, raise_on_error=False) -> Sequence[str]:
|
||||
if allow_spaces_inside_key: # see #1612
|
||||
parts = text.split('\n')
|
||||
parts = map(lambda x: ''.join(x.split()), parts)
|
||||
@@ -1143,7 +1143,7 @@ def get_private_keys(text: str, *, allow_spaces_inside_key=True, raise_on_error=
|
||||
parts = text.split()
|
||||
if bool(parts) and all(bitcoin.is_private_key(x, raise_on_error=raise_on_error) for x in parts):
|
||||
return parts
|
||||
return None
|
||||
return []
|
||||
|
||||
|
||||
def is_private_key_list(text: str, *, allow_spaces_inside_key: bool = True, raise_on_error: bool = False) -> bool:
|
||||
|
||||
@@ -3755,7 +3755,7 @@ class Imported_Wallet(Simple_Wallet):
|
||||
x = self.db.get_imported_address(address)
|
||||
return x.get('pubkey') if x else None
|
||||
|
||||
def import_private_keys(self, keys: List[str], password: Optional[str], *,
|
||||
def import_private_keys(self, keys: Sequence[str], password: Optional[str], *,
|
||||
write_to_disk=True) -> Tuple[List[str], List[Tuple[str, str]]]:
|
||||
good_addr = [] # type: List[str]
|
||||
bad_keys = [] # type: List[Tuple[str, str]]
|
||||
|
||||
Reference in New Issue
Block a user