From cbd4d2a2ae47091658688367828003dd9970add0 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 4 Jul 2022 17:28:56 +0200 Subject: [PATCH] make rbf selection allowed configurable --- electrum/gui/qml/components/ConfirmTxDialog.qml | 1 + electrum/gui/qml/components/Send.qml | 1 + electrum/gui/qml/qechannelopener.py | 3 +++ electrum/gui/qml/qetxfinalizer.py | 14 ++++++++++++++ 4 files changed, 19 insertions(+) diff --git a/electrum/gui/qml/components/ConfirmTxDialog.qml b/electrum/gui/qml/components/ConfirmTxDialog.qml index a6394bf1a..b19db825f 100644 --- a/electrum/gui/qml/components/ConfirmTxDialog.qml +++ b/electrum/gui/qml/components/ConfirmTxDialog.qml @@ -179,6 +179,7 @@ Dialog { text: qsTr('Replace-by-Fee') Layout.columnSpan: 2 checked: finalizer.rbf + visible: finalizer.canRbf } Rectangle { diff --git a/electrum/gui/qml/components/Send.qml b/electrum/gui/qml/components/Send.qml index 77f605f58..96d0aa313 100644 --- a/electrum/gui/qml/components/Send.qml +++ b/electrum/gui/qml/components/Send.qml @@ -245,6 +245,7 @@ Pane { title: qsTr('Confirm Payment') finalizer: TxFinalizer { wallet: Daemon.currentWallet + canRbf: True } } } diff --git a/electrum/gui/qml/qechannelopener.py b/electrum/gui/qml/qechannelopener.py index 99fef56d1..8c5767380 100644 --- a/electrum/gui/qml/qechannelopener.py +++ b/electrum/gui/qml/qechannelopener.py @@ -140,11 +140,13 @@ class QEChannelOpener(QObject): acpt = lambda tx: self.do_open_channel(tx, str(self._peer), None) self._finalizer = QETxFinalizer(self, make_tx=mktx, accept=acpt) + self._finalizer.canRbf = False self._finalizer.amount = self._amount self._finalizer.wallet = self._wallet self.finalizerChanged.emit() def do_open_channel(self, funding_tx, conn_str, password): + self._logger.debug('opening channel') # read funding_sat from tx; converts '!' to int value funding_sat = funding_tx.output_value_for_address(ln_dummy_address()) lnworker = self._wallet.wallet.lnworker @@ -160,6 +162,7 @@ class QEChannelOpener(QObject): self.channelOpenError.emit(_('Problem opening channel: ') + '\n' + repr(e)) return + self._logger.debug('opening channel succeeded') self.channelOpenSuccess.emit(chan.channel_id.hex(), chan.has_onchain_backup()) # TODO: it would be nice to show this before broadcasting diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py index 4467ef1fa..7a8c9fef9 100644 --- a/electrum/gui/qml/qetxfinalizer.py +++ b/electrum/gui/qml/qetxfinalizer.py @@ -32,6 +32,7 @@ class QETxFinalizer(QObject): _warning = '' _target = '' _rbf = False + _canRbf = False _outputs = [] config = None @@ -126,6 +127,19 @@ class QETxFinalizer(QObject): self.update() self.rbfChanged.emit() + canRbfChanged = pyqtSignal() + @pyqtProperty(bool, notify=canRbfChanged) + def canRbf(self): + return self._canRbf + + @canRbf.setter + def canRbf(self, canRbf): + if self._canRbf != canRbf: + self._canRbf = canRbf + self.canRbfChanged.emit() + if not canRbf and self.rbf: + self.rbf = False + outputsChanged = pyqtSignal() @pyqtProperty('QVariantList', notify=outputsChanged) def outputs(self):