From ca30705c693f0b00e7a3209cf894fdbff0d2c8a7 Mon Sep 17 00:00:00 2001 From: Vivek Teegalapally Date: Sun, 5 Aug 2018 21:12:18 +0530 Subject: [PATCH] Commiting comment/floData changes The changes made in this commit make sure the transaction comments or floData are being sent out of the wallet. It still has some errors left though, related to verifying SegWit address. --- electrum/gui/qt/history_list.py | 5 +++-- electrum/gui/qt/main_window.py | 13 ++++++++++--- electrum/wallet.py | 11 ++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py index c789bc57..edcdc682 100644 --- a/electrum/gui/qt/history_list.py +++ b/electrum/gui/qt/history_list.py @@ -72,7 +72,7 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): return str(datetime.date(d.year, d.month, d.day)) if d else _('None') def refresh_headers(self): - headers = ['', '', _('Date'), _('Description'), _('Amount'), _('Balance')] + headers = ['', '', _('Date'), _('Description'), _('Amount'), _('Balance'), _('FLO Data')] fx = self.parent.fx if fx and fx.show_history(): headers.extend(['%s '%fx.ccy + _('Value')]) @@ -246,7 +246,8 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): icon = self.icon_cache.get(":icons/" + TX_ICONS[status]) v_str = self.parent.format_amount(value, is_diff=True, whitespaces=True) balance_str = self.parent.format_amount(balance, whitespaces=True) - entry = ['', tx_hash, status_str, label, v_str, balance_str] + txcomment = self.wallet.get_tx_comment(tx_hash) + entry = ['', tx_hash, status_str, label, v_str, balance_str, txcomment] fiat_value = None if value is not None and fx and fx.show_history(): fiat_value = tx_item['fiat_value'].value diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index e58f6480..0386c94e 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -1067,6 +1067,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.message_e = MyLineEdit() grid.addWidget(self.message_e, 2, 1, 1, -1) + msg = _('This is where you write the FLO Data for the transaction') + txcomment_label = HelpLabel(_('FLO Data'), msg) + grid.addWidget(txcomment_label, 7, 0) + self.message_tx = MyLineEdit() + grid.addWidget(self.message_tx, 7, 1, 1, -1) + self.from_label = QLabel(_('From')) grid.addWidget(self.from_label, 3, 0) self.from_list = MyTreeWidget(self, self.from_list_menu, ['','']) @@ -1463,6 +1469,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.show_error(_('Payment request has expired')) return label = self.message_e.text() + txcomment = self.message_tx.text() if self.payment_request: outputs = self.payment_request.get_outputs() @@ -1498,7 +1505,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): fee_estimator = self.get_send_fee_estimator() coins = self.get_coins() - return outputs, fee_estimator, label, coins + return outputs, fee_estimator, label, coins, txcomment def do_preview(self): self.do_send(preview = True) @@ -1509,12 +1516,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): r = self.read_send_tab() if not r: return - outputs, fee_estimator, tx_desc, coins = r + outputs, fee_estimator, tx_desc, coins, txcomment = r try: is_sweep = bool(self.tx_external_keypairs) tx = self.wallet.make_unsigned_transaction( coins, outputs, self.config, fixed_fee=fee_estimator, - is_sweep=is_sweep) + is_sweep=is_sweep, txcomment=txcomment) except NotEnoughFunds: self.show_message(_("Insufficient funds")) return diff --git a/electrum/wallet.py b/electrum/wallet.py index c9fef88b..18f10c1c 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -486,6 +486,11 @@ class Abstract_Wallet(AddressSynchronizer): return ', '.join(labels) return '' + def get_tx_comment(self, tx_hash): + tx = self.transactions.get(tx_hash) + comment = tx.txcomment[5:] + return comment + def get_tx_status(self, tx_hash, tx_mined_status): extra = [] height = tx_mined_status.height @@ -533,7 +538,7 @@ class Abstract_Wallet(AddressSynchronizer): return dust_threshold(self.network) def make_unsigned_transaction(self, inputs, outputs, config, fixed_fee=None, - change_addr=None, is_sweep=False): + change_addr=None, is_sweep=False, txcomment = ""): # check outputs i_max = None for i, o in enumerate(outputs): @@ -604,6 +609,10 @@ class Abstract_Wallet(AddressSynchronizer): tx.BIP_LI01_sort() # Timelock tx to current height. tx.locktime = self.get_local_height() + # Transactions with transaction comments/floData are version 2 + if txcomment != "": + tx.version = 2 + tx.txcomment = "text:" + txcomment run_hook('make_unsigned_transaction', self, tx) return tx