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

Errors-ready dialog

parent 419a1b5c
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,14 @@ class Wallet(object): ...@@ -46,6 +46,14 @@ class Wallet(object):
def __eq__(self, other): def __eq__(self, other):
return (self.keyid == other.keyid) return (self.keyid == other.keyid)
def check_password(self, salt, password):
key = None
if self.walletid == 0:
key = SigningKey(salt, password)
else:
key = SigningKey("{0}{1}".format(salt, self.walletid), password)
return (key.pubkey == self.pubkey)
def relative_value(self, community): def relative_value(self, community):
value = self.value(community) value = self.value(community)
ud = community.dividend() ud = community.dividend()
...@@ -106,11 +114,8 @@ class Wallet(object): ...@@ -106,11 +114,8 @@ class Wallet(object):
logging.debug("Signature : {0}".format(str(signing.signature))) logging.debug("Signature : {0}".format(str(signing.signature)))
tx.signatures = [str(signing.signature, 'ascii')] tx.signatures = [str(signing.signature, 'ascii')]
logging.debug("Transaction : {0}".format(tx.signed_raw())) logging.debug("Transaction : {0}".format(tx.signed_raw()))
try: community.post(bma.tx.Process,
community.post(bma.tx.Process, post_args={'transaction': tx.signed_raw()})
post_args={'transaction': tx.signed_raw()})
except ValueError as e:
logging.debug("Error : {0}".format(e))
def sources(self, community): def sources(self, community):
data = community.request(bma.tx.Sources, req_args={'pubkey': self.pubkey}) data = community.request(bma.tx.Sources, req_args={'pubkey': self.pubkey})
......
...@@ -3,7 +3,7 @@ Created on 2 févr. 2014 ...@@ -3,7 +3,7 @@ Created on 2 févr. 2014
@author: inso @author: inso
''' '''
from PyQt5.QtWidgets import QDialog, QErrorMessage, QInputDialog, QLineEdit from PyQt5.QtWidgets import QDialog, QErrorMessage, QInputDialog, QLineEdit, QMessageBox
from cutecoin.core.person import Person from cutecoin.core.person import Person
...@@ -50,15 +50,32 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): ...@@ -50,15 +50,32 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
else: else:
return return
error = self.wallet.send_money(self.sender.salt, password, self.community, while not self.wallet.check_password(self.sender.salt, password):
password = QInputDialog.getText(self, "Wallet password",
"Wrong password.\nPlease enter your password",
QLineEdit.Password)
if password[1] is True:
password = password[0]
else:
return
try:
self.wallet.send_money(self.sender.salt, password, self.community,
recipient, amount, message) recipient, amount, message)
QMessageBox.information(self, "Money transfer",
"Success transfering {0} {1} to {2}".format(amount,
self.community.currency,
recipient))
except ValueError as e:
QMessageBox.critical(self, "Money transfer",
"Something wrong happened : {0}".format(e),
QMessageBox.Ok)
self.accepted.emit() self.accepted.emit()
self.close() self.close()
def amount_changed(self): def amount_changed(self):
amount = self.spinbox_amount.value() amount = self.spinbox_amount.value()
dividend = self.community.dividend()
relative = amount / self.dividend relative = amount / self.dividend
self.spinbox_relative.blockSignals(True) self.spinbox_relative.blockSignals(True)
self.spinbox_relative.setValue(relative) self.spinbox_relative.setValue(relative)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment