close task invalidate tx
This commit is contained in:
1
bal.py
1
bal.py
@@ -62,7 +62,6 @@ class BalPlugin(BasePlugin):
|
||||
SIZE = (159, 97)
|
||||
|
||||
def __init__(self, parent, config, name):
|
||||
print("init bal_plugin")
|
||||
self.logger = get_logger(__name__)
|
||||
BasePlugin.__init__(self, parent, config, name)
|
||||
self.base_dir = os.path.join(config.electrum_path(), "bal")
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
|
||||
PLUGIN_DIR = os.path.split(os.path.realpath(__file__))[0]
|
||||
DEFAULT_ICON = "bal32x32.png"
|
||||
DEFAULT_ICON_PATH = ""
|
||||
DEFAULT_ICON_PATH = "icons"
|
||||
|
||||
|
||||
def icon_path(icon_basename: str = DEFAULT_ICON):
|
||||
|
||||
41
qt.py
41
qt.py
@@ -169,13 +169,11 @@ class Plugin(BalPlugin, Logger):
|
||||
def __init__(self, parent, config, name):
|
||||
Logger.__init__(self)
|
||||
self.logger.info("INIT BALPLUGIN")
|
||||
print("init bal_plugin")
|
||||
BalPlugin.__init__(self, parent, config, name)
|
||||
self.bal_windows = {}
|
||||
|
||||
@hook
|
||||
def init_qt(self, gui_object):
|
||||
print("hook init qt")
|
||||
self.logger.info("HOOK init qt")
|
||||
try:
|
||||
self.gui_object = gui_object
|
||||
@@ -225,7 +223,7 @@ class Plugin(BalPlugin, Logger):
|
||||
|
||||
@hook
|
||||
def load_wallet(self, wallet, main_window):
|
||||
self.logger.info("HOOK load wallet")
|
||||
self.logger.debug("HOOK load wallet")
|
||||
w = self.get_window(main_window)
|
||||
# havetoupdate = Util.fix_will_settings_tx_fees(wallet.db)
|
||||
w.wallet = wallet
|
||||
@@ -238,18 +236,18 @@ class Plugin(BalPlugin, Logger):
|
||||
|
||||
@hook
|
||||
def close_wallet(self, wallet):
|
||||
print("HOOK close wallet")
|
||||
self.logger.debug("HOOK close wallet")
|
||||
for winid, win in self.bal_windows.items():
|
||||
if win.wallet == wallet:
|
||||
win.on_close()
|
||||
|
||||
@hook
|
||||
def init_keystore(self):
|
||||
print("init keystore")
|
||||
self.logger.debug("init keystore")
|
||||
|
||||
@hook
|
||||
def daemon_wallet_loaded(self, boh, wallet):
|
||||
print("daemon wallet loaded")
|
||||
self.logger.debug("daemon wallet loaded")
|
||||
|
||||
def get_window(self, window):
|
||||
w = self.bal_windows.get(window.winId, None)
|
||||
@@ -1180,7 +1178,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:
|
||||
@@ -2079,6 +2077,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.bal_window.window.wallet.dust_threshold(),
|
||||
)
|
||||
_logger.debug("variables ok")
|
||||
self.msg_set_status("checking variables:", varrow,"Ok")
|
||||
except AmountException:
|
||||
self.msg_set_status(
|
||||
"checking variables",
|
||||
@@ -2091,7 +2090,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
)
|
||||
+ "</font>",
|
||||
)
|
||||
|
||||
|
||||
self.msg_set_checking()
|
||||
have_to_build = False
|
||||
try:
|
||||
@@ -2238,8 +2237,9 @@ class BalBuildWillDialog(BalDialog):
|
||||
if not self._stopping:
|
||||
self.loop_push()
|
||||
|
||||
def invalidate_task(self, tx, password):
|
||||
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)
|
||||
try:
|
||||
if tx:
|
||||
@@ -2247,11 +2247,12 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.loop_broadcast_invalidating(tx)
|
||||
self.wait(5)
|
||||
else:
|
||||
raise
|
||||
raise Exception("tx not complete")
|
||||
else:
|
||||
raise
|
||||
except Exception:
|
||||
self.msg_set_invalidating("Error")
|
||||
raise Exception("not tx")
|
||||
except Exception as e:
|
||||
(f"exception:{e}")
|
||||
self.msg_set_invalidating(f"Error: {e}")
|
||||
raise Exception("Impossible to sign")
|
||||
|
||||
def on_success_invalidate(self, success):
|
||||
@@ -2265,12 +2266,12 @@ 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))
|
||||
password = None
|
||||
if self.have_to_sign is None:
|
||||
_logger.debug("have to invalidate")
|
||||
self.msg_set_invalidating()
|
||||
# need to sign invalidate and restart phase 1
|
||||
|
||||
@@ -2283,7 +2284,7 @@ class BalBuildWillDialog(BalDialog):
|
||||
self.close()
|
||||
return
|
||||
self.thread.add(
|
||||
partial(self.invalidate_task, tx, password),
|
||||
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,
|
||||
@@ -3391,19 +3392,17 @@ class WillExecutorList(MyTreeView):
|
||||
labels = [""] * len(self.Columns)
|
||||
labels[self.Columns.URL] = url
|
||||
if Willexecutors.is_selected(value):
|
||||
labels[self.Columns.SELECTED] = [read_QIcon("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("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("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", ""))
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from PyQt6.QtWidgets import (
|
||||
from PyQt6.QtCore import Qt
|
||||
from electrum.storage import WalletStorage
|
||||
from electrum.util import MyEncoder
|
||||
from bal_wallet_utils import fix_will_settings_tx_fees, uninstall_bal, read_wallet
|
||||
from bal_wallet_utils import fix_will_settings_tx_fees, uninstall_bal, read_wallet, save
|
||||
|
||||
|
||||
class WalletUtilityGUI(QMainWindow):
|
||||
@@ -175,7 +175,7 @@ class WalletUtilityGUI(QMainWindow):
|
||||
|
||||
if have_to_save:
|
||||
try:
|
||||
save_wallet(json_wallet, storage)
|
||||
save(json_wallet, storage)
|
||||
self.log_message(f"SUCCESS: {message}")
|
||||
except Exception as e:
|
||||
self.log_message(f"Save error: {str(e)}")
|
||||
|
||||
21
will.py
21
will.py
@@ -338,7 +338,6 @@ class Will:
|
||||
if utxo_str in prevout_to_spend:
|
||||
balance += inputs[utxo_str][0][2].value_sats()
|
||||
utxo_to_spend.append(utxo)
|
||||
|
||||
if len(utxo_to_spend) > 0:
|
||||
change_addresses = wallet.get_change_addresses_for_new_transaction()
|
||||
out = PartialTxOutput.from_address_and_value(change_addresses[0], balance)
|
||||
@@ -428,7 +427,6 @@ class Will:
|
||||
if not inp_str in utxos_list:
|
||||
if wallet:
|
||||
height = Will.check_tx_height(w.tx, wallet)
|
||||
print(type(height))
|
||||
if height < 0:
|
||||
Will.set_invalidate(wid, willtree)
|
||||
elif height == 0:
|
||||
@@ -473,23 +471,16 @@ class Will:
|
||||
)
|
||||
|
||||
def check_will(will, all_utxos, wallet, block_to_check, timestamp_to_check):
|
||||
print("check will2")
|
||||
Will.add_willtree(will)
|
||||
print("willtree")
|
||||
utxos_list = Will.utxos_strs(all_utxos)
|
||||
print("utxo_list")
|
||||
|
||||
Will.check_invalidated(will, utxos_list, wallet)
|
||||
print("check invalidate")
|
||||
|
||||
all_inputs = Will.get_all_inputs(will, only_valid=True)
|
||||
print("get all inputs")
|
||||
all_inputs_min_locktime = Will.get_all_inputs_min_locktime(all_inputs)
|
||||
print("min_locktime")
|
||||
Will.check_will_expired(
|
||||
all_inputs_min_locktime, block_to_check, timestamp_to_check
|
||||
)
|
||||
print("check expired")
|
||||
|
||||
all_inputs = Will.get_all_inputs(will, only_valid=True)
|
||||
|
||||
@@ -507,9 +498,7 @@ class Will:
|
||||
wallet=False,
|
||||
callback_not_valid_tx=None,
|
||||
):
|
||||
print("is_will_valid")
|
||||
Will.check_will(will, all_utxos, wallet, block_to_check, timestamp_to_check)
|
||||
print("check will")
|
||||
if heirs:
|
||||
if not Will.check_willexecutors_and_heirs(
|
||||
will,
|
||||
@@ -665,11 +654,11 @@ class WillItem(Logger):
|
||||
}
|
||||
|
||||
def set_status(self, status, value=True):
|
||||
_logger.debug(
|
||||
"set status {} - {} {} -> {}".format(
|
||||
self._id, status, self.STATUS[status][1], value
|
||||
)
|
||||
)
|
||||
#_logger.trace(
|
||||
# "set status {} - {} {} -> {}".format(
|
||||
# self._id, status, self.STATUS[status][1], value
|
||||
# )
|
||||
#)
|
||||
if self.STATUS[status][1] == bool(value):
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user