electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c2d40db47c9084cb154e18d2799f2d2ca9ab8406
parent 682645bfe0434bd968262723744c283c30fad599
Author: ThomasV <thomasv@electrum.org>
Date:   Mon,  6 Mar 2017 20:56:43 +0100

add RBF policy to preferences

Diffstat:
Mgui/qt/main_window.py | 38+++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1042,7 +1042,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): _('and you will have the possiblity, while it is unconfirmed, to replace it with a transaction that pays a higher fee.'), _('Note that some merchants do not accept non-final transactions until they are confirmed.')] self.rbf_checkbox.setToolTip('<p>' + ' '.join(msg) + '</p>') - self.rbf_checkbox.setVisible(self.config.get('use_rbf', False)) + self.rbf_checkbox.setVisible(False) grid.addWidget(self.fee_e_label, 5, 0) grid.addWidget(self.fee_slider, 5, 1) @@ -1149,6 +1149,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.not_enough_funds = False except NotEnoughFunds: self.not_enough_funds = True + except BaseException: + return if not freeze_fee: fee = None if self.not_enough_funds else self.wallet.get_tx_fee(tx) self.fee_e.setAmount(fee) @@ -1157,6 +1159,22 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): amount = tx.output_value() self.amount_e.setAmount(amount) + rbf_policy = self.config.get('rbf_policy', 1) + if rbf_policy == 0: + b = True + elif rbf_policy == 1: + fee_rate = tx.get_fee() * 1000 / tx.estimated_size() + try: + c = self.config.reverse_dynfee(fee_rate) + b = c in [-1, 25] + except: + b = False + elif rbf_policy == 2: + b = False + self.rbf_checkbox.setVisible(b) + self.rbf_checkbox.setChecked(b) + + def from_list_delete(self, item): i = self.from_list.indexOfTopLevelItem(item) self.pay_from.pop(i) @@ -2407,17 +2425,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): feebox_cb.stateChanged.connect(on_feebox) fee_widgets.append((feebox_cb, None)) - use_rbf = self.config.get('use_rbf', False) - rbf_cb = QCheckBox(_('Enable Replace-By-Fee')) - rbf_cb.setChecked(use_rbf) + rbf_policy = self.config.get('rbf_policy', 1) + rbf_label = HelpLabel(_('Propose Replace-By-Fee') + ':', '') + rbf_combo = QComboBox() + rbf_combo.addItems([_('Always'), _('If the fee is low'), _('Never')]) + rbf_combo.setCurrentIndex(rbf_policy) def on_rbf(x): - rbf_result = x == Qt.Checked - 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)) + self.config.set_key('rbf_policy', x) + rbf_combo.currentIndexChanged.connect(on_rbf) + fee_widgets.append((rbf_label, rbf_combo)) msg = _('OpenAlias record, used to receive coins and to sign payment requests.') + '\n\n'\ + _('The following alias providers are available:') + '\n'\