Browse Source

add extra checkbox for RBF

283
ThomasV 9 years ago
parent
commit
f01f931e83
  1. 20
      gui/qt/main_window.py
  2. 4
      lib/transaction.py
  3. 3
      lib/wallet.py

20
gui/qt/main_window.py

@ -1040,9 +1040,13 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
# we go back to auto-calculate mode and put a fee back. # we go back to auto-calculate mode and put a fee back.
self.fee_e.editingFinished.connect(self.update_fee) 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_label, 5, 0)
grid.addWidget(self.fee_e, 5, 1) grid.addWidget(self.fee_e, 5, 1)
grid.addWidget(self.fee_slider, 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.send_button = EnterButton(_("Send"), self.do_send)
self.clear_button = EnterButton(_("Clear"), self.do_clear) self.clear_button = EnterButton(_("Clear"), self.do_clear)
@ -1280,6 +1284,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.show_message(str(e)) self.show_message(str(e))
return 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): 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")) self.show_error(_("This transaction requires a higher fee, or it will not be propagated by the network"))
return return
@ -1478,6 +1486,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
e.setText('') e.setText('')
e.setFrozen(False) e.setFrozen(False)
self.set_pay_from([]) self.set_pay_from([])
self.rbf_checkbox.setChecked(False)
self.update_status() self.update_status()
run_hook('do_clear', self) run_hook('do_clear', self)
@ -2805,15 +2814,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
qr_combo.currentIndexChanged.connect(on_video_device) qr_combo.currentIndexChanged.connect(on_video_device)
gui_widgets.append((qr_label, qr_combo)) gui_widgets.append((qr_label, qr_combo))
use_rbf = self.config.get('use_rbf', False)
rbf_cb = QCheckBox(_('Enable Replace-By-Fee')) rbf_cb = QCheckBox(_('Enable Replace-By-Fee'))
rbf_cb.setChecked(self.wallet.use_rbf) rbf_cb.setChecked(use_rbf)
if not self.config.is_modifiable('use_rbf'):
rbf_cb.setEnabled(False)
def on_rbf(x): def on_rbf(x):
rbf_result = x == Qt.Checked rbf_result = x == Qt.Checked
if self.wallet.use_rbf != rbf_result: self.config.set_key('use_rbf', rbf_result)
self.wallet.use_rbf = rbf_result self.rbf_checkbox.setVisible(rbf_result)
self.wallet.storage.put('use_rbf', self.wallet.use_rbf) self.rbf_checkbox.setChecked(False)
rbf_cb.stateChanged.connect(on_rbf) rbf_cb.stateChanged.connect(on_rbf)
rbf_cb.setToolTip(_('Enable RBF')) rbf_cb.setToolTip(_('Enable RBF'))
fee_widgets.append((rbf_cb, None)) fee_widgets.append((rbf_cb, None))

4
lib/transaction.py

@ -675,6 +675,10 @@ class Transaction:
s += int_to_hex(txin.get('sequence', 0xffffffff), 4) s += int_to_hex(txin.get('sequence', 0xffffffff), 4)
return s return s
def set_sequence(self, n):
for txin in self.inputs():
txin['sequence'] = n
def BIP_LI01_sort(self): def BIP_LI01_sort(self):
# See https://github.com/kristovatlas/rfc/blob/master/bips/bip-li01.mediawiki # See https://github.com/kristovatlas/rfc/blob/master/bips/bip-li01.mediawiki
self._inputs.sort(key = lambda i: (i['prevout_hash'], i['prevout_n'])) self._inputs.sort(key = lambda i: (i['prevout_hash'], i['prevout_n']))

3
lib/wallet.py

@ -175,14 +175,12 @@ class Abstract_Wallet(PrintError):
self.use_change = storage.get('use_change', True) self.use_change = storage.get('use_change', True)
self.multiple_change = storage.get('multiple_change', False) self.multiple_change = storage.get('multiple_change', False)
self.use_encryption = storage.get('use_encryption', False) self.use_encryption = storage.get('use_encryption', False)
self.use_rbf = storage.get('use_rbf', False)
self.seed = storage.get('seed', '') # encrypted self.seed = storage.get('seed', '') # encrypted
self.labels = storage.get('labels', {}) self.labels = storage.get('labels', {})
self.frozen_addresses = set(storage.get('frozen_addresses',[])) self.frozen_addresses = set(storage.get('frozen_addresses',[]))
self.stored_height = storage.get('stored_height', 0) # last known height (for offline mode) self.stored_height = storage.get('stored_height', 0) # last known height (for offline mode)
self.history = storage.get('addr_history',{}) # address -> list(txid, height) self.history = storage.get('addr_history',{}) # address -> list(txid, height)
# imported_keys is deprecated. The GUI should call convert_imported_keys # imported_keys is deprecated. The GUI should call convert_imported_keys
self.imported_keys = self.storage.get('imported_keys',{}) self.imported_keys = self.storage.get('imported_keys',{})
@ -999,7 +997,6 @@ class Abstract_Wallet(PrintError):
def add_input_info(self, txin): def add_input_info(self, txin):
address = txin['address'] address = txin['address']
txin['sequence'] = 0 if self.use_rbf else 0xffffffff
account_id, sequence = self.get_address_index(address) account_id, sequence = self.get_address_index(address)
account = self.accounts[account_id] account = self.accounts[account_id]
redeemScript = account.redeem_script(*sequence) redeemScript = account.redeem_script(*sequence)

Loading…
Cancel
Save