Browse Source

qt tx dialog: only allow "save as local" for complete txns

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
8bd27851a4
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 17
      electrum/gui/qt/transaction_dialog.py
  2. 4
      electrum/wallet.py

17
electrum/gui/qt/transaction_dialog.py

@ -70,9 +70,6 @@ class QTextEditWithDefaultSize(QTextEdit):
return QSize(0, 100) 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__) _logger = get_logger(__name__)
dialogs = [] # Otherwise python randomly garbage collects the dialogs... dialogs = [] # Otherwise python randomly garbage collects the dialogs...
@ -142,12 +139,6 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
b.clicked.connect(self.do_broadcast) b.clicked.connect(self.do_broadcast)
self.save_button = b = QPushButton(_("Save")) 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) b.clicked.connect(self.save)
self.cancel_button = b = QPushButton(_("Close")) self.cancel_button = b = QPushButton(_("Close"))
@ -295,8 +286,6 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
if self.tx.is_complete(): if self.tx.is_complete():
self.prompt_if_unsaved = True self.prompt_if_unsaved = True
self.saved = False self.saved = False
self.save_button.setDisabled(False)
self.save_button.setToolTip(SAVE_BUTTON_ENABLED_TOOLTIP)
self.update() self.update()
self.main_window.pop_top_level_window(self) self.main_window.pop_top_level_window(self)
@ -449,6 +438,12 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
else: else:
widget.setVisible(show_psbt_only_widgets) 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) run_hook('transaction_dialog_update', self)
def update_io(self): def update_io(self):

4
electrum/wallet.py

@ -202,6 +202,7 @@ class TxWalletDetails(NamedTuple):
label: str label: str
can_broadcast: bool can_broadcast: bool
can_bump: bool can_bump: bool
can_save_as_local: bool
amount: Optional[int] amount: Optional[int]
fee: Optional[int] fee: Optional[int]
tx_mined_status: TxMinedInfo tx_mined_status: TxMinedInfo
@ -464,6 +465,7 @@ class Abstract_Wallet(AddressSynchronizer):
exp_n = None exp_n = None
can_broadcast = False can_broadcast = False
can_bump = False can_bump = False
can_save_as_local = False
label = '' label = ''
tx_hash = tx.txid() tx_hash = tx.txid()
tx_mined_status = self.get_tx_height(tx_hash) tx_mined_status = self.get_tx_height(tx_hash)
@ -491,6 +493,7 @@ class Abstract_Wallet(AddressSynchronizer):
else: else:
status = _("Signed") status = _("Signed")
can_broadcast = self.network is not None can_broadcast = self.network is not None
can_save_as_local = is_relevant
else: else:
s, r = tx.signature_count() s, r = tx.signature_count()
status = _("Unsigned") if s == 0 else _('Partially signed') + ' (%d/%d)'%(s,r) status = _("Unsigned") if s == 0 else _('Partially signed') + ' (%d/%d)'%(s,r)
@ -512,6 +515,7 @@ class Abstract_Wallet(AddressSynchronizer):
label=label, label=label,
can_broadcast=can_broadcast, can_broadcast=can_broadcast,
can_bump=can_bump, can_bump=can_bump,
can_save_as_local=can_save_as_local,
amount=amount, amount=amount,
fee=fee, fee=fee,
tx_mined_status=tx_mined_status, tx_mined_status=tx_mined_status,

Loading…
Cancel
Save