From c32e5ba6c63b1afd2393ec98f5cbac2cf33b2532 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Tue, 7 Jul 2015 08:15:44 +0200 Subject: [PATCH] Multiples fixes with transfers --- src/cutecoin/core/transfer.py | 9 ++++++--- src/cutecoin/core/wallet.py | 2 +- src/cutecoin/gui/currency_tab.py | 6 +++--- src/cutecoin/gui/mainwindow.py | 2 +- src/cutecoin/gui/transfer.py | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cutecoin/core/transfer.py b/src/cutecoin/core/transfer.py index 95b316a6..f7785927 100644 --- a/src/cutecoin/core/transfer.py +++ b/src/cutecoin/core/transfer.py @@ -114,20 +114,23 @@ class Transfer(QObject): self.state = Transfer.AWAITING self.hash = hashlib.sha1(txdoc.signed_raw().encode("ascii")).hexdigest().upper() blockid = yield from community.blockid() - self._metadata['block'] = blockid['number'] - self._metadata['time'] = community.get_block()['medianTime'] + block = yield from community.bma_access.future_request(qtbma.blockchain.Block, + req_args={'number': blockid['number']}) + if block != qtbma.Blockchain.Block.null_value: + self._metadata['block'] = blockid['number'] + self._metadata['time'] = block['medianTime'] def __handle_transfers_reply(self, replies, reply): strdata = bytes(reply.readAll()).decode('utf-8') logging.debug("Received reply : {0} : {1}".format(reply.error(), strdata)) if reply.error() == QNetworkReply.NoError: - self.transfer_broadcasted.emit(self.metadata['receiver_uid']) for r in replies: try: r.disconnect() except TypeError as e: if "disconnect()" in str(e): logging.debug("Could not disconnect a reply") + self.transfer_broadcasted.emit(self.metadata['receiver_uid']) else: for r in replies: if not r.isFinished() or r.error() == QNetworkReply.NoError: diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index a0628c52..751d9099 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -274,7 +274,7 @@ class Wallet(QObject): result = self.tx_inputs(int(amount), community) inputs = result[0] - self.caches[community.currency].available_sources = result[1:] + self.caches[community.currency].available_sources = result[1][1:] logging.debug("Inputs : {0}".format(inputs)) outputs = self.tx_outputs(recipient, amount, inputs) diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 1e79f719..ad666123 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -162,11 +162,11 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): logging.debug("Refresh status") text = self.tr(" Block {0}").format(self.community.network.latest_block) - blockchain_time = self.community.get_block(self.community.network.latest_block)['medianTime'] - if blockchain_time != qtbma.blockchain.Block.null_value: + block = self.community.get_block(self.community.network.latest_block) + if block != qtbma.blockchain.Block.null_value: text += " ( {0} )".format(QLocale.toString( QLocale(), - QDateTime.fromTime_t(blockchain_time), + QDateTime.fromTime_t(block['medianTime']), QLocale.dateTimeFormat(QLocale(), QLocale.NarrowFormat) )) diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index 4e7b261c..56d776e6 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -143,7 +143,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): QApplication.processEvents() def open_transfer_money_dialog(self): - dialog = TransferMoneyDialog(self.app.current_account, + dialog = TransferMoneyDialog(self.app, self.app.current_account, self.password_asker) dialog.accepted.connect(self.refresh_wallets) if dialog.exec_() == QDialog.Accepted: diff --git a/src/cutecoin/gui/transfer.py b/src/cutecoin/gui/transfer.py index d514c900..4b0ce6dc 100644 --- a/src/cutecoin/gui/transfer.py +++ b/src/cutecoin/gui/transfer.py @@ -28,6 +28,7 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog): """ super().__init__() self.setupUi(self) + self.app = app self.account = sender self.password_asker = password_asker self.recipient_trusts = [] -- GitLab