diff --git a/res/ui/addContactDialog.ui b/res/ui/addContactDialog.ui index b9f2ad6148b07b47323af16a7acc34602175eaeb..818f2da602276aa43786f659198cd2e20335371c 100644 --- a/res/ui/addContactDialog.ui +++ b/res/ui/addContactDialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>228</width> - <height>134</height> + <height>103</height> </rect> </property> <property name="windowTitle"> @@ -33,29 +33,12 @@ <item> <widget class="QLabel" name="label_2"> <property name="text"> - <string>Fingerprint</string> + <string>Pubkey</string> </property> </widget> </item> <item> - <widget class="QLineEdit" name="edit_fingerprint"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="topMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Email</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="edit_email"/> + <widget class="QLineEdit" name="edit_pubkey"/> </item> </layout> </item> @@ -106,7 +89,7 @@ </hints> </connection> <connection> - <sender>edit_fingerprint</sender> + <sender>edit_pubkey</sender> <signal>textChanged(QString)</signal> <receiver>AddContactDialog</receiver> <slot>fingerprint_edited()</slot> @@ -140,6 +123,6 @@ </connections> <slots> <slot>name_edited()</slot> - <slot>fingerprint_edited()</slot> + <slot>pubkey_edited()</slot> </slots> </ui> diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index 6c2e53f6986c621f39e824766b35ccf769c973c2..07e95c188e27424397ec40b46bf43389ede24d1d 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -30,6 +30,7 @@ class Wallet(object): self.pubkey = pubkey self.currency = currency self.name = name + self.inputs_cache = None @classmethod def create(cls, walletid, pubkey, currency, name): @@ -69,12 +70,21 @@ class Wallet(object): def tx_inputs(self, amount, community): value = 0 inputs = [] - for s in self.sources(community): + block = community.request(bma.blockchain.Current) + sources = self.sources(community) + if not self.inputs_cache: + self.inputs_cache = (block['number'], sources) + elif self.inputs_cache[0] < block['number']: + self.inputs_cache = (block['number'], sources) + + for s in self.inputs_cache[1]: value += s.amount s.index = 0 inputs.append(s) + self.inputs_cache[1].remove(s) if value >= amount: return inputs + raise NotEnoughMoneyError(amount, value) return [] diff --git a/src/cutecoin/gui/addContactDialog.py b/src/cutecoin/gui/addContactDialog.py index 157ad339bdb6dcbdfc35033fad00a89889709f13..f5cabef6e58fb50008cc4a79ea2f8cbdb2968f26 100644 --- a/src/cutecoin/gui/addContactDialog.py +++ b/src/cutecoin/gui/addContactDialog.py @@ -30,9 +30,8 @@ class AddContactDialog(QDialog, Ui_AddContactDialog): def accept(self): name = self.edit_name.text() - fingerprint = self.edit_fingerprint.text() - email = self.edit_email.text() - self.account.add_contact(Person(name, fingerprint, email)) + pubkey = self.edit_pubkey.text() + self.account.add_contact(Person(name, pubkey)) self.main_window.menu_contacts_list.addAction(name) self.close() @@ -40,8 +39,8 @@ class AddContactDialog(QDialog, Ui_AddContactDialog): name_ok = len(new_name) > 0 self.button_box.button(QDialogButtonBox.Ok).setEnabled(name_ok) - def fingerprint_edited(self, new_fingerprint): - pattern = re.compile("([A-Z]|[0-9])+") + def pubkey_edited(self, new_pubkey): + pattern = re.compile("([1-9A-Za-z][^OIl]{42,45})") self.button_box.button( QDialogButtonBox.Ok).setEnabled( - pattern.match(new_fingerprint) is not None) + pattern.match(new_pubkey))