Skip to content
Snippets Groups Projects
Commit 83a04516 authored by inso's avatar inso
Browse files

Multiple bug fixes with new accounts

parent 4cda8e93
Branches
Tags
No related merge requests found
......@@ -113,12 +113,18 @@ class Account(object):
def certify(self, password, community, pubkey):
certified = Person.lookup(pubkey, community)
try:
block = community.get_block()
block_number = block.number
block_hash = hashlib.sha1(block.signed_raw().encode("ascii")).hexdigest().upper()
except ValueError as e:
block_number = 0
block_hash = "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
certification = Certification(PROTOCOL_VERSION, community.currency,
self.pubkey, certified.pubkey,
block_hash, block.number, None)
block_hash, block_number, None)
selfcert = certified.selfcert(community)
logging.debug("SelfCertification : {0}".format(selfcert.raw()))
......@@ -202,10 +208,11 @@ class Account(object):
try:
block = community.get_block()
block_hash = hashlib.sha1(block.signed_raw().encode("ascii")).hexdigest().upper()
block_number = block['number']
block_number = block.number
except ValueError as e:
block_number = 0
block_hash = "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
membership = Membership(PROTOCOL_VERSION, community.currency,
selfcert.pubkey, block_number,
block_hash, type, selfcert.uid,
......
......@@ -126,12 +126,11 @@ class Community(object):
def request(self, request, req_args={}, get_args={}, cached=True):
for peer in self.peers:
e = next(e for e in peer.endpoints if type(e) is BMAEndpoint)
if cached:
self.check_current_block(e)
if cached and self.last_block["number"] != 0:
try:
# We request the current block every five minutes
# If a new block is mined we reset the cache
self.check_current_block(e)
cache_key = (hash(request),
hash(tuple(frozenset(sorted(req_args.keys())))),
hash(tuple(frozenset(sorted(req_args.items())))),
......
......@@ -167,8 +167,10 @@ class Wallet(object):
self.caches[currency].load_from_json(json_data[currency])
def jsonify_caches(self):
data = {}
for currency in self.caches:
return {currency: self.caches[currency].jsonify()}
data[currency] = self.caches[currency].jsonify()
return data
def refresh_cache(self, community):
if community.currency not in self.caches:
......
......@@ -104,7 +104,7 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
self.account.send_membership(password, self.community, 'IN')
except ValueError as e:
QMessageBox.critical(self, "Join demand error",
e.message)
str(e))
except PersonNotFoundError as e:
QMessageBox.critical(self, "Key not sent to community",
"Your key wasn't sent in the community. \
......
......@@ -200,7 +200,7 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog):
def open_process_edit_community(self, index):
community = self.account.communities[index.row()]
dialog = ProcessConfigureCommunity(self.account, community)
dialog = ProcessConfigureCommunity(self.account, community, self.password_asker)
dialog.accepted.connect(self.action_edit_community)
dialog.exec_()
......
......@@ -3,7 +3,7 @@ Created on 2 févr. 2014
@author: inso
'''
from PyQt5.QtWidgets import QDialog, QErrorMessage, QInputDialog, QLineEdit, QMessageBox
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QMessageBox
from ..tools.exceptions import NotEnoughMoneyError
from ..core.person import Person
......@@ -41,6 +41,11 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
for contact in sender.contacts:
self.combo_contact.addItem(contact.name)
if len(self.sender.contacts) == 0:
self.combo_contact.setEnabled(False)
self.radio_contact.setEnabled(False)
self.radio_pubkey.setChecked(True)
def accept(self):
comment = self.edit_message.text()
......@@ -94,13 +99,19 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
self.label_total.setText(self.wallet.get_text(self.community))
self.spinbox_amount.setSuffix(" " + self.community.currency)
self.spinbox_amount.setValue(0)
self.spinbox_amount.setMaximum(self.wallet.value(self.community))
amount = self.wallet.value(self.community)
relative = amount / self.dividend
self.spinbox_amount.setMaximum(amount)
self.spinbox_relative.setMaximum(relative)
def change_displayed_wallet(self, index):
self.wallet = self.sender.wallets[index]
self.label_total.setText(self.wallet.get_text(self.community))
self.spinbox_amount.setValue(0)
self.spinbox_amount.setMaximum(self.wallet.value(self.community))
amount = self.wallet.value(self.community)
relative = amount / self.dividend
self.spinbox_amount.setMaximum(amount)
self.spinbox_relative.setMaximum(relative)
def recipient_mode_changed(self, pubkey_toggled):
self.edit_pubkey.setEnabled(pubkey_toggled)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment