mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
qt tx dialog: only allow "save as local" for complete txns
This commit is contained in:
parent
aa3d817ef2
commit
8bd27851a4
2 changed files with 10 additions and 11 deletions
|
@ -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):
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue