tadd extra checkbox for RBF - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f01f931e833e5eeff286b5cf62ed0803adf55246 DIR parent 18a2498b76cb5de667e48cd667125d0d4c93cb6d HTML Author: ThomasV <thomasv@electrum.org> Date: Mon, 23 May 2016 17:34:33 +0200 add extra checkbox for RBF Diffstat: M gui/qt/main_window.py | 20 ++++++++++++++------ M lib/transaction.py | 4 ++++ M lib/wallet.py | 3 --- 3 files changed, 18 insertions(+), 9 deletions(-) --- DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py t@@ -1040,9 +1040,13 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): # we go back to auto-calculate mode and put a fee back. self.fee_e.editingFinished.connect(self.update_fee) + self.rbf_checkbox = QCheckBox('RBF') + self.rbf_checkbox.setVisible(self.config.get('use_rbf', False)) + grid.addWidget(self.fee_e_label, 5, 0) grid.addWidget(self.fee_e, 5, 1) grid.addWidget(self.fee_slider, 5, 1) + grid.addWidget(self.rbf_checkbox, 5, 2) self.send_button = EnterButton(_("Send"), self.do_send) self.clear_button = EnterButton(_("Clear"), self.do_clear) t@@ -1280,6 +1284,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.show_message(str(e)) return + use_rbf = self.rbf_checkbox.isChecked() + if use_rbf: + tx.set_sequence(0) + if tx.get_fee() < self.wallet.relayfee() and tx.requires_fee(self.wallet): self.show_error(_("This transaction requires a higher fee, or it will not be propagated by the network")) return t@@ -1478,6 +1486,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): e.setText('') e.setFrozen(False) self.set_pay_from([]) + self.rbf_checkbox.setChecked(False) self.update_status() run_hook('do_clear', self) t@@ -2805,15 +2814,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): qr_combo.currentIndexChanged.connect(on_video_device) gui_widgets.append((qr_label, qr_combo)) + use_rbf = self.config.get('use_rbf', False) rbf_cb = QCheckBox(_('Enable Replace-By-Fee')) - rbf_cb.setChecked(self.wallet.use_rbf) - if not self.config.is_modifiable('use_rbf'): - rbf_cb.setEnabled(False) + rbf_cb.setChecked(use_rbf) def on_rbf(x): rbf_result = x == Qt.Checked - if self.wallet.use_rbf != rbf_result: - self.wallet.use_rbf = rbf_result - self.wallet.storage.put('use_rbf', self.wallet.use_rbf) + self.config.set_key('use_rbf', rbf_result) + self.rbf_checkbox.setVisible(rbf_result) + self.rbf_checkbox.setChecked(False) rbf_cb.stateChanged.connect(on_rbf) rbf_cb.setToolTip(_('Enable RBF')) fee_widgets.append((rbf_cb, None)) DIR diff --git a/lib/transaction.py b/lib/transaction.py t@@ -675,6 +675,10 @@ class Transaction: s += int_to_hex(txin.get('sequence', 0xffffffff), 4) return s + def set_sequence(self, n): + for txin in self.inputs(): + txin['sequence'] = n + def BIP_LI01_sort(self): # See https://github.com/kristovatlas/rfc/blob/master/bips/bip-li01.mediawiki self._inputs.sort(key = lambda i: (i['prevout_hash'], i['prevout_n'])) DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -175,14 +175,12 @@ class Abstract_Wallet(PrintError): self.use_change = storage.get('use_change', True) self.multiple_change = storage.get('multiple_change', False) self.use_encryption = storage.get('use_encryption', False) - self.use_rbf = storage.get('use_rbf', False) self.seed = storage.get('seed', '') # encrypted self.labels = storage.get('labels', {}) self.frozen_addresses = set(storage.get('frozen_addresses',[])) self.stored_height = storage.get('stored_height', 0) # last known height (for offline mode) self.history = storage.get('addr_history',{}) # address -> list(txid, height) - # imported_keys is deprecated. The GUI should call convert_imported_keys self.imported_keys = self.storage.get('imported_keys',{}) t@@ -999,7 +997,6 @@ class Abstract_Wallet(PrintError): def add_input_info(self, txin): address = txin['address'] - txin['sequence'] = 0 if self.use_rbf else 0xffffffff account_id, sequence = self.get_address_index(address) account = self.accounts[account_id] redeemScript = account.redeem_script(*sequence)