dust bugfix
This commit is contained in:
153
qt.py
153
qt.py
@@ -145,7 +145,7 @@ from electrum.util import (
|
||||
|
||||
from .bal import BalPlugin
|
||||
from .bal_resources import DEFAULT_ICON, icon_path
|
||||
from .heirs import Heirs
|
||||
from .heirs import Heirs, HEIR_REAL_AMOUNT, HEIR_DUST_AMOUNT
|
||||
from .util import Util
|
||||
from .will import (
|
||||
AmountException,
|
||||
@@ -295,8 +295,8 @@ class Plugin(BalPlugin, Logger):
|
||||
lbl_logo = QLabel()
|
||||
lbl_logo.setPixmap(qicon)
|
||||
|
||||
#heir_ping_willexecutors = bal_checkbox(self.PING_WILLEXECUTORS)
|
||||
#heir_ask_ping_willexecutors = bal_checkbox(self.ASK_PING_WILLEXECUTORS)
|
||||
# heir_ping_willexecutors = bal_checkbox(self.PING_WILLEXECUTORS)
|
||||
# heir_ask_ping_willexecutors = bal_checkbox(self.ASK_PING_WILLEXECUTORS)
|
||||
heir_no_willexecutor = bal_checkbox(self.NO_WILLEXECUTOR)
|
||||
|
||||
def on_multiverse_change():
|
||||
@@ -327,27 +327,27 @@ class Plugin(BalPlugin, Logger):
|
||||
2,
|
||||
"Hide invalidated transactions from will detail and list",
|
||||
)
|
||||
#add_widget(
|
||||
# add_widget(
|
||||
# grid,
|
||||
# "Ping Willexecutors",
|
||||
# heir_ping_willexecutors,
|
||||
# 3,
|
||||
# "Ping willexecutors to get payment info before compiling will",
|
||||
#)
|
||||
#add_widget(
|
||||
# )
|
||||
# add_widget(
|
||||
# grid,
|
||||
# " - Ask before",
|
||||
# heir_ask_ping_willexecutors,
|
||||
# 4,
|
||||
# "Ask before to ping willexecutor",
|
||||
#)
|
||||
#add_widget(
|
||||
# )
|
||||
# add_widget(
|
||||
# grid,
|
||||
# "Backup Transaction",
|
||||
# heir_no_willexecutor,
|
||||
# 5,
|
||||
# "Add transactions without willexecutor",
|
||||
#)
|
||||
# )
|
||||
# add_widget(grid,"Enable Multiverse(EXPERIMENTAL/BROKEN)",heir_enable_multiverse,6,"enable multiple locktimes, will import.... ")
|
||||
grid.addWidget(heir_repush, 7, 0)
|
||||
grid.addWidget(
|
||||
@@ -473,7 +473,7 @@ class BalWindow(Logger):
|
||||
self.bal_plugin, update=False, bal_window=self
|
||||
)
|
||||
if not self.heirs:
|
||||
self.heirs = Heirs._validate(Heirs(self.wallet.db))
|
||||
self.heirs = Heirs._validate(Heirs(self.wallet))
|
||||
if not self.will:
|
||||
self.will = self.wallet.db.get_dict("will")
|
||||
Util.fix_will_tx_fees(self.will)
|
||||
@@ -522,7 +522,6 @@ class BalWindow(Logger):
|
||||
tab.is_shown_cv = shown_cv(True)
|
||||
return tab
|
||||
|
||||
|
||||
def new_heir_dialog(self, heir_key=None):
|
||||
heir = self.heirs.get(heir_key)
|
||||
title = "New heir"
|
||||
@@ -655,6 +654,7 @@ class BalWindow(Logger):
|
||||
Will.normalize_will(self.willitems, self.wallet)
|
||||
|
||||
def build_will(self, ignore_duplicate=True, keep_original=True):
|
||||
_logger.debug("building will...")
|
||||
will = {}
|
||||
willtodelete = []
|
||||
willtoappend = {}
|
||||
@@ -670,6 +670,7 @@ class BalWindow(Logger):
|
||||
if Willexecutors.is_selected(w):
|
||||
f = True
|
||||
if not f:
|
||||
_logger.error("No Will-Executor or backup transaction selected")
|
||||
raise NoWillExecutorNotPresent(
|
||||
"No Will-Executor or backup transaction selected"
|
||||
)
|
||||
@@ -680,7 +681,8 @@ class BalWindow(Logger):
|
||||
None,
|
||||
self.date_to_check,
|
||||
)
|
||||
self.logger.info(txs)
|
||||
|
||||
self.logger.info(f"txs built: {txs}")
|
||||
creation_time = time.time()
|
||||
if txs:
|
||||
for txid in txs:
|
||||
@@ -699,7 +701,13 @@ class BalWindow(Logger):
|
||||
tx["txchildren"] = []
|
||||
will[txid] = WillItem(tx, _id=txid, wallet=self.wallet)
|
||||
self.update_will(will)
|
||||
else:
|
||||
self.logger.info("No transactions was built")
|
||||
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}")
|
||||
except Exception as e:
|
||||
self.logger.info(f"Exception build_will: {e}")
|
||||
raise e
|
||||
pass
|
||||
return self.willitems
|
||||
@@ -1177,7 +1185,7 @@ class BalWindow(Logger):
|
||||
parent = self
|
||||
|
||||
def on_success(result):
|
||||
#del self.waiting_dialog
|
||||
# del self.waiting_dialog
|
||||
try:
|
||||
parent.willexecutor_list.update()
|
||||
except Exception as e:
|
||||
@@ -1757,7 +1765,9 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
|
||||
|
||||
def on_success(willexecutors):
|
||||
self.bal_window.willexecutors.update(willexecutors)
|
||||
self.bal_window.ping_willexecutors(self.bal_window.willexecutors,False)
|
||||
self.bal_window.ping_willexecutors(
|
||||
self.bal_window.willexecutors, False
|
||||
)
|
||||
if index < 1:
|
||||
for we in self.bal_window.willexecutors:
|
||||
if self.bal_window.willexecutors[we]["status"] == 200:
|
||||
@@ -1828,7 +1838,6 @@ 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)
|
||||
|
||||
@@ -1846,7 +1855,6 @@ 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)
|
||||
@@ -2029,7 +2037,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
if not parent:
|
||||
parent = bal_window.window
|
||||
BalDialog.__init__(self, parent, bal_window.bal_plugin, "Building Will")
|
||||
self.parent=parent
|
||||
self.parent = parent
|
||||
self.updatemessage.connect(self.update)
|
||||
self.bal_window = bal_window
|
||||
self.message_label = QLabel("Building Will:")
|
||||
@@ -2080,7 +2088,7 @@ 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")
|
||||
except AmountException:
|
||||
self.msg_set_status(
|
||||
"checking variables",
|
||||
@@ -2093,7 +2101,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
)
|
||||
+ "</font>",
|
||||
)
|
||||
|
||||
|
||||
self.msg_set_checking()
|
||||
have_to_build = False
|
||||
try:
|
||||
@@ -2110,7 +2118,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
_logger.debug("no heirs")
|
||||
self.msg_set_checking("No Heirs")
|
||||
except NotCompleteWillException as e:
|
||||
_logger.debug("not complete", e)
|
||||
_logger.debug(f"not complete {e} true")
|
||||
message = False
|
||||
have_to_build = True
|
||||
if isinstance(e, HeirChangeException):
|
||||
@@ -2124,7 +2132,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
elif isinstance(e, HeirNotFoundException):
|
||||
message = "Heir not found"
|
||||
if message:
|
||||
_logger.debug("message")
|
||||
_logger.debug(f"message: {message}")
|
||||
self.msg_set_checking(message)
|
||||
else:
|
||||
self.msg_set_checking("New")
|
||||
@@ -2140,6 +2148,18 @@ class BalBuildWillDialog(BalDialog):
|
||||
except Exception as e:
|
||||
self.msg_set_building(self.msg_error(e))
|
||||
return False, None
|
||||
|
||||
excluded_heirs = []
|
||||
for wid in Will.only_valid(self.bal_window.willitems):
|
||||
heirs = self.bal_window.willitems[wid].heirs
|
||||
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',
|
||||
None,
|
||||
f"Excluded from will {wid}</font>",
|
||||
)
|
||||
|
||||
have_to_sign = False
|
||||
for wid in Will.only_valid(self.bal_window.willitems):
|
||||
if not self.bal_window.willitems[wid].get_status("COMPLETE"):
|
||||
@@ -2240,7 +2260,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
if not self._stopping:
|
||||
self.loop_push()
|
||||
|
||||
def invalidate_task(self,password,bal_window,tx):
|
||||
def invalidate_task(self, password, bal_window, tx):
|
||||
_logger.debug(f"invalidate tx: {tx}")
|
||||
fee_per_byte = bal_window.will_settings.get("baltx_fees", 1)
|
||||
tx = self.bal_window.wallet.sign_transaction(tx, password)
|
||||
@@ -2269,6 +2289,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
def on_error(self, error):
|
||||
_logger.error(error)
|
||||
pass
|
||||
|
||||
def on_success_phase1(self, result):
|
||||
self.have_to_sign, tx = list(result)
|
||||
_logger.debug("have to sign {}".format(self.have_to_sign))
|
||||
@@ -2287,7 +2308,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.close()
|
||||
return
|
||||
self.thread.add(
|
||||
partial(self.invalidate_task,password,self.bal_window,tx),
|
||||
partial(self.invalidate_task, password, self.bal_window, tx),
|
||||
on_success=self.on_success_invalidate,
|
||||
on_done=self.on_accept,
|
||||
on_error=self.on_error,
|
||||
@@ -2399,8 +2420,6 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.password = self.bal_window.get_wallet_password(msg, parent=self)
|
||||
|
||||
def msg_edit_row(self, line, row=None):
|
||||
_logger.debug(f"{row},{line}")
|
||||
|
||||
try:
|
||||
self.labels[row] = line
|
||||
except Exception:
|
||||
@@ -2573,9 +2592,15 @@ 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 + 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)
|
||||
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)
|
||||
@@ -2594,10 +2619,9 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
||||
pass
|
||||
|
||||
def get_edit_key_from_coordinate(self, row, col):
|
||||
a= self.get_role_data_from_coordinate(
|
||||
row, col, role=self.ROLE_HEIR_KEY + col
|
||||
)
|
||||
a = self.get_role_data_from_coordinate(row, col, role=self.ROLE_HEIR_KEY + col)
|
||||
return a
|
||||
|
||||
def create_toolbar(self, config):
|
||||
toolbar, menu = self.create_toolbar_with_menu("")
|
||||
menu.addAction(_("&New Heir"), self.bal_window.new_heir_dialog)
|
||||
@@ -2605,6 +2629,7 @@ 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")
|
||||
@@ -2695,7 +2720,6 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
||||
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}")
|
||||
|
||||
@@ -2963,16 +2987,22 @@ class PreviewList(MyTreeView):
|
||||
|
||||
def check(self):
|
||||
Will.add_willtree(self.bal_window.willitems)
|
||||
all_utxos =self.bal_window.wallet.get_utxos()
|
||||
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)
|
||||
|
||||
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") and w.get_status("PUSHED") and not w.get_status("CHECKED"):
|
||||
if (
|
||||
w.get_status("VALID")
|
||||
and w.get_status("PUSHED")
|
||||
and not w.get_status("CHECKED")
|
||||
):
|
||||
will[wid] = w
|
||||
if will:
|
||||
self.bal_window.check_transactions(will)
|
||||
@@ -3008,7 +3038,7 @@ 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()
|
||||
|
||||
@@ -3290,7 +3320,7 @@ class WillExecutorList(MyTreeView):
|
||||
self.Columns.INFO,
|
||||
],
|
||||
)
|
||||
self.parent=parent
|
||||
self.parent = parent
|
||||
try:
|
||||
self.setModel(QStandardItemModel(self))
|
||||
self.sortByColumn(self.Columns.SELECTED, Qt.SortOrder.AscendingOrder)
|
||||
@@ -3356,9 +3386,9 @@ class WillExecutorList(MyTreeView):
|
||||
self.update()
|
||||
|
||||
def get_edit_key_from_coordinate(self, row, col):
|
||||
role=self.ROLE_HEIR_KEY+col
|
||||
role = self.ROLE_HEIR_KEY + col
|
||||
a = self.get_role_data_from_coordinate(row, col, role=role)
|
||||
return a
|
||||
return a
|
||||
|
||||
def delete(self, selected_keys):
|
||||
for key in selected_keys:
|
||||
@@ -3416,16 +3446,33 @@ class WillExecutorList(MyTreeView):
|
||||
labels[self.Columns.URL] = url
|
||||
if Willexecutors.is_selected(value):
|
||||
|
||||
labels[self.Columns.SELECTED] = [read_QIcon_from_bytes(self.parent.bal_plugin.read_file("icons/confirmed.png")),""]
|
||||
labels[self.Columns.SELECTED] = [
|
||||
read_QIcon_from_bytes(
|
||||
self.parent.bal_plugin.read_file("icons/confirmed.png")
|
||||
),
|
||||
"",
|
||||
]
|
||||
else:
|
||||
labels[self.Columns.SELECTED] = ""
|
||||
labels[self.Columns.BASE_FEE] = Util.decode_amount(
|
||||
value.get("base_fee", 0), self.get_decimal_point()
|
||||
)
|
||||
if str(value.get("status", 0)) == "200":
|
||||
labels[self.Columns.STATUS] = [read_QIcon_from_bytes(self.parent.bal_plugin.read_file("icons/status_connected.png")),""]
|
||||
labels[self.Columns.STATUS] = [
|
||||
read_QIcon_from_bytes(
|
||||
self.parent.bal_plugin.read_file(
|
||||
"icons/status_connected.png"
|
||||
)
|
||||
),
|
||||
"",
|
||||
]
|
||||
else:
|
||||
labels[self.Columns.STATUS] = [read_QIcon_from_bytes(self.parent.bal_plugin.read_file("icons/unconfirmed.png")),""]
|
||||
labels[self.Columns.STATUS] = [
|
||||
read_QIcon_from_bytes(
|
||||
self.parent.bal_plugin.read_file("icons/unconfirmed.png")
|
||||
),
|
||||
"",
|
||||
]
|
||||
labels[self.Columns.ADDRESS] = str(value.get("address", ""))
|
||||
labels[self.Columns.INFO] = str(value.get("info", ""))
|
||||
|
||||
@@ -3445,10 +3492,18 @@ class WillExecutorList(MyTreeView):
|
||||
items[self.Columns.BASE_FEE].setEditable(True)
|
||||
items[self.Columns.STATUS].setEditable(False)
|
||||
|
||||
items[self.Columns.URL].setData(url, self.ROLE_HEIR_KEY + self.Columns.URL)
|
||||
items[self.Columns.BASE_FEE].setData(url, self.ROLE_HEIR_KEY + self.Columns.BASE_FEE)
|
||||
items[self.Columns.INFO].setData(url, self.ROLE_HEIR_KEY + self.Columns.INFO)
|
||||
items[self.Columns.ADDRESS].setData(url, self.ROLE_HEIR_KEY + self.Columns.ADDRESS)
|
||||
items[self.Columns.URL].setData(
|
||||
url, self.ROLE_HEIR_KEY + self.Columns.URL
|
||||
)
|
||||
items[self.Columns.BASE_FEE].setData(
|
||||
url, self.ROLE_HEIR_KEY + self.Columns.BASE_FEE
|
||||
)
|
||||
items[self.Columns.INFO].setData(
|
||||
url, self.ROLE_HEIR_KEY + self.Columns.INFO
|
||||
)
|
||||
items[self.Columns.ADDRESS].setData(
|
||||
url, self.ROLE_HEIR_KEY + self.Columns.ADDRESS
|
||||
)
|
||||
row_count = self.model().rowCount()
|
||||
self.model().insertRow(row_count, items)
|
||||
if url == current_key:
|
||||
@@ -3516,7 +3571,7 @@ class WillExecutorWidget(QWidget, MessageBoxMixin):
|
||||
buttonbox.addWidget(b)
|
||||
|
||||
vbox.addLayout(buttonbox)
|
||||
#self.willexecutor_list.update()
|
||||
# self.willexecutor_list.update()
|
||||
|
||||
def add(self):
|
||||
self.willexecutors_list["http://localhost:8080"] = {
|
||||
@@ -3548,7 +3603,7 @@ class WillExecutorWidget(QWidget, MessageBoxMixin):
|
||||
|
||||
def update_willexecutors(self, wes=None):
|
||||
if not wes:
|
||||
wes=self.willexecutors_list
|
||||
wes = self.willexecutors_list
|
||||
self.bal_window.ping_willexecutors(wes, self.parent)
|
||||
self.willexecutors_list.update(wes)
|
||||
self.willexecutor_list.update()
|
||||
|
||||
Reference in New Issue
Block a user