forked from bitcoinafterlife/bal-electrum-plugin
fixed refresh and some minor bug about dust amounts and empty wallet
This commit is contained in:
61
qt.py
61
qt.py
@@ -500,6 +500,7 @@ class BalWindow(Logger):
|
||||
self.logger.debug("not_will_settings {}".format(self.will_settings))
|
||||
self.bal_plugin.validate_will_settings(self.will_settings)
|
||||
self.heir_list.update_will_settings()
|
||||
self.heir_list.update()
|
||||
|
||||
def init_wizard(self):
|
||||
wizard_dialog = BalWizardDialog(self)
|
||||
@@ -710,6 +711,7 @@ class BalWindow(Logger):
|
||||
self.logger.info(f"will-settings: {self.will_settings}")
|
||||
self.logger.info(f"date_to_check:{self.date_to_check}")
|
||||
self.logger.info(f"heirs: {self.heirs}")
|
||||
return {}
|
||||
except Exception as e:
|
||||
self.logger.info(f"Exception build_will: {e}")
|
||||
raise e
|
||||
@@ -2036,6 +2038,9 @@ class bal_checkbox(QCheckBox):
|
||||
|
||||
class BalBuildWillDialog(BalDialog):
|
||||
updatemessage = pyqtSignal()
|
||||
COLOR_WARNING='#cfa808'
|
||||
COLOR_ERROR='#ff0000'
|
||||
COLOR_OK='#05ad05'
|
||||
|
||||
def __init__(self, bal_window, parent=None):
|
||||
if not parent:
|
||||
@@ -2092,25 +2097,24 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.bal_window.window.wallet.dust_threshold(),
|
||||
)
|
||||
_logger.debug("variables ok")
|
||||
self.msg_set_status("checking variables:", varrow, "Ok")
|
||||
self.msg_set_status("checking variables:", varrow, "Ok",self.COLOR_OK)
|
||||
except AmountException:
|
||||
self.msg_set_status(
|
||||
"checking variables",
|
||||
varrow,
|
||||
'<font color="#ff0000">'
|
||||
+ _(
|
||||
_(
|
||||
"In the inheritance process, "
|
||||
+ "the entire wallet will always be fully emptied. \n"
|
||||
+ "Your settings require an adjustment of the amounts"
|
||||
)
|
||||
+ "</font>",
|
||||
),
|
||||
self.COLOR_WARNING
|
||||
)
|
||||
|
||||
self.msg_set_checking()
|
||||
have_to_build = False
|
||||
try:
|
||||
self.bal_window.check_will()
|
||||
self.msg_set_checking("Ok")
|
||||
self.msg_set_checking(self.msg_ok())
|
||||
except WillExpiredException:
|
||||
_logger.debug("expired")
|
||||
self.msg_set_checking("Expired")
|
||||
@@ -2144,11 +2148,23 @@ class BalBuildWillDialog(BalDialog):
|
||||
if have_to_build:
|
||||
self.msg_set_building()
|
||||
try:
|
||||
self.bal_window.build_will()
|
||||
if not self.bal_window.build_will():
|
||||
self.msg_set_status(
|
||||
_("Balance is too low. No transaction was built"),None,_("Skipped"),self.COLOR_ERROR
|
||||
)
|
||||
|
||||
self.bal_window.check_will()
|
||||
for wid in Will.only_valid(self.bal_window.willitems):
|
||||
self.bal_window.wallet.set_label(wid, "BAL Transaction")
|
||||
self.msg_set_building("Ok")
|
||||
self.msg_set_building(self.msg_ok())
|
||||
except WillExecutorNotPresent as e:
|
||||
self.msg_set_status(
|
||||
_("Will-Executor excluded"),
|
||||
None,
|
||||
_("Skipped"),
|
||||
self.COLOR_ERROR
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.msg_set_building(self.msg_error(e))
|
||||
return False, None
|
||||
@@ -2159,9 +2175,10 @@ class BalBuildWillDialog(BalDialog):
|
||||
for hid, heir in heirs.items():
|
||||
if "DUST" in str(heir[HEIR_REAL_AMOUNT]):
|
||||
self.msg_set_status(
|
||||
f'<font color="red">{hid},{heir[HEIR_DUST_AMOUNT]} is DUST',
|
||||
f'{hid},{heir[HEIR_DUST_AMOUNT]} is DUST',
|
||||
None,
|
||||
f"Excluded from will {wid}</font>",
|
||||
f"Excluded from will {wid}",
|
||||
self.COLOR_WARNING
|
||||
)
|
||||
|
||||
have_to_sign = False
|
||||
@@ -2197,7 +2214,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
txid = self.network.run_from_another_thread(
|
||||
self.network.broadcast_transaction(tx, timeout=120), timeout=120
|
||||
)
|
||||
self.msg_set_invalidating("Ok")
|
||||
self.msg_set_invalidating(self.msg_ok())
|
||||
if not txid:
|
||||
_logger.debug(f"should not be none txid: {txid}")
|
||||
|
||||
@@ -2354,7 +2371,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
for txid, tx in txs.items():
|
||||
self.bal_window.willitems[txid].tx = copy.deepcopy(tx)
|
||||
self.bal_window.save_willitems()
|
||||
self.msg_set_signing("Ok")
|
||||
self.msg_set_signing(self.msg_ok())
|
||||
except Exception as e:
|
||||
self.msg_set_signing(self.msg_error(e))
|
||||
|
||||
@@ -2369,11 +2386,11 @@ class BalBuildWillDialog(BalDialog):
|
||||
else:
|
||||
try:
|
||||
self.loop_push()
|
||||
self.msg_set_pushing("Ok")
|
||||
self.msg_set_pushing(self.msg_ok())
|
||||
|
||||
except Exception as e:
|
||||
self.msg_set_pushing(self.msg_error(e))
|
||||
self.msg_edit_row("Ok")
|
||||
self.msg_edit_row(self.msg_ok())
|
||||
self.wait(5)
|
||||
|
||||
def on_error_phase1(self, error):
|
||||
@@ -2413,13 +2430,20 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.wait_row = self.msg_edit_row(f"Please wait {status}secs", self.wait_row)
|
||||
|
||||
def msg_error(self, e):
|
||||
return "Error: {}".format(e)
|
||||
return "<font color='{}'>{}</font>".format(self.COLOR_ERROR,e)
|
||||
|
||||
def msg_set_status(self, msg, row=None, status=None):
|
||||
def msg_ok(self, e="Ok"):
|
||||
return "<font color='{}'>{}</font>".format(self.COLOR_OK,e)
|
||||
|
||||
def msg_warning(self, e):
|
||||
return "<font color='{}'>{}</font".format(self.COLOR_WARNING,e)
|
||||
|
||||
def msg_set_status(self, msg, row=None, status=None,color="#000000"):
|
||||
status = "Wait" if status is None else status
|
||||
line = "{}:\t{}".format(_(msg), status)
|
||||
line = "<font color={}>{}:\t{}</font>".format(color,_(msg), status)
|
||||
return self.msg_edit_row(line, row)
|
||||
|
||||
|
||||
def ask_password(self, msg=None):
|
||||
self.password = self.bal_window.get_wallet_password(msg, parent=self)
|
||||
|
||||
@@ -2616,7 +2640,6 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
||||
set_current = QPersistentModelIndex(idx)
|
||||
self.set_current_idx(set_current)
|
||||
# FIXME refresh loses sort order; so set "default" here:
|
||||
self.repaint()
|
||||
self.filter()
|
||||
run_hook("update_heirs_tab", self)
|
||||
self.update_will_settings()
|
||||
@@ -2949,7 +2972,7 @@ class PreviewList(MyTreeView):
|
||||
display = QPushButton(_("Display"))
|
||||
display.clicked.connect(self.bal_window.preview_modal_dialog)
|
||||
|
||||
display = QPushButton(_("refresh"))
|
||||
display = QPushButton(_("Refresh"))
|
||||
display.clicked.connect(self.check)
|
||||
|
||||
widget = QWidget()
|
||||
|
||||
Reference in New Issue
Block a user