From d86b941fcba3c91625f1723e874011ce989d2b91 Mon Sep 17 00:00:00 2001 From: svatantrya Date: Thu, 5 Feb 2026 17:11:11 -0400 Subject: [PATCH] refresh button. locktim is correctly saved, minor bugfix in checking confirmed transaction --- bal.py | 10 +--------- qt.py | 52 +++++++++++++++++++++++++++++++++------------------- will.py | 31 +++++++++++++++++++------------ 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/bal.py b/bal.py index 0e04e6b..d18a4df 100644 --- a/bal.py +++ b/bal.py @@ -68,15 +68,9 @@ class BalPlugin(BasePlugin): self.base_dir = os.path.join(config.electrum_path(), "bal") self.plugin_dir = os.path.split(os.path.realpath(__file__))[0] zipfile = "/".join(self.plugin_dir.split("/")[:-1]) - # print("real path",os.path.realpath(__file__)) - # self.logger.info(self.base_dir) - # print("base_dir:", self.base_dir) - # print("suca:",zipfile) - # print("plugin_dir:", self.plugin_dir) import sys sys.path.insert(0, zipfile) - # print("sono state listate?") self.parent = parent self.config = config self.name = name @@ -145,13 +139,11 @@ class BalPlugin(BasePlugin): self.HIDE_REPLACED.set(self._hide_replaced) def validate_will_settings(self, will_settings): - # print(type(will_settings)) - # print(will_settings.get('baltx_fees',1),1) if int(will_settings.get("baltx_fees", 1)) < 1: will_settings["baltx_fees"] = 1 if not will_settings.get("threshold"): will_settings["threshold"] = "180d" - if not will_settings.get("locktime") == "": + if not will_settings.get("locktime"): will_settings["locktime"] = "1y" return will_settings diff --git a/qt.py b/qt.py index 3e5ad61..f4169f5 100644 --- a/qt.py +++ b/qt.py @@ -401,13 +401,13 @@ class BalWindow(Logger): self.willitems = {} self.willexecutors = {} self.will_settings = None - self.heirs_tab = self.create_heirs_tab() - self.will_tab = self.create_will_tab() self.ok = False self.disable_plugin = True self.bal_plugin.get_decimal_point = self.window.get_decimal_point if self.window.wallet: + self.heirs_tab = self.create_heirs_tab() + self.will_tab = self.create_will_tab() self.wallet = self.window.wallet self.heirs_tab.wallet = self.wallet self.will_tab.wallet = self.wallet @@ -498,7 +498,6 @@ class BalWindow(Logger): if not self.will_settings: Util.copy(self.will_settings, self.bal_plugin.default_will_settings()) 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() @@ -706,6 +705,7 @@ class BalWindow(Logger): return self.willitems def check_will(self): + print("check_will") return Will.is_will_valid( self.willitems, self.block_to_check, @@ -1819,6 +1819,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget): widget = QWidget() self.heir_locktime = HeirsLockTimeEdit(widget, 0) will_settings = self.bal_window.bal_plugin.WILL_SETTINGS.get() + will_settings = self.bal_window.will_settings self.heir_locktime.set_locktime(will_settings["locktime"]) def on_heir_locktime(): @@ -1828,6 +1829,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget): 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) @@ -1845,6 +1847,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget): ) self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings) + self.heir_threshold.valueEdited.connect(on_heir_threshold) self.heir_tx_fees = QSpinBox(widget) @@ -2571,9 +2574,9 @@ class HeirList(MyTreeView, MessageBoxMixin): items[self.Columns.NAME].setEditable(True) items[self.Columns.ADDRESS].setEditable(True) items[self.Columns.AMOUNT].setEditable(True) - items[self.Columns.NAME].setData(key, self.ROLE_HEIR_KEY + 1) - items[self.Columns.ADDRESS].setData(key, self.ROLE_HEIR_KEY + 2) - items[self.Columns.AMOUNT].setData(key, self.ROLE_HEIR_KEY + 3) + items[self.Columns.NAME].setData(key, self.ROLE_HEIR_KEY + self.Columns.NAME) + items[self.Columns.ADDRESS].setData(key, self.ROLE_HEIR_KEY + self.Columns.ADDRESS) + items[self.Columns.AMOUNT].setData(key, self.ROLE_HEIR_KEY + self.Columns.AMOUNT) row_count = self.model().rowCount() self.model().insertRow(row_count, items) @@ -2593,7 +2596,7 @@ class HeirList(MyTreeView, MessageBoxMixin): def get_edit_key_from_coordinate(self, row, col): a= self.get_role_data_from_coordinate( - row, col, role=self.ROLE_HEIR_KEY + col + 1 + row, col, role=self.ROLE_HEIR_KEY + col ) return a def create_toolbar(self, config): @@ -2603,7 +2606,6 @@ class HeirList(MyTreeView, MessageBoxMixin): menu.addAction(_("Export"), lambda: self.bal_window.export_heirs()) self.heir_locktime = HeirsLockTimeEdit(self, 0) - def on_heir_locktime(): if not self.heir_locktime.get_locktime(): self.heir_locktime.set_locktime("1y") @@ -2691,8 +2693,9 @@ class HeirList(MyTreeView, MessageBoxMixin): def update_will_settings(self): try: self.heir_locktime.set_locktime(self.bal_window.will_settings["locktime"]) - self.heir_tx_fees.setValue(int(self.bal_window.will_settings["baltx_fees"])) self.heir_threshold.set_locktime(self.bal_window.will_settings["threshold"]) + self.heir_tx_fees.setValue(int(self.bal_window.will_settings["baltx_fees"])) + except Exception as e: _logger.debug(f"Exception update_will_settings {e}") @@ -2737,6 +2740,7 @@ class PreviewList(MyTreeView): self.wallet = bal_window.window.wallet self.setModel(QStandardItemModel(self)) + self.sortByColumn(self.Columns.LOCKTIME, Qt.SortOrder.AscendingOrder) self.setSortingEnabled(True) self.std_model = self.model() self.config = bal_window.bal_plugin.config @@ -2895,6 +2899,8 @@ class PreviewList(MyTreeView): tmp = self.replace(set_current, current_key, txid, bal_tx) if tmp: set_current = tmp + self.sortByColumn(self.Columns.LOCKTIME, Qt.SortOrder.AscendingOrder) + self.setSortingEnabled(True) def create_toolbar(self, config): toolbar, menu = self.create_toolbar_with_menu("") @@ -2913,6 +2919,9 @@ class PreviewList(MyTreeView): display = QPushButton(_("Display")) display.clicked.connect(self.bal_window.preview_modal_dialog) + display = QPushButton(_("refresh")) + display.clicked.connect(self.check) + widget = QWidget() hlayout = QHBoxLayout(widget) hlayout.addWidget(wizard) @@ -2954,11 +2963,20 @@ class PreviewList(MyTreeView): self.update() def check(self): + Will.add_willtree(self.bal_window.willitems) + all_utxos =self.bal_window.wallet.get_utxos() + utxos_list = Will.utxos_strs(all_utxos) + Will.check_invalidated(self.bal_window.willitems,utxos_list,self.bal_window.wallet) + + close_window = BalBuildWillDialog(self.bal_window) + close_window.build_will_task() + will = {} for wid, w in self.bal_window.willitems.items(): - if w.get_status("VALID"): + if w.get_status("VALID") and w.get_status("PUSHED") and not w.get_status("CHECKED"): will[wid] = w - self.bal_window.check_transactions(will) + if will: + self.bal_window.check_transactions(will) self.update() def invalidate_will(self): @@ -2991,6 +3009,10 @@ class PreviewDialog(BalDialog, MessageBoxMixin): self.setMinimumSize(1000, 200) self.size_label = QLabel() self.transactions_list = PreviewList(self.bal_window, self.will) + + self.bal_window.init_class_variables() + self.check_will() + vbox = QVBoxLayout(self) vbox.addWidget(self.size_label) vbox.addWidget(self.transactions_list) @@ -3041,14 +3063,6 @@ class PreviewDialog(BalDialog, MessageBoxMixin): event.accept() -def read_bal_QIcon(icon_basename: str = DEFAULT_ICON) -> QIcon: - return QIcon(icon_path(icon_basename)) - - -def read_bal_QPixmap(icon_basename: str = DEFAULT_ICON) -> QPixmap: - return QPixmap(icon_path(icon_basename)) - - class WillDetailDialog(BalDialog): def __init__(self, bal_window): diff --git a/will.py b/will.py index 7011dc9..514fc4c 100644 --- a/will.py +++ b/will.py @@ -394,8 +394,10 @@ class Will: else: if wallet.db.get_transaction(wi._id): + print("search rai status confirmed") wi.set_status("CONFIRMED", True) else: + print("search rai status invalidated") wi.set_status("INVALIDATED", True) for child in wi.search(all_inputs): @@ -420,19 +422,24 @@ class Will: # check if transactions are stil valid tecnically valid def check_invalidated(willtree, utxos_list, wallet): + print("utxo list",utxos_list) for wid, w in willtree.items(): - if not w.father: - for inp in w.tx.inputs(): - inp_str = Util.utxo_to_str(inp) - if not inp_str in utxos_list: - if wallet: - height = Will.check_tx_height(w.tx, wallet) - if height < 0: - Will.set_invalidate(wid, willtree) - elif height == 0: - w.set_status("PENDING", True) - else: - w.set_status("CONFIRMED", True) + print("check transaction",w._id) + #if not w.father: + for inp in w.tx.inputs(): + inp_str = Util.utxo_to_str(inp) + if not inp_str in utxos_list: + if wallet: + height = Will.check_tx_height(w.tx, wallet) + if height < 0: + Will.set_invalidate(wid, willtree) + elif height == 0: + w.set_status("PENDING", True) + else: + print("check_invalidate status confirmed",w._id) + w.set_status("CONFIRMED", True) + #else: + # print("father",w.father) def reflect_to_children(treeitem): if not treeitem.get_status("VALID"):