forked from bitcoinafterlife/bal-electrum-plugin
checkalive sulla finestra will
This commit is contained in:
2
bal.py
2
bal.py
@@ -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"):
|
||||||
|
|||||||
122
qt.py
122
qt.py
@@ -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.wallet.db.get_dict("will_settings")
|
||||||
|
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
|
||||||
|
|
||||||
@@ -732,6 +736,38 @@ 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:
|
||||||
|
print("error heir locktime",e)
|
||||||
|
pass
|
||||||
|
#self.preview_list.heirs_locktime.set_locktim(will_settings['thershold'])
|
||||||
|
|
||||||
|
def update_threshold_widgets(self,threshold):
|
||||||
|
threshold = self.will_settings["thershold"] = (
|
||||||
|
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:
|
||||||
|
print("error heir threshold",e)
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
self.will_list.heir_threshold.set_locktime(threshold)
|
||||||
|
except Exception as e:
|
||||||
|
print("error will threshold",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]
|
||||||
@@ -1872,12 +1908,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
|
|||||||
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 +1918,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)
|
||||||
|
|
||||||
@@ -2150,15 +2177,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 +2773,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 +3079,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 +3104,33 @@ 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")
|
||||||
|
print("no threshold")
|
||||||
|
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
10
will.py
@@ -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):
|
||||||
|
|||||||
Reference in New Issue
Block a user