Skip to content
Snippets Groups Projects
Commit 47aff6c7 authored by inso's avatar inso
Browse files

Fix bug with no wallet initialized

parent f3dc1a1b
No related branches found
No related tags found
No related merge requests found
...@@ -196,6 +196,18 @@ class Account(QObject): ...@@ -196,6 +196,18 @@ class Account(QObject):
def set_display_referential(self, index): def set_display_referential(self, index):
self._current_ref = index self._current_ref = index
def set_scrypt_infos(self, salt, password):
"""
Change the size of the wallet pool
:param int size: The new size of the wallet pool
:param str password: The password of the account, same for all wallets
"""
self.salt = salt
self.pubkey = SigningKey(self.salt, password).pubkey
wallet = Wallet.create(0, self.salt, password,
"Wallet", self._identities_registry)
self.wallets.append(wallet)
def identity(self, community): def identity(self, community):
""" """
Get the account identity in the specified community Get the account identity in the specified community
...@@ -212,23 +224,6 @@ class Account(QObject): ...@@ -212,23 +224,6 @@ class Account(QObject):
def current_ref(self): def current_ref(self):
return money.Referentials[self._current_ref] return money.Referentials[self._current_ref]
def set_walletpool_size(self, size, password):
"""
Change the size of the wallet pool
:param int size: The new size of the wallet pool
:param str password: The password of the account, same for all wallets
"""
logging.debug("Defining wallet pool size")
if len(self.wallets) < size:
for i in range(len(self.wallets), size):
wallet = Wallet.create(i, self.salt, password,
"Wallet {0}".format(i), self._identities_registry)
self.wallets.append(wallet)
else:
self.wallets = self.wallets[:size]
self.wallets_changed.emit()
def transfers(self, community): def transfers(self, community):
""" """
Get all transfers done in a community by all the wallets Get all transfers done in a community by all the wallets
......
...@@ -60,7 +60,7 @@ class Wallet(QObject): ...@@ -60,7 +60,7 @@ class Wallet(QObject):
if walletid == 0: if walletid == 0:
key = SigningKey(salt, password) key = SigningKey(salt, password)
else: else:
key = SigningKey("{0}{1}".format(salt, walletid), password) key = SigningKey(b"{0}{1}".format(salt, walletid), password)
return cls(walletid, key.pubkey, name, identities_registry) return cls(walletid, key.pubkey, name, identities_registry)
@classmethod @classmethod
......
...@@ -94,8 +94,7 @@ class StepPageKey(Step): ...@@ -94,8 +94,7 @@ class StepPageKey(Step):
def process_next(self): def process_next(self):
salt = self.config_dialog.edit_salt.text() salt = self.config_dialog.edit_salt.text()
password = self.config_dialog.edit_password.text() password = self.config_dialog.edit_password.text()
self.config_dialog.account.salt = salt self.config_dialog.account.set_scrypt_infos(salt, password)
self.config_dialog.account.pubkey = SigningKey(salt, password).pubkey
self.config_dialog.password_asker = PasswordAskerDialog(self.config_dialog.account) self.config_dialog.password_asker = PasswordAskerDialog(self.config_dialog.account)
model = CommunitiesListModel(self.config_dialog.account) model = CommunitiesListModel(self.config_dialog.account)
self.config_dialog.list_communities.setModel(model) self.config_dialog.list_communities.setModel(model)
......
...@@ -90,6 +90,7 @@ class TestCertificationDialog(unittest.TestCase): ...@@ -90,6 +90,7 @@ class TestCertificationDialog(unittest.TestCase):
self.lp.call_later(15, close_dialog) self.lp.call_later(15, close_dialog)
asyncio.async(exec_test()) asyncio.async(exec_test())
self.lp.run_until_complete(open_dialog(certification_dialog)) self.lp.run_until_complete(open_dialog(certification_dialog))
mock.delete_mock()
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -105,6 +105,7 @@ class TestIdentitiesTable(unittest.TestCase): ...@@ -105,6 +105,7 @@ class TestIdentitiesTable(unittest.TestCase):
asyncio.async(exec_test()) asyncio.async(exec_test())
self.lp.run_until_complete(async_open_widget()) self.lp.run_until_complete(async_open_widget())
mock.delete_mock()
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig( stream=sys.stderr ) logging.basicConfig( stream=sys.stderr )
......
...@@ -94,6 +94,7 @@ class ProcessAddCommunity(unittest.TestCase): ...@@ -94,6 +94,7 @@ class ProcessAddCommunity(unittest.TestCase):
self.assertEqual(len(self.application.accounts), 1) self.assertEqual(len(self.application.accounts), 1)
self.assertEqual(self.application.current_account.name, "test") self.assertEqual(self.application.current_account.name, "test")
self.assertEqual(self.application.preferences['account'], "test") self.assertEqual(self.application.preferences['account'], "test")
self.assertEqual(len(self.application.current_account.wallets), 1)
self.lp.call_later(10, close_dialog) self.lp.call_later(10, close_dialog)
asyncio.async(exec_test()) asyncio.async(exec_test())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment