commit 8bd27851a47707e2c4a039c7675f01e66fbfb939
parent aa3d817ef20f630333d06678c434564baf20b7a3
Author: SomberNight <somber.night@protonmail.com>
Date: Tue, 19 Nov 2019 18:41:44 +0100
qt tx dialog: only allow "save as local" for complete txns
Diffstat:
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py
@@ -70,9 +70,6 @@ class QTextEditWithDefaultSize(QTextEdit):
return QSize(0, 100)
-SAVE_BUTTON_ENABLED_TOOLTIP = _("Save transaction offline")
-SAVE_BUTTON_DISABLED_TOOLTIP = _("Please sign this transaction in order to save it")
-
_logger = get_logger(__name__)
dialogs = [] # Otherwise python randomly garbage collects the dialogs...
@@ -142,12 +139,6 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
b.clicked.connect(self.do_broadcast)
self.save_button = b = QPushButton(_("Save"))
- save_button_disabled = False #not tx.is_complete()
- b.setDisabled(save_button_disabled)
- if save_button_disabled:
- b.setToolTip(SAVE_BUTTON_DISABLED_TOOLTIP)
- else:
- b.setToolTip(SAVE_BUTTON_ENABLED_TOOLTIP)
b.clicked.connect(self.save)
self.cancel_button = b = QPushButton(_("Close"))
@@ -295,8 +286,6 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
if self.tx.is_complete():
self.prompt_if_unsaved = True
self.saved = False
- self.save_button.setDisabled(False)
- self.save_button.setToolTip(SAVE_BUTTON_ENABLED_TOOLTIP)
self.update()
self.main_window.pop_top_level_window(self)
@@ -449,6 +438,12 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
else:
widget.setVisible(show_psbt_only_widgets)
+ self.save_button.setEnabled(tx_details.can_save_as_local)
+ if tx_details.can_save_as_local:
+ self.save_button.setToolTip(_("Save transaction offline"))
+ else:
+ self.save_button.setToolTip(_("Transaction already saved or not yet signed."))
+
run_hook('transaction_dialog_update', self)
def update_io(self):
diff --git a/electrum/wallet.py b/electrum/wallet.py
@@ -202,6 +202,7 @@ class TxWalletDetails(NamedTuple):
label: str
can_broadcast: bool
can_bump: bool
+ can_save_as_local: bool
amount: Optional[int]
fee: Optional[int]
tx_mined_status: TxMinedInfo
@@ -464,6 +465,7 @@ class Abstract_Wallet(AddressSynchronizer):
exp_n = None
can_broadcast = False
can_bump = False
+ can_save_as_local = False
label = ''
tx_hash = tx.txid()
tx_mined_status = self.get_tx_height(tx_hash)
@@ -491,6 +493,7 @@ class Abstract_Wallet(AddressSynchronizer):
else:
status = _("Signed")
can_broadcast = self.network is not None
+ can_save_as_local = is_relevant
else:
s, r = tx.signature_count()
status = _("Unsigned") if s == 0 else _('Partially signed') + ' (%d/%d)'%(s,r)
@@ -512,6 +515,7 @@ class Abstract_Wallet(AddressSynchronizer):
label=label,
can_broadcast=can_broadcast,
can_bump=can_bump,
+ can_save_as_local=can_save_as_local,
amount=amount,
fee=fee,
tx_mined_status=tx_mined_status,