diff --git a/lib/ucoinpy/api/bma/tx/__init__.py b/lib/ucoinpy/api/bma/tx/__init__.py index 10ea07a5ca4bf673286a3b4d36dbf76662e85d22..384b7ff9f0b8827ae1ac2e400e1adc91efef2b48 100644 --- a/lib/ucoinpy/api/bma/tx/__init__.py +++ b/lib/ucoinpy/api/bma/tx/__init__.py @@ -44,4 +44,4 @@ class Sources(Tx): def __get__(self, **kwargs): assert self.pubkey is not None - return self.requests_get('/sources/%s' % self.pubkey, **kwargs).json() + return self.requests_get('/sources/%d' % self.pubkey, **kwargs).json() diff --git a/lib/ucoinpy/documents/transaction.py b/lib/ucoinpy/documents/transaction.py index 251c6b89b995d9af8c7733ff21b6aec8a23a2f2d..2cbdb7000d6be0b16dafe15884968004470ee4c0 100644 --- a/lib/ucoinpy/documents/transaction.py +++ b/lib/ucoinpy/documents/transaction.py @@ -265,7 +265,7 @@ class InputSource(): @classmethod def from_bma(cls, bma_data): index = None - source = bma_data['type'] + source = bma_data['source'] number = bma_data['number'] txhash = bma_data['fingerprint'] amount = bma_data['amount'] diff --git a/src/cutecoin/gui/processConfigureAccount.py b/src/cutecoin/gui/processConfigureAccount.py index 9d5d0e7e695803bf025878218418047f7d7bac5a..2ad208e40c2acceb8a0d0aa658483119f046a371 100644 --- a/src/cutecoin/gui/processConfigureAccount.py +++ b/src/cutecoin/gui/processConfigureAccount.py @@ -35,7 +35,6 @@ class StepPageInit(Step): return False def process_next(self): - logging.debug("Init NEXT") if self.config_dialog.account is None: name = self.config_dialog.edit_account_name.text() self.config_dialog.account = self.config_dialog.core.create_account(name) @@ -44,7 +43,6 @@ class StepPageInit(Step): self.config_dialog.account.name = name def display_page(self): - logging.debug("Init DISPLAY") if self.config_dialog.account is not None: self.config_dialog.edit_account_name.setText(self.config_dialog.account.name) model = CommunitiesListModel(self.config_dialog.account) @@ -75,7 +73,6 @@ class StepPageKey(Step): return True def process_next(self): - logging.debug("Key NEXT") salt = self.config_dialog.edit_email.text() password = self.config_dialog.edit_password.text() self.config_dialog.account.salt = salt @@ -84,7 +81,6 @@ class StepPageKey(Step): self.config_dialog.list_communities.setModel(model) def display_page(self): - logging.debug("Key DISPLAY") self.config_dialog.button_previous.setEnabled(False) self.config_dialog.button_next.setEnabled(False) diff --git a/src/cutecoin/gui/processConfigureCommunity.py b/src/cutecoin/gui/processConfigureCommunity.py index 68af5ea8a5b691f2df5a305a56d8f90bc4e4839f..5c1f58d99511f9835de852bad89a33020416d61c 100644 --- a/src/cutecoin/gui/processConfigureCommunity.py +++ b/src/cutecoin/gui/processConfigureCommunity.py @@ -11,6 +11,8 @@ from PyQt5.QtWidgets import QDialog, QMenu, QMessageBox, QWidget, QAction from PyQt5.QtCore import QSignalMapper from cutecoin.models.node.treeModel import NodesTreeModel from cutecoin.models.node import Node +from cutecoin.models.person import Person +from cutecoin.tools.exceptions import PersonNotFoundError from cutecoin.tools.exceptions import Error @@ -158,10 +160,20 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): def accept(self): try: - self.account.send_pubkey(self.community) - except Error as e: - QMessageBox.critical(self, "Pubkey publishing error", - e.message) + Person.lookup(self.account.pubkey, self.community) + except PersonNotFoundError as e: + reply = QMessageBox.question(self, "Pubkey not found", + "The public key of your account wasn't found in the community. :\n \ + {0}\n \ + Would you like to publish the key ?".format(self.account.pubkey)) + if reply == QMessageBox.Yes: + try: + self.account.send_pubkey(self.community) + except Error as e: + QMessageBox.critical(self, "Pubkey publishing error", + e.message) + else: + return self.accepted.emit() self.close() diff --git a/src/cutecoin/models/node/__init__.py b/src/cutecoin/models/node/__init__.py index eeb94a1c4b5a3e8b6e126f1a877bb47298b1d3da..c17942580812238b5d0a939fd02d493bfebb51c5 100644 --- a/src/cutecoin/models/node/__init__.py +++ b/src/cutecoin/models/node/__init__.py @@ -46,7 +46,7 @@ class Node(object): def __eq__(self, other): pubkey = bma.network.Peering(server=self.server, - port=self.port).get()['puubkey'] + port=self.port).get()['pubkey'] other_pubkey = bma.network.Peering(server=other.server, port=other.port).get()['pubkey'] return (pubkey == other_pubkey) diff --git a/src/cutecoin/models/person/__init__.py b/src/cutecoin/models/person/__init__.py index c22c81b086e9c7018b3f3301012bd98791c56f46..0c2dc519d95ed108164f9050a1ad8793b1f76a8e 100644 --- a/src/cutecoin/models/person/__init__.py +++ b/src/cutecoin/models/person/__init__.py @@ -37,6 +37,10 @@ class Person(object): name = uids[0]["uid"] else: raise PersonNotFoundError(pubkey, community.name()) + return None + else: + raise PersonNotFoundError(pubkey, community.name()) + return None return cls(name, pubkey) @classmethod diff --git a/src/cutecoin/tools/exceptions.py b/src/cutecoin/tools/exceptions.py index 6354da4d9403f66b59955d840b84126fbde2ab1f..3161338940d1846875589b9b91c8869d998627de 100644 --- a/src/cutecoin/tools/exceptions.py +++ b/src/cutecoin/tools/exceptions.py @@ -24,7 +24,7 @@ class NotMemberOfCommunityError(Error): ''' Constructor ''' - super(NotMemberOfCommunityError, self) \ + super() \ .__init__(account + " is not a member of " + community) @@ -39,9 +39,7 @@ class PersonNotFoundError(Error): ''' Constructor ''' - super( - PersonNotFoundError, - self) .__init( + super() .__init__( "Person looked by " + value + " in " + @@ -59,7 +57,7 @@ class AlgorithmNotImplemented(Error): ''' Constructor ''' - super(AlgorithmNotImplemented, self) \ + super() \ .__init__("Algorithm " + algo_name + " not implemented.") @@ -74,9 +72,7 @@ class KeyAlreadyUsed(Error): ''' Constructor ''' - super( - KeyAlreadyUsed, - self) .__init__( + super() .__init__( "Cannot add account " + new_account.name + " : the pgpKey " + @@ -96,9 +92,7 @@ class NameAlreadyExists(Error): ''' Constructor ''' - super( - KeyAlreadyUsed, - self) .__init__( + super() .__init__( "Cannot add account " + account.name + " the name already exists") @@ -115,7 +109,5 @@ class BadAccountFile(Error): ''' Constructor ''' - super( - BadAccountFile, - self) .__init__( + super() .__init__( "File " + path + " is not an account file")