From 585c5c44c656dc60104258bed15ebbac355950ea Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Fri, 19 Dec 2014 18:30:43 +0100 Subject: [PATCH] Added contacts maangement --- lib/ucoinpy/documents/peer.py | 10 +++++----- res/ui/addContactDialog.ui | 2 +- src/cutecoin/core/account.py | 1 - src/cutecoin/core/wallet.py | 4 +--- src/cutecoin/gui/addContactDialog.py | 3 ++- src/cutecoin/gui/transferMoneyDialog.py | 7 ++++++- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/ucoinpy/documents/peer.py b/lib/ucoinpy/documents/peer.py index 6733c538..128da67b 100644 --- a/lib/ucoinpy/documents/peer.py +++ b/lib/ucoinpy/documents/peer.py @@ -142,11 +142,11 @@ class BMAEndpoint(Endpoint): self.port = port def inline(self): - return "BASIC_MERKLED_API {DNS} {IPv4} {IPv6} {PORT}" \ - .format(DNS=(self.server if self.server else ""), - IPv4=(self.ipv4 if self.ipv4 else ""), - IPv6=(self.ipv6 if self.ipv6 else ""), - PORT=(self.port if self.port else "")) + return "BASIC_MERKLED_API{DNS}{IPv4}{IPv6}{PORT}" \ + .format(DNS=(" {0}".format(self.server) if self.server else ""), + IPv4=(" {0}".format(self.ipv4) if self.ipv4 else ""), + IPv6=(" {0}".format(self.ipv6) if self.ipv6 else ""), + PORT=(" {0}".format(self.port) if self.port else "")) def conn_handler(self): if self.server: diff --git a/res/ui/addContactDialog.ui b/res/ui/addContactDialog.ui index 818f2da6..ac9d87ad 100644 --- a/res/ui/addContactDialog.ui +++ b/res/ui/addContactDialog.ui @@ -92,7 +92,7 @@ <sender>edit_pubkey</sender> <signal>textChanged(QString)</signal> <receiver>AddContactDialog</receiver> - <slot>fingerprint_edited()</slot> + <slot>pubkey_edited()</slot> <hints> <hint type="sourcelabel"> <x>145</x> diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index b2627b5f..60204357 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -7,7 +7,6 @@ Created on 1 févr. 2014 from ucoinpy.api import bma from ucoinpy.api.bma import ConnectionHandler from ucoinpy.documents.peer import Peer -from ucoinpy.key import SigningKey import logging from .wallet import Wallet from .community import Community diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 07e95c18..129e0730 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -11,14 +11,12 @@ from ucoinpy.documents.transaction import InputSource, OutputSource, Transaction from ucoinpy.key import SigningKey from ..tools.exceptions import NotEnoughMoneyError import logging -import base64 class Wallet(object): ''' - A wallet is list of coins. - It's only used to sort coins. + A wallet is used to manage money with a unique key. ''' def __init__(self, walletid, pubkey, currency, name): diff --git a/src/cutecoin/gui/addContactDialog.py b/src/cutecoin/gui/addContactDialog.py index f5cabef6..35fdd903 100644 --- a/src/cutecoin/gui/addContactDialog.py +++ b/src/cutecoin/gui/addContactDialog.py @@ -33,6 +33,7 @@ class AddContactDialog(QDialog, Ui_AddContactDialog): pubkey = self.edit_pubkey.text() self.account.add_contact(Person(name, pubkey)) self.main_window.menu_contacts_list.addAction(name) + self.main_window.app.save(self.account) self.close() def name_edited(self, new_name): @@ -43,4 +44,4 @@ class AddContactDialog(QDialog, Ui_AddContactDialog): pattern = re.compile("([1-9A-Za-z][^OIl]{42,45})") self.button_box.button( QDialogButtonBox.Ok).setEnabled( - pattern.match(new_pubkey)) + pattern.match(new_pubkey)is not None) diff --git a/src/cutecoin/gui/transferMoneyDialog.py b/src/cutecoin/gui/transferMoneyDialog.py index 8f5c9a01..18b548dc 100644 --- a/src/cutecoin/gui/transferMoneyDialog.py +++ b/src/cutecoin/gui/transferMoneyDialog.py @@ -40,7 +40,12 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): def accept(self): message = self.edit_message.text() - recipient = self.edit_key_fingerprint.text() + recipient = "" + if self.radio_contact.isEnabled(): + index = self.combo_contact.currentIndex() + recipient = self.sender.contacts[index].pubkey + else: + recipient = self.edit_key_fingerprint.text() amount = self.spinbox_amount.value() password = QInputDialog.getText(self, "Wallet password", "Please enter your password", -- GitLab