3 Commits

Author SHA1 Message Date
6f44a3bb54 checkalive sulla finestra will 2026-04-10 16:34:27 -04:00
8f966a974a checkalive sulla finestra will 2026-04-10 16:08:33 -04:00
a59b5c47b6 checkalive sulla finestra will 2026-04-10 16:02:40 -04:00
3 changed files with 107 additions and 56 deletions

2
bal.py
View File

@@ -149,6 +149,8 @@ class BalPlugin(BasePlugin):
self.HIDE_REPLACED.set(self._hide_replaced) self.HIDE_REPLACED.set(self._hide_replaced)
def validate_will_settings(self, will_settings): def validate_will_settings(self, will_settings):
if not will_settings:
will_settings=[]
if int(will_settings.get("baltx_fees", 1)) < 1: if int(will_settings.get("baltx_fees", 1)) < 1:
will_settings["baltx_fees"] = 1 will_settings["baltx_fees"] = 1
if not will_settings.get("threshold"): if not will_settings.get("threshold"):

151
qt.py
View File

@@ -404,9 +404,13 @@ class BalWindow(Logger):
self.bal_plugin.get_decimal_point = self.window.get_decimal_point self.bal_plugin.get_decimal_point = self.window.get_decimal_point
if self.window.wallet: if self.window.wallet:
self.wallet = self.window.wallet
if not self.will_settings:
self.will_settings = self.bal_plugin.WILL_SETTINGS.get()
Util.fix_will_settings_tx_fees(self.will_settings)
self.heirs_tab = self.create_heirs_tab() self.heirs_tab = self.create_heirs_tab()
self.will_tab = self.create_will_tab() self.will_tab = self.create_will_tab()
self.wallet = self.window.wallet
self.heirs_tab.wallet = self.wallet self.heirs_tab.wallet = self.wallet
self.will_tab.wallet = self.wallet self.will_tab.wallet = self.wallet
@@ -488,17 +492,17 @@ class BalWindow(Logger):
self.close_wallet() self.close_wallet()
return return
if not self.will_settings: #if not self.will_settings:
self.will_settings = self.wallet.db.get_dict("will_settings") # self.will_settings = self.wallet.db.get_dict("will_settings")
Util.fix_will_settings_tx_fees(self.will_settings) # Util.fix_will_settings_tx_fees(self.will_settings)
self.logger.info("will_settings: {}".format(self.will_settings)) # self.logger.info("will_settings: {}".format(self.will_settings))
if not self.will_settings: # if not self.will_settings:
Util.copy(self.will_settings, self.bal_plugin.default_will_settings()) # Util.copy(self.will_settings, self.bal_plugin.default_will_settings())
self.logger.debug("not_will_settings {}".format(self.will_settings)) # self.logger.debug("not_will_settings {}".format(self.will_settings))
self.bal_plugin.validate_will_settings(self.will_settings) # self.bal_plugin.validate_will_settings(self.will_settings)
self.heir_list_widget.update_will_settings() # self.heir_list_widget.update_will_settings()
self.heir_list_widget.update() # self.heir_list_widget.update()
def init_wizard(self): def init_wizard(self):
wizard_dialog = BalWizardDialog(self) wizard_dialog = BalWizardDialog(self)
@@ -732,6 +736,35 @@ class BalWindow(Logger):
def show_critical(self, text): def show_critical(self, text):
self.window.show_critical(text) self.window.show_critical(text)
def update_locktime_widgets(self,locktime):
locktime = self.will_settings["locktime"] = (
locktime
if locktime
else "1y"
)
self.bal_plugin.WILL_SETTINGS.set(self.will_settings)
try:
self.heir_list_widget.heir_locktime.set_locktime(locktime)
except Exception as e:
pass
#self.preview_list.heirs_locktime.set_locktim(will_settings['thershold'])
def update_threshold_widgets(self,threshold):
threshold = self.will_settings["threshold"] = (
threshold
if threshold
else "1y"
)
self.bal_plugin.WILL_SETTINGS.set(self.will_settings)
try:
self.heir_list_widget.heir_threshold.set_locktime(threshold)
except Exception as e:
pass
try:
self.will_list.heir_threshold.set_locktime(threshold)
except Exception as e:
pass
def init_heirs_to_locktime(self, multiverse=False): def init_heirs_to_locktime(self, multiverse=False):
for heir in self.heirs: for heir in self.heirs:
h = self.heirs[heir] h = self.heirs[heir]
@@ -1318,8 +1351,8 @@ class HeirsLockTimeEdit(QWidget, _LockTimeEditor):
w.setEnabled(False) w.setEnabled(False)
prev_locktime = self.editor.get_locktime() prev_locktime = self.editor.get_locktime()
self.editor = self.option_index_to_editor_map[i] self.editor = self.option_index_to_editor_map[i]
if self.editor.is_acceptable_locktime(prev_locktime): #if self.editor.is_acceptable_locktime(prev_locktime):
self.editor.set_locktime(prev_locktime, force=True) # self.editor.set_locktime(prev_locktime, force=False)
self.editor.setVisible(True) self.editor.setVisible(True)
self.editor.setEnabled(True) self.editor.setEnabled(True)
@@ -1330,14 +1363,16 @@ class HeirsLockTimeEdit(QWidget, _LockTimeEditor):
self.combo.setCurrentIndex(index) self.combo.setCurrentIndex(index)
self.on_current_index_changed(index) self.on_current_index_changed(index)
def set_locktime(self, x: Any, force=True) -> None: def set_locktime(self, x: Any, force=None) -> None:
if force is None:
force=True
try: try:
int(x) int(x)
self.set_index(1) self.set_index(1)
except: except:
if isinstance(x,str): if isinstance(x,str):
self.set_index(0) self.set_index(0)
self.editor.set_locktime(x, force) self.editor.set_locktime(x, force=False)
class LockTimeRawEdit(QLineEdit, _LockTimeEditor): class LockTimeRawEdit(QLineEdit, _LockTimeEditor):
@@ -1865,19 +1900,14 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
def get_content(self): def get_content(self):
widget = QWidget() widget = QWidget()
self.heir_locktime = HeirsLockTimeEdit(widget, 0) self.heir_locktime = HeirsLockTimeEdit(widget, 0)
will_settings = self.bal_window.bal_plugin.WILL_SETTINGS.get() #will_settings = self.bal_window.bal_plugin.WILL_SETTINGS.get()
will_settings = self.bal_window.will_settings will_settings = self.bal_window.will_settings
self.heir_locktime.set_locktime(will_settings["locktime"]) self.heir_locktime.set_locktime(will_settings["locktime"])
def on_heir_locktime(): def on_heir_locktime():
if not self.heir_locktime.get_locktime(): if not self.heir_locktime.get_locktime():
self.heir_locktime.set_locktime("1y") self.heir_locktime.set_locktime("1y")
self.bal_window.will_settings["locktime"] = ( self.bal_window.update_locktime_widgets(self.heir_locktime.get_locktime())
self.heir_locktime.get_locktime()
if self.heir_locktime.get_locktime()
else "1y"
)
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
self.heir_locktime.valueEdited.connect(on_heir_locktime) self.heir_locktime.valueEdited.connect(on_heir_locktime)
@@ -1887,11 +1917,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
def on_heir_threshold(): def on_heir_threshold():
if not self.heir_threshold.get_locktime(): if not self.heir_threshold.get_locktime():
self.heir_threshold.set_locktime("180d") self.heir_threshold.set_locktime("180d")
self.bal_window.update_threshold_widgets(self.heir_threshold.get_locktime())
self.bal_window.will_settings["threshold"] = (
self.heir_threshold.get_locktime()
)
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
self.heir_threshold.valueEdited.connect(on_heir_threshold) self.heir_threshold.valueEdited.connect(on_heir_threshold)
@@ -2021,7 +2047,6 @@ class BalWaitingDialog(BalDialog):
self.thread.stop() self.thread.stop()
def update_message(self, msg): def update_message(self, msg):
print(msg)
self.message_label.setText(msg) self.message_label.setText(msg)
def update(self, msg): def update(self, msg):
@@ -2150,15 +2175,12 @@ class BalBuildWillDialog(BalDialog):
_logger.debug("variables ok") _logger.debug("variables ok")
self.msg_set_status("checking variables:", varrow, "Ok", self.COLOR_OK) self.msg_set_status("checking variables:", varrow, "Ok", self.COLOR_OK)
except AmountException: except AmountException:
self.msg_set_status( self.msg_set_checking(
"checking variables", self.msg_warning(
varrow,
_(
"In the inheritance process, " "In the inheritance process, "
+ "the entire wallet will always be fully emptied. \n" + "the entire wallet will always be fully emptied. \n"
+ "Your settings require an adjustment of the amounts" + "Your settings require an adjustment of the amounts"
), )
self.COLOR_WARNING,
) )
self.msg_set_checking() self.msg_set_checking()
@@ -2749,32 +2771,28 @@ class HeirListWidget(MyTreeView, MessageBoxMixin):
menu.addAction(_("Import"), self.bal_window.import_heirs) menu.addAction(_("Import"), self.bal_window.import_heirs)
menu.addAction(_("Export"), lambda: self.bal_window.export_heirs()) menu.addAction(_("Export"), lambda: self.bal_window.export_heirs())
self.heir_locktime = HeirsLockTimeEdit(self, 0) threshold = self.bal_window.will_settings.get('threshold',None) if self.bal_window.will_settings else self.bal_window.window.wallet.db.get_dict("will_settings")['threshold']
locktime = self.bal_window.will_settings.get('locktime',None) if self.bal_window.will_settings else self.bal_window.window.wallet.db.get_dict("will_settings")['locktime']
self.heir_locktime = HeirsLockTimeEdit(self, 0)
def on_heir_locktime(): def on_heir_locktime():
if not self.heir_locktime.get_locktime(): if not self.heir_locktime.get_locktime():
self.heir_locktime.set_locktime("1y") self.heir_locktime.set_locktime("1y")
self.bal_window.will_settings["locktime"] = ( self.bal_window.update_locktime_widgets(self.heir_locktime.get_locktime())
self.heir_locktime.get_locktime()
if self.heir_locktime.get_locktime()
else "1y"
)
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
self.heir_locktime.valueEdited.connect(on_heir_locktime) self.heir_locktime.valueEdited.connect(on_heir_locktime)
self.heir_locktime.set_locktime(locktime)
self.heir_threshold = HeirsLockTimeEdit(self, 0) self.heir_threshold = HeirsLockTimeEdit(self, 0)
def on_heir_threshold(): def on_heir_threshold():
if not self.heir_threshold.get_locktime(): if not self.heir_threshold.get_locktime():
self.heir_threshold.set_locktime("180d") self.heir_threshold.set_locktime("180d")
self.bal_window.update_threshold_widgets(self.heir_threshold.get_locktime())
self.bal_window.will_settings["threshold"] = (
self.heir_threshold.get_locktime()
)
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
self.heir_threshold.valueEdited.connect(on_heir_threshold) self.heir_threshold.valueEdited.connect(on_heir_threshold)
self.heir_threshold.set_locktime(threshold)
self.heir_tx_fees = QSpinBox() self.heir_tx_fees = QSpinBox()
self.heir_tx_fees.setMinimum(1) self.heir_tx_fees.setMinimum(1)
@@ -3059,6 +3077,21 @@ class PreviewList(MyTreeView):
menu.addAction(_("Check"), self.check) menu.addAction(_("Check"), self.check)
menu.addAction(_("Invalidate"), self.invalidate_will) menu.addAction(_("Invalidate"), self.invalidate_will)
def make_hlayout(label, twidget, help_text):
tw = QWidget()
hlayout = QHBoxLayout(tw)
hlayout.addWidget(QLabel(label))
hlayout.addWidget(twidget)
hlayout.addWidget(HelpButton(help_text))
hlayout.addStretch(1)
spacer_widget = QWidget()
spacer_widget.setSizePolicy(
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding
)
hlayout.addWidget(spacer_widget)
return tw
wizard = QPushButton(_("Setup Wizard")) wizard = QPushButton(_("Setup Wizard"))
wizard.clicked.connect(self.bal_window.init_wizard) wizard.clicked.connect(self.bal_window.init_wizard)
#display = QPushButton(_("Display")) #display = QPushButton(_("Display"))
@@ -3069,6 +3102,32 @@ class PreviewList(MyTreeView):
widget = QWidget() widget = QWidget()
hlayout = QHBoxLayout(widget) hlayout = QHBoxLayout(widget)
hlayout.addWidget(QLabel(_("Check Alive:")))
threshold = self.bal_window.will_settings.get('threshold',None) if self.bal_window.will_settings else self.bal_window.window.wallet.db.get_dict("will_settings")['threshold']
self.heir_threshold = HeirsLockTimeEdit(widget, 0)
self.heir_threshold.set_locktime(threshold)
def on_heir_threshold():
if not self.heir_threshold.get_locktime():
self.heir_threshold.set_locktime("180d")
self.bal_window.update_threshold_widgets(self.heir_threshold.get_locktime())
self.heir_threshold.valueEdited.connect(on_heir_threshold)
hlayout.addWidget(self.heir_threshold)
hlayout.addWidget(
HelpButton(
_(
"Check to ask for invalidation.\n"
+ "When less then this time is missing, ask to invalidate.\n"
+ "If you fail to invalidate during this time, your transactions will be delivered to your heirs.\n"
+ "if you choose Raw, you can insert various options based on suffix:\n"
+ " - d: number of days after current day(ex: 1d means tomorrow).\n"
+ " - y: number of years after currrent day(ex: 1y means one year from today).\n\n"
)
)
)
hlayout.addWidget(wizard) hlayout.addWidget(wizard)
hlayout.addWidget(refresh) hlayout.addWidget(refresh)
toolbar.insertWidget(2, widget) toolbar.insertWidget(2, widget)

10
will.py
View File

@@ -148,16 +148,6 @@ class Will:
inp._TxInput__value_sats = change.value inp._TxInput__value_sats = change.value
return inp return inp
"""
in questa situazione sono presenti due transazioni con id differente(quindi transazioni differenti)
per prima cosa controllo il locktime
se il locktime della nuova transazione e' maggiore del locktime della vecchia transazione, allora
confronto gli eredi, per locktime se corrispondono controllo i willexecutor
se hanno la stessa url ma le fee vecchie sono superiori alle fee nuove, allora anticipare.
"""
def check_anticipate(ow: "WillItem", nw: "WillItem"): def check_anticipate(ow: "WillItem", nw: "WillItem"):
anticipate = Util.anticipate_locktime(ow.tx.locktime, days=1) anticipate = Util.anticipate_locktime(ow.tx.locktime, days=1)
if int(nw.tx.locktime) >= int(anticipate): if int(nw.tx.locktime) >= int(anticipate):