1
0

wallet: make importing thousands of addr/privkeys fast

fixes #3101
closes #3106
closes #3113
This commit is contained in:
SomberNight
2018-10-27 17:36:10 +02:00
parent 917b7fa898
commit 34569d172f
5 changed files with 84 additions and 54 deletions

View File

@@ -189,17 +189,23 @@ class BaseWizard(object):
# will be reflected on self.storage
if keystore.is_address_list(text):
w = Imported_Wallet(self.storage)
for x in text.split():
w.import_address(x)
addresses = text.split()
good_inputs, bad_inputs = w.import_addresses(addresses)
elif keystore.is_private_key_list(text):
k = keystore.Imported_KeyStore({})
self.storage.put('keystore', k.dump())
w = Imported_Wallet(self.storage)
for x in keystore.get_private_keys(text):
w.import_private_key(x, None)
keys = keystore.get_private_keys(text)
good_inputs, bad_inputs = w.import_private_keys(keys, None)
self.keystores.append(w.keystore)
else:
return self.terminate()
if bad_inputs:
msg = "\n".join(f"{key[:10]}... ({msg})" for key, msg in bad_inputs[:10])
if len(bad_inputs) > 10: msg += '\n...'
self.show_error(_("The following inputs could not be imported")
+ f' ({len(bad_inputs)}):\n' + msg)
# FIXME what if len(good_inputs) == 0 ?
return self.run('create_wallet')
def restore_from_key(self):