diff --git a/src/cutecoin/core/transfer.py b/src/cutecoin/core/transfer.py index 95b316a6014e56a584801ea7ade6535e954b899e..f7785927391ca4c061fb0acd994b83099eed5c91 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 a0628c52f15ceb1d8e4afc7e5b6555cd6a2bc34b..751d9099bfc62fb35a6690caee515722ab12acb9 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 1e79f71960b275fea585eef8d0920cd419687748..ad666123ed7b06767a7ac44626062520113646ac 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 4e7b261ced0492a419349eead76ba8f20483b0cf..56d776e66f3137e8e11eb28022e6be92ab4e3124 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 d514c90022ec3e949144ddc37ed2f12d8f72ec20..4b0ce6dc8c7a6b0a487a46a29b8545a1afc6401a 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 = []