diff --git a/res/ui/transferDialog.ui b/res/ui/transferDialog.ui index 2ac25e29a4e9d9350d8b730240ea3224aa1fb85c..42436b5f256ec6fb0f1dabe9c37c4ca845ab59a4 100644 --- a/res/ui/transferDialog.ui +++ b/res/ui/transferDialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>400</width> - <height>489</height> + <height>486</height> </rect> </property> <property name="windowTitle"> @@ -69,13 +69,6 @@ </property> </widget> </item> - <item> - <widget class="QPushButton" name="button_get_trusts"> - <property name="text"> - <string>Get trusts nodes</string> - </property> - </widget> - </item> </layout> </item> </layout> @@ -103,7 +96,14 @@ </widget> </item> <item> - <widget class="QComboBox" name="combo_wallets"/> + <widget class="QComboBox" name="combo_wallets"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + </widget> </item> </layout> </item> @@ -199,7 +199,7 @@ <item> <widget class="QLabel" name="label_total"> <property name="text"> - <string>Total money transfered : 0 </string> + <string/> </property> </widget> </item> diff --git a/src/cutecoin/gui/processConfigureAccount.py b/src/cutecoin/gui/processConfigureAccount.py index 6e1cbeb0375acbf121a2ea033b3c88b547af9bf1..a29982d1b2681955c5942c91444ee09721cfd0a7 100644 --- a/src/cutecoin/gui/processConfigureAccount.py +++ b/src/cutecoin/gui/processConfigureAccount.py @@ -86,7 +86,6 @@ class StepPageCommunities(Step): account = self.config_dialog.account self.config_dialog.community = account.communities.add_community( default_node) - #TODO: Get existing Wallet from ucoin node account.wallets.add_wallet(account.keyid, self.config_dialog.community) self.config_dialog.refresh() diff --git a/src/cutecoin/gui/processConfigureCommunity.py b/src/cutecoin/gui/processConfigureCommunity.py index 9ea87a89a3a8c475ece799bc23b7fa20c0b7bb57..fd55ab0e746e6fbcd20f3c685bf23a7755d8eba1 100644 --- a/src/cutecoin/gui/processConfigureCommunity.py +++ b/src/cutecoin/gui/processConfigureCommunity.py @@ -60,7 +60,6 @@ class StepPageAddNodes(Step): def __init__(self, config_dialog): super().__init__(config_dialog) - #TODO: Check page validity def is_valid(self): return True @@ -88,7 +87,6 @@ class StepPageSetWallets(Step): def __init__(self, config_dialog): super().__init__(config_dialog) - #TODO: Check page validity def is_valid(self): return True @@ -221,7 +219,6 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): QMessageBox.critical(self, "Pubkey publishing error", result) - #TODO: Push wht only if changed for wallet in self.account.wallets: if self.wallet_edit[wallet.name]: result = wallet.push_wht(self.account.gpg) diff --git a/src/cutecoin/gui/processCreateWallet.py b/src/cutecoin/gui/processCreateWallet.py index 9d35e98e03228db20841e766c46fac3040c21636..23d2f68da74d95eb917f8da7c62298c146de067f 100644 --- a/src/cutecoin/gui/processCreateWallet.py +++ b/src/cutecoin/gui/processCreateWallet.py @@ -52,7 +52,6 @@ class StepPageKey(Step): def __init__(self, config_dialog): super().__init__(config_dialog) - #TODO: Check page validity def is_valid(self): return self.config_dialog.keyid != '' @@ -70,7 +69,6 @@ class StepPageNode(Step): def __init__(self, config_dialog): super().__init__(config_dialog) - #TODO: Check page validity def is_valid(self): address = self.config_dialog.edit_address.text() port = self.config_dialog.spinbox_port.value() diff --git a/src/cutecoin/gui/transferMoneyDialog.py b/src/cutecoin/gui/transferMoneyDialog.py index 173e375d5cac96698d5e76e4f3216af893e60d00..1ba5dba3ad2c98eab04364e75fcaf1e648478809 100644 --- a/src/cutecoin/gui/transferMoneyDialog.py +++ b/src/cutecoin/gui/transferMoneyDialog.py @@ -42,16 +42,22 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): for select in selection: coins = self.list_coins_sent.model().remove_coins(select, 1) self.list_wallet.model().add_coins(coins) - self.label_total.setText("Total : %d" % - self.list_coins_sent.model().total()) + self.refresh_total() def add_coins_to_transfer(self): selection = self.list_wallet.selectedIndexes() for select in selection: coins = self.list_wallet.model().remove_coins(select, 1) self.list_coins_sent.model().add_coins(coins) - self.label_total.setText("Total : %d" - % self.list_coins_sent.model().total()) + self.refresh_total() + + def refresh_total(self): + dividend = self.wallet.get_amendment(None)['dividend'] + total = self.list_coins_sent.model().total() + relative_total = total / int(dividend) + self.label_total.setText("Total : \n \ +%d %s \n \ +%.2f UD" % (total, self.wallet.currency, relative_total)) def accept(self): sent_coins = self.list_coins_sent.model().to_list() @@ -64,7 +70,6 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): self.combo_contact.currentIndex()] message = self.edit_message.text() - # TODO: All nodes trusted by recipient error = self.wallet.transfer_coins(recipient, sent_coins, message) if error: QErrorMessage(self).showMessage("Cannot transfer coins " + error) diff --git a/src/cutecoin/models/coin/__init__.py b/src/cutecoin/models/coin/__init__.py index 5c31cd0239c5ee954fbeb73f91d3fb9f21099117..614010e24224fa09501adc6d05ec721c2d1110ef 100644 --- a/src/cutecoin/models/coin/__init__.py +++ b/src/cutecoin/models/coin/__init__.py @@ -38,7 +38,7 @@ class Coin(object): def value(self, wallet): amendment = wallet.get_amendment(self.am_number) if 'CoinAlgo' in amendment: - coin_algo_name = self.amendment['CoinAlgo'] + coin_algo_name = amendment['CoinAlgo'] else: coin_algo_name = 'Base2Draft' diff --git a/src/cutecoin/models/wallet/__init__.py b/src/cutecoin/models/wallet/__init__.py index 1af9a2796b81f5cdedee16d77438e188627bcc5d..1646933356e6932745264a8a2f05b03e5cc8eb1f 100644 --- a/src/cutecoin/models/wallet/__init__.py +++ b/src/cutecoin/models/wallet/__init__.py @@ -11,6 +11,7 @@ import json import time import hashlib import importlib +from decimal import Decimal from cutecoin.models.coin import Coin from cutecoin.models.coin import algorithms from cutecoin.models.node import Node @@ -60,7 +61,12 @@ class Wallet(object): def __eq__(self, other): return (self.keyid == other.keyid) - #TODO: Relative and quantitative value + def relative_value(self): + value = self.value() + amendment = self.get_amendment(None) + relative_value = value / float(amendment['dividend']) + return relative_value + def value(self): value = 0 for coin in self.coins: @@ -295,7 +301,8 @@ Hosters: else: amendment_req = ucoin.hdc.amendments.Promoted(am_number) new_am = self.request(amendment_req) - self.amendments_cache[am_number] = new_am + number = int(new_am['number']) + self.amendments_cache[number] = new_am return new_am def fingerprint(self, gpg): @@ -308,8 +315,10 @@ Hosters: return "" def get_text(self): - return self.name + " : " + \ - str(self.value()) + " " + self.currency + return "%s : \n \ +%d %s \n \ +%.2f UD" % (self.name, self.value(), self.currency, + self.relative_value()) def jsonify_coins_list(self): data = []