refresh button. locktim is correctly saved, minor bugfix in checking confirmed transaction
This commit is contained in:
10
bal.py
10
bal.py
@@ -68,15 +68,9 @@ class BalPlugin(BasePlugin):
|
|||||||
self.base_dir = os.path.join(config.electrum_path(), "bal")
|
self.base_dir = os.path.join(config.electrum_path(), "bal")
|
||||||
self.plugin_dir = os.path.split(os.path.realpath(__file__))[0]
|
self.plugin_dir = os.path.split(os.path.realpath(__file__))[0]
|
||||||
zipfile = "/".join(self.plugin_dir.split("/")[:-1])
|
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
|
import sys
|
||||||
|
|
||||||
sys.path.insert(0, zipfile)
|
sys.path.insert(0, zipfile)
|
||||||
# print("sono state listate?")
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.config = config
|
self.config = config
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -145,13 +139,11 @@ 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):
|
||||||
# print(type(will_settings))
|
|
||||||
# print(will_settings.get('baltx_fees',1),1)
|
|
||||||
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"):
|
||||||
will_settings["threshold"] = "180d"
|
will_settings["threshold"] = "180d"
|
||||||
if not will_settings.get("locktime") == "":
|
if not will_settings.get("locktime"):
|
||||||
will_settings["locktime"] = "1y"
|
will_settings["locktime"] = "1y"
|
||||||
return will_settings
|
return will_settings
|
||||||
|
|
||||||
|
|||||||
50
qt.py
50
qt.py
@@ -401,13 +401,13 @@ class BalWindow(Logger):
|
|||||||
self.willitems = {}
|
self.willitems = {}
|
||||||
self.willexecutors = {}
|
self.willexecutors = {}
|
||||||
self.will_settings = None
|
self.will_settings = None
|
||||||
self.heirs_tab = self.create_heirs_tab()
|
|
||||||
self.will_tab = self.create_will_tab()
|
|
||||||
self.ok = False
|
self.ok = False
|
||||||
self.disable_plugin = True
|
self.disable_plugin = True
|
||||||
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.heirs_tab = self.create_heirs_tab()
|
||||||
|
self.will_tab = self.create_will_tab()
|
||||||
self.wallet = self.window.wallet
|
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
|
||||||
@@ -498,7 +498,6 @@ class BalWindow(Logger):
|
|||||||
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.update_will_settings()
|
self.heir_list.update_will_settings()
|
||||||
|
|
||||||
@@ -706,6 +705,7 @@ class BalWindow(Logger):
|
|||||||
return self.willitems
|
return self.willitems
|
||||||
|
|
||||||
def check_will(self):
|
def check_will(self):
|
||||||
|
print("check_will")
|
||||||
return Will.is_will_valid(
|
return Will.is_will_valid(
|
||||||
self.willitems,
|
self.willitems,
|
||||||
self.block_to_check,
|
self.block_to_check,
|
||||||
@@ -1819,6 +1819,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
|
|||||||
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
|
||||||
self.heir_locktime.set_locktime(will_settings["locktime"])
|
self.heir_locktime.set_locktime(will_settings["locktime"])
|
||||||
|
|
||||||
def on_heir_locktime():
|
def on_heir_locktime():
|
||||||
@@ -1828,6 +1829,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
|
|||||||
self.heir_locktime.get_locktime()
|
self.heir_locktime.get_locktime()
|
||||||
if self.heir_locktime.get_locktime()
|
if self.heir_locktime.get_locktime()
|
||||||
else "1y"
|
else "1y"
|
||||||
|
|
||||||
)
|
)
|
||||||
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
|
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.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_tx_fees = QSpinBox(widget)
|
self.heir_tx_fees = QSpinBox(widget)
|
||||||
@@ -2571,9 +2574,9 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
items[self.Columns.NAME].setEditable(True)
|
items[self.Columns.NAME].setEditable(True)
|
||||||
items[self.Columns.ADDRESS].setEditable(True)
|
items[self.Columns.ADDRESS].setEditable(True)
|
||||||
items[self.Columns.AMOUNT].setEditable(True)
|
items[self.Columns.AMOUNT].setEditable(True)
|
||||||
items[self.Columns.NAME].setData(key, self.ROLE_HEIR_KEY + 1)
|
items[self.Columns.NAME].setData(key, self.ROLE_HEIR_KEY + self.Columns.NAME)
|
||||||
items[self.Columns.ADDRESS].setData(key, self.ROLE_HEIR_KEY + 2)
|
items[self.Columns.ADDRESS].setData(key, self.ROLE_HEIR_KEY + self.Columns.ADDRESS)
|
||||||
items[self.Columns.AMOUNT].setData(key, self.ROLE_HEIR_KEY + 3)
|
items[self.Columns.AMOUNT].setData(key, self.ROLE_HEIR_KEY + self.Columns.AMOUNT)
|
||||||
|
|
||||||
row_count = self.model().rowCount()
|
row_count = self.model().rowCount()
|
||||||
self.model().insertRow(row_count, items)
|
self.model().insertRow(row_count, items)
|
||||||
@@ -2593,7 +2596,7 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
|
|
||||||
def get_edit_key_from_coordinate(self, row, col):
|
def get_edit_key_from_coordinate(self, row, col):
|
||||||
a= self.get_role_data_from_coordinate(
|
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
|
return a
|
||||||
def create_toolbar(self, config):
|
def create_toolbar(self, config):
|
||||||
@@ -2603,7 +2606,6 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
menu.addAction(_("Export"), lambda: self.bal_window.export_heirs())
|
menu.addAction(_("Export"), lambda: self.bal_window.export_heirs())
|
||||||
|
|
||||||
self.heir_locktime = HeirsLockTimeEdit(self, 0)
|
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")
|
||||||
@@ -2691,8 +2693,9 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
def update_will_settings(self):
|
def update_will_settings(self):
|
||||||
try:
|
try:
|
||||||
self.heir_locktime.set_locktime(self.bal_window.will_settings["locktime"])
|
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_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:
|
except Exception as e:
|
||||||
_logger.debug(f"Exception update_will_settings {e}")
|
_logger.debug(f"Exception update_will_settings {e}")
|
||||||
@@ -2737,6 +2740,7 @@ class PreviewList(MyTreeView):
|
|||||||
|
|
||||||
self.wallet = bal_window.window.wallet
|
self.wallet = bal_window.window.wallet
|
||||||
self.setModel(QStandardItemModel(self))
|
self.setModel(QStandardItemModel(self))
|
||||||
|
self.sortByColumn(self.Columns.LOCKTIME, Qt.SortOrder.AscendingOrder)
|
||||||
self.setSortingEnabled(True)
|
self.setSortingEnabled(True)
|
||||||
self.std_model = self.model()
|
self.std_model = self.model()
|
||||||
self.config = bal_window.bal_plugin.config
|
self.config = bal_window.bal_plugin.config
|
||||||
@@ -2895,6 +2899,8 @@ class PreviewList(MyTreeView):
|
|||||||
tmp = self.replace(set_current, current_key, txid, bal_tx)
|
tmp = self.replace(set_current, current_key, txid, bal_tx)
|
||||||
if tmp:
|
if tmp:
|
||||||
set_current = tmp
|
set_current = tmp
|
||||||
|
self.sortByColumn(self.Columns.LOCKTIME, Qt.SortOrder.AscendingOrder)
|
||||||
|
self.setSortingEnabled(True)
|
||||||
|
|
||||||
def create_toolbar(self, config):
|
def create_toolbar(self, config):
|
||||||
toolbar, menu = self.create_toolbar_with_menu("")
|
toolbar, menu = self.create_toolbar_with_menu("")
|
||||||
@@ -2913,6 +2919,9 @@ class PreviewList(MyTreeView):
|
|||||||
display = QPushButton(_("Display"))
|
display = QPushButton(_("Display"))
|
||||||
display.clicked.connect(self.bal_window.preview_modal_dialog)
|
display.clicked.connect(self.bal_window.preview_modal_dialog)
|
||||||
|
|
||||||
|
display = QPushButton(_("refresh"))
|
||||||
|
display.clicked.connect(self.check)
|
||||||
|
|
||||||
widget = QWidget()
|
widget = QWidget()
|
||||||
hlayout = QHBoxLayout(widget)
|
hlayout = QHBoxLayout(widget)
|
||||||
hlayout.addWidget(wizard)
|
hlayout.addWidget(wizard)
|
||||||
@@ -2954,10 +2963,19 @@ class PreviewList(MyTreeView):
|
|||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def check(self):
|
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 = {}
|
will = {}
|
||||||
for wid, w in self.bal_window.willitems.items():
|
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
|
will[wid] = w
|
||||||
|
if will:
|
||||||
self.bal_window.check_transactions(will)
|
self.bal_window.check_transactions(will)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@@ -2991,6 +3009,10 @@ class PreviewDialog(BalDialog, MessageBoxMixin):
|
|||||||
self.setMinimumSize(1000, 200)
|
self.setMinimumSize(1000, 200)
|
||||||
self.size_label = QLabel()
|
self.size_label = QLabel()
|
||||||
self.transactions_list = PreviewList(self.bal_window, self.will)
|
self.transactions_list = PreviewList(self.bal_window, self.will)
|
||||||
|
|
||||||
|
self.bal_window.init_class_variables()
|
||||||
|
self.check_will()
|
||||||
|
|
||||||
vbox = QVBoxLayout(self)
|
vbox = QVBoxLayout(self)
|
||||||
vbox.addWidget(self.size_label)
|
vbox.addWidget(self.size_label)
|
||||||
vbox.addWidget(self.transactions_list)
|
vbox.addWidget(self.transactions_list)
|
||||||
@@ -3041,14 +3063,6 @@ class PreviewDialog(BalDialog, MessageBoxMixin):
|
|||||||
event.accept()
|
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):
|
class WillDetailDialog(BalDialog):
|
||||||
def __init__(self, bal_window):
|
def __init__(self, bal_window):
|
||||||
|
|
||||||
|
|||||||
9
will.py
9
will.py
@@ -394,8 +394,10 @@ class Will:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
if wallet.db.get_transaction(wi._id):
|
if wallet.db.get_transaction(wi._id):
|
||||||
|
print("search rai status confirmed")
|
||||||
wi.set_status("CONFIRMED", True)
|
wi.set_status("CONFIRMED", True)
|
||||||
else:
|
else:
|
||||||
|
print("search rai status invalidated")
|
||||||
wi.set_status("INVALIDATED", True)
|
wi.set_status("INVALIDATED", True)
|
||||||
|
|
||||||
for child in wi.search(all_inputs):
|
for child in wi.search(all_inputs):
|
||||||
@@ -420,8 +422,10 @@ class Will:
|
|||||||
|
|
||||||
# check if transactions are stil valid tecnically valid
|
# check if transactions are stil valid tecnically valid
|
||||||
def check_invalidated(willtree, utxos_list, wallet):
|
def check_invalidated(willtree, utxos_list, wallet):
|
||||||
|
print("utxo list",utxos_list)
|
||||||
for wid, w in willtree.items():
|
for wid, w in willtree.items():
|
||||||
if not w.father:
|
print("check transaction",w._id)
|
||||||
|
#if not w.father:
|
||||||
for inp in w.tx.inputs():
|
for inp in w.tx.inputs():
|
||||||
inp_str = Util.utxo_to_str(inp)
|
inp_str = Util.utxo_to_str(inp)
|
||||||
if not inp_str in utxos_list:
|
if not inp_str in utxos_list:
|
||||||
@@ -432,7 +436,10 @@ class Will:
|
|||||||
elif height == 0:
|
elif height == 0:
|
||||||
w.set_status("PENDING", True)
|
w.set_status("PENDING", True)
|
||||||
else:
|
else:
|
||||||
|
print("check_invalidate status confirmed",w._id)
|
||||||
w.set_status("CONFIRMED", True)
|
w.set_status("CONFIRMED", True)
|
||||||
|
#else:
|
||||||
|
# print("father",w.father)
|
||||||
|
|
||||||
def reflect_to_children(treeitem):
|
def reflect_to_children(treeitem):
|
||||||
if not treeitem.get_status("VALID"):
|
if not treeitem.get_status("VALID"):
|
||||||
|
|||||||
Reference in New Issue
Block a user