Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1836cdd892
|
|||
|
2416d0ce8d
|
|||
|
8e4e401d1b
|
|||
|
b8859ee5c1
|
|||
|
faeff1ff3c
|
|||
|
437105477d
|
|||
|
4c12136470
|
|||
|
a918c5564d
|
12
bal.py
12
bal.py
@@ -9,7 +9,8 @@ from electrum.transaction import tx_from_any
|
|||||||
|
|
||||||
|
|
||||||
def get_will_settings(x):
|
def get_will_settings(x):
|
||||||
print(x)
|
#print(x)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
json_db.register_dict("heirs", tuple, None)
|
json_db.register_dict("heirs", tuple, None)
|
||||||
@@ -62,7 +63,6 @@ class BalPlugin(BasePlugin):
|
|||||||
SIZE = (159, 97)
|
SIZE = (159, 97)
|
||||||
|
|
||||||
def __init__(self, parent, config, name):
|
def __init__(self, parent, config, name):
|
||||||
print("init bal_plugin")
|
|
||||||
self.logger = get_logger(__name__)
|
self.logger = get_logger(__name__)
|
||||||
BasePlugin.__init__(self, parent, config, name)
|
BasePlugin.__init__(self, parent, config, name)
|
||||||
self.base_dir = os.path.join(config.electrum_path(), "bal")
|
self.base_dir = os.path.join(config.electrum_path(), "bal")
|
||||||
@@ -96,10 +96,10 @@ class BalPlugin(BasePlugin):
|
|||||||
self.PREVIEW = BalConfig(config, "bal_preview", True)
|
self.PREVIEW = BalConfig(config, "bal_preview", True)
|
||||||
self.SAVE_TXS = BalConfig(config, "bal_save_txs", True)
|
self.SAVE_TXS = BalConfig(config, "bal_save_txs", True)
|
||||||
self.WILLEXECUTORS = BalConfig(config, "bal_willexecutors", True)
|
self.WILLEXECUTORS = BalConfig(config, "bal_willexecutors", True)
|
||||||
self.PING_WILLEXECUTORS = BalConfig(config, "bal_ping_willexecutors", True)
|
#self.PING_WILLEXECUTORS = BalConfig(config, "bal_ping_willexecutors", True)
|
||||||
self.ASK_PING_WILLEXECUTORS = BalConfig(
|
#self.ASK_PING_WILLEXECUTORS = BalConfig(
|
||||||
config, "bal_ask_ping_willexecutors", True
|
# config, "bal_ask_ping_willexecutors", True
|
||||||
)
|
#)
|
||||||
self.NO_WILLEXECUTOR = BalConfig(config, "bal_no_willexecutor", True)
|
self.NO_WILLEXECUTOR = BalConfig(config, "bal_no_willexecutor", True)
|
||||||
self.HIDE_REPLACED = BalConfig(config, "bal_hide_replaced", True)
|
self.HIDE_REPLACED = BalConfig(config, "bal_hide_replaced", True)
|
||||||
self.HIDE_INVALIDATED = BalConfig(config, "bal_hide_invalidated", True)
|
self.HIDE_INVALIDATED = BalConfig(config, "bal_hide_invalidated", True)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import os
|
|||||||
|
|
||||||
PLUGIN_DIR = os.path.split(os.path.realpath(__file__))[0]
|
PLUGIN_DIR = os.path.split(os.path.realpath(__file__))[0]
|
||||||
DEFAULT_ICON = "bal32x32.png"
|
DEFAULT_ICON = "bal32x32.png"
|
||||||
DEFAULT_ICON_PATH = ""
|
DEFAULT_ICON_PATH = "icons"
|
||||||
|
|
||||||
|
|
||||||
def icon_path(icon_basename: str = DEFAULT_ICON):
|
def icon_path(icon_basename: str = DEFAULT_ICON):
|
||||||
|
|||||||
1
heirs.py
1
heirs.py
@@ -138,7 +138,6 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
|
|||||||
outputs.append(change)
|
outputs.append(change)
|
||||||
for i in range(0, 100):
|
for i in range(0, 100):
|
||||||
random.shuffle(outputs)
|
random.shuffle(outputs)
|
||||||
print(outputs)
|
|
||||||
tx = PartialTransaction.from_io(
|
tx = PartialTransaction.from_io(
|
||||||
used_utxos,
|
used_utxos,
|
||||||
outputs,
|
outputs,
|
||||||
|
|||||||
BIN
icons/confirmed.png
Normal file
BIN
icons/confirmed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
BIN
icons/status_connected.png
Normal file
BIN
icons/status_connected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 69 KiB |
BIN
icons/unconfirmed.png
Normal file
BIN
icons/unconfirmed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "BAL",
|
"name": "BAL",
|
||||||
"fullname": "Bitcoin After Life",
|
"fullname": "Bitcoin After Life",
|
||||||
"description": "Provides free and decentralized inheritance support<br> Version: 0.2.2d",
|
"description": "Provides free and decentralized inheritance support<br> Version: 0.2.4",
|
||||||
"author":"Svatantrya",
|
"author":"Svatantrya",
|
||||||
"available_for": ["qt"],
|
"available_for": ["qt"],
|
||||||
"icon":"icons/bal32x32.png"
|
"icon":"icons/bal32x32.png"
|
||||||
|
|||||||
162
qt.py
162
qt.py
@@ -131,6 +131,7 @@ from electrum.gui.qt.util import (
|
|||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.logging import Logger, get_logger
|
from electrum.logging import Logger, get_logger
|
||||||
from electrum.network import BestEffortRequestFailed, Network, TxBroadcastError
|
from electrum.network import BestEffortRequestFailed, Network, TxBroadcastError
|
||||||
|
from electrum.payment_identifier import PaymentIdentifier
|
||||||
from electrum.plugin import hook, run_hook
|
from electrum.plugin import hook, run_hook
|
||||||
from electrum.transaction import SerializationError, Transaction, tx_from_any
|
from electrum.transaction import SerializationError, Transaction, tx_from_any
|
||||||
from electrum.util import (
|
from electrum.util import (
|
||||||
@@ -169,14 +170,12 @@ class Plugin(BalPlugin, Logger):
|
|||||||
def __init__(self, parent, config, name):
|
def __init__(self, parent, config, name):
|
||||||
Logger.__init__(self)
|
Logger.__init__(self)
|
||||||
self.logger.info("INIT BALPLUGIN")
|
self.logger.info("INIT BALPLUGIN")
|
||||||
print("init bal_plugin")
|
|
||||||
BalPlugin.__init__(self, parent, config, name)
|
BalPlugin.__init__(self, parent, config, name)
|
||||||
self.bal_windows = {}
|
self.bal_windows = {}
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def init_qt(self, gui_object):
|
def init_qt(self, gui_object):
|
||||||
print("hook init qt")
|
self.logger.info("HOOK bal init qt")
|
||||||
self.logger.info("HOOK init qt")
|
|
||||||
try:
|
try:
|
||||||
self.gui_object = gui_object
|
self.gui_object = gui_object
|
||||||
for window in gui_object.windows:
|
for window in gui_object.windows:
|
||||||
@@ -225,7 +224,7 @@ class Plugin(BalPlugin, Logger):
|
|||||||
|
|
||||||
@hook
|
@hook
|
||||||
def load_wallet(self, wallet, main_window):
|
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)
|
w = self.get_window(main_window)
|
||||||
# havetoupdate = Util.fix_will_settings_tx_fees(wallet.db)
|
# havetoupdate = Util.fix_will_settings_tx_fees(wallet.db)
|
||||||
w.wallet = wallet
|
w.wallet = wallet
|
||||||
@@ -238,18 +237,18 @@ class Plugin(BalPlugin, Logger):
|
|||||||
|
|
||||||
@hook
|
@hook
|
||||||
def close_wallet(self, wallet):
|
def close_wallet(self, wallet):
|
||||||
print("HOOK close wallet")
|
self.logger.debug("HOOK close wallet")
|
||||||
for winid, win in self.bal_windows.items():
|
for winid, win in self.bal_windows.items():
|
||||||
if win.wallet == wallet:
|
if win.wallet == wallet:
|
||||||
win.on_close()
|
win.on_close()
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def init_keystore(self):
|
def init_keystore(self):
|
||||||
print("init keystore")
|
self.logger.debug("init keystore")
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def daemon_wallet_loaded(self, boh, wallet):
|
def daemon_wallet_loaded(self, boh, wallet):
|
||||||
print("daemon wallet loaded")
|
self.logger.debug("daemon wallet loaded")
|
||||||
|
|
||||||
def get_window(self, window):
|
def get_window(self, window):
|
||||||
w = self.bal_windows.get(window.winId, None)
|
w = self.bal_windows.get(window.winId, None)
|
||||||
@@ -296,8 +295,8 @@ class Plugin(BalPlugin, Logger):
|
|||||||
lbl_logo = QLabel()
|
lbl_logo = QLabel()
|
||||||
lbl_logo.setPixmap(qicon)
|
lbl_logo.setPixmap(qicon)
|
||||||
|
|
||||||
heir_ping_willexecutors = bal_checkbox(self.PING_WILLEXECUTORS)
|
#heir_ping_willexecutors = bal_checkbox(self.PING_WILLEXECUTORS)
|
||||||
heir_ask_ping_willexecutors = bal_checkbox(self.ASK_PING_WILLEXECUTORS)
|
#heir_ask_ping_willexecutors = bal_checkbox(self.ASK_PING_WILLEXECUTORS)
|
||||||
heir_no_willexecutor = bal_checkbox(self.NO_WILLEXECUTOR)
|
heir_no_willexecutor = bal_checkbox(self.NO_WILLEXECUTOR)
|
||||||
|
|
||||||
def on_multiverse_change():
|
def on_multiverse_change():
|
||||||
@@ -328,27 +327,27 @@ class Plugin(BalPlugin, Logger):
|
|||||||
2,
|
2,
|
||||||
"Hide invalidated transactions from will detail and list",
|
"Hide invalidated transactions from will detail and list",
|
||||||
)
|
)
|
||||||
add_widget(
|
#add_widget(
|
||||||
grid,
|
# grid,
|
||||||
"Ping Willexecutors",
|
# "Ping Willexecutors",
|
||||||
heir_ping_willexecutors,
|
# heir_ping_willexecutors,
|
||||||
3,
|
# 3,
|
||||||
"Ping willexecutors to get payment info before compiling will",
|
# "Ping willexecutors to get payment info before compiling will",
|
||||||
)
|
#)
|
||||||
add_widget(
|
#add_widget(
|
||||||
grid,
|
# grid,
|
||||||
" - Ask before",
|
# " - Ask before",
|
||||||
heir_ask_ping_willexecutors,
|
# heir_ask_ping_willexecutors,
|
||||||
4,
|
# 4,
|
||||||
"Ask before to ping willexecutor",
|
# "Ask before to ping willexecutor",
|
||||||
)
|
#)
|
||||||
add_widget(
|
#add_widget(
|
||||||
grid,
|
# grid,
|
||||||
"Backup Transaction",
|
# "Backup Transaction",
|
||||||
heir_no_willexecutor,
|
# heir_no_willexecutor,
|
||||||
5,
|
# 5,
|
||||||
"Add transactions without willexecutor",
|
# "Add transactions without willexecutor",
|
||||||
)
|
#)
|
||||||
# add_widget(grid,"Enable Multiverse(EXPERIMENTAL/BROKEN)",heir_enable_multiverse,6,"enable multiple locktimes, will import.... ")
|
# add_widget(grid,"Enable Multiverse(EXPERIMENTAL/BROKEN)",heir_enable_multiverse,6,"enable multiple locktimes, will import.... ")
|
||||||
grid.addWidget(heir_repush, 7, 0)
|
grid.addWidget(heir_repush, 7, 0)
|
||||||
grid.addWidget(
|
grid.addWidget(
|
||||||
@@ -420,7 +419,7 @@ class BalWindow(Logger):
|
|||||||
tab.tab_icon = icon
|
tab.tab_icon = icon
|
||||||
tab.tab_description = description
|
tab.tab_description = description
|
||||||
tab.tab_pos = len(tabs)
|
tab.tab_pos = len(tabs)
|
||||||
if tab.is_shown_cv:
|
if tab.is_shown_cv.get():
|
||||||
tabs.addTab(tab, icon, description.replace("&", ""))
|
tabs.addTab(tab, icon, description.replace("&", ""))
|
||||||
|
|
||||||
def add_toggle_action(tab):
|
def add_toggle_action(tab):
|
||||||
@@ -515,7 +514,7 @@ class BalWindow(Logger):
|
|||||||
self.heir_list = l = HeirList(self, self.window)
|
self.heir_list = l = HeirList(self, self.window)
|
||||||
|
|
||||||
tab = self.window.create_list_tab(l)
|
tab = self.window.create_list_tab(l)
|
||||||
tab.is_shown_cv = shown_cv(True)
|
tab.is_shown_cv = shown_cv(False)
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
def create_will_tab(self):
|
def create_will_tab(self):
|
||||||
@@ -524,6 +523,7 @@ class BalWindow(Logger):
|
|||||||
tab.is_shown_cv = shown_cv(True)
|
tab.is_shown_cv = shown_cv(True)
|
||||||
return tab
|
return tab
|
||||||
|
|
||||||
|
|
||||||
def new_heir_dialog(self, heir_key=None):
|
def new_heir_dialog(self, heir_key=None):
|
||||||
heir = self.heirs.get(heir_key)
|
heir = self.heirs.get(heir_key)
|
||||||
title = "New heir"
|
title = "New heir"
|
||||||
@@ -656,7 +656,6 @@ class BalWindow(Logger):
|
|||||||
Will.normalize_will(self.willitems, self.wallet)
|
Will.normalize_will(self.willitems, self.wallet)
|
||||||
|
|
||||||
def build_will(self, ignore_duplicate=True, keep_original=True):
|
def build_will(self, ignore_duplicate=True, keep_original=True):
|
||||||
|
|
||||||
will = {}
|
will = {}
|
||||||
willtodelete = []
|
willtodelete = []
|
||||||
willtoappend = {}
|
willtoappend = {}
|
||||||
@@ -665,7 +664,6 @@ class BalWindow(Logger):
|
|||||||
self.willexecutors = Willexecutors.get_willexecutors(
|
self.willexecutors = Willexecutors.get_willexecutors(
|
||||||
self.bal_plugin, update=False, bal_window=self
|
self.bal_plugin, update=False, bal_window=self
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.no_willexecutor:
|
if not self.no_willexecutor:
|
||||||
|
|
||||||
f = False
|
f = False
|
||||||
@@ -1180,7 +1178,7 @@ class BalWindow(Logger):
|
|||||||
parent = self
|
parent = self
|
||||||
|
|
||||||
def on_success(result):
|
def on_success(result):
|
||||||
del self.waiting_dialog
|
#del self.waiting_dialog
|
||||||
try:
|
try:
|
||||||
parent.willexecutor_list.update()
|
parent.willexecutor_list.update()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1578,7 +1576,7 @@ class BalWizardDialog(BalDialog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_next_we(self):
|
def on_next_we(self):
|
||||||
close_window = BalBuildWillDialog(self.bal_window, self)
|
close_window = BalBuildWillDialog(self.bal_window)
|
||||||
close_window.build_will_task()
|
close_window.build_will_task()
|
||||||
self.close()
|
self.close()
|
||||||
# self.next_widget(BalWizardLocktimeAndFeeWidget(self.bal_window,self,self.on_next_locktimeandfee,self.on_next_wedonwload,self.on_next_wedonwload.on_cancel_heir))
|
# self.next_widget(BalWizardLocktimeAndFeeWidget(self.bal_window,self,self.on_next_locktimeandfee,self.on_next_wedonwload,self.on_next_wedonwload.on_cancel_heir))
|
||||||
@@ -1688,7 +1686,7 @@ class BalWizardHeirsWidget(BalWizardWidget):
|
|||||||
button_import = QPushButton(_("Import"))
|
button_import = QPushButton(_("Import"))
|
||||||
button_import.clicked.connect(self.import_from_file)
|
button_import.clicked.connect(self.import_from_file)
|
||||||
button_export = QPushButton(_("Export"))
|
button_export = QPushButton(_("Export"))
|
||||||
button_import.clicked.connect(self.export_to_file)
|
button_export.clicked.connect(self.export_to_file)
|
||||||
widget = QWidget()
|
widget = QWidget()
|
||||||
vbox = QVBoxLayout(widget)
|
vbox = QVBoxLayout(widget)
|
||||||
vbox.addWidget(self.heirs_list)
|
vbox.addWidget(self.heirs_list)
|
||||||
@@ -1760,7 +1758,7 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
|
|||||||
|
|
||||||
def on_success(willexecutors):
|
def on_success(willexecutors):
|
||||||
self.bal_window.willexecutors.update(willexecutors)
|
self.bal_window.willexecutors.update(willexecutors)
|
||||||
self.bal_window.ping_willexecutors(self.bal_window.willexecutors)
|
self.bal_window.ping_willexecutors(self.bal_window.willexecutors,False)
|
||||||
if index < 1:
|
if index < 1:
|
||||||
for we in self.bal_window.willexecutors:
|
for we in self.bal_window.willexecutors:
|
||||||
if self.bal_window.willexecutors[we]["status"] == 200:
|
if self.bal_window.willexecutors[we]["status"] == 200:
|
||||||
@@ -2029,6 +2027,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
if not parent:
|
if not parent:
|
||||||
parent = bal_window.window
|
parent = bal_window.window
|
||||||
BalDialog.__init__(self, parent, bal_window.bal_plugin, "Building Will")
|
BalDialog.__init__(self, parent, bal_window.bal_plugin, "Building Will")
|
||||||
|
self.parent=parent
|
||||||
self.updatemessage.connect(self.update)
|
self.updatemessage.connect(self.update)
|
||||||
self.bal_window = bal_window
|
self.bal_window = bal_window
|
||||||
self.message_label = QLabel("Building Will:")
|
self.message_label = QLabel("Building Will:")
|
||||||
@@ -2079,6 +2078,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.bal_window.window.wallet.dust_threshold(),
|
self.bal_window.window.wallet.dust_threshold(),
|
||||||
)
|
)
|
||||||
_logger.debug("variables ok")
|
_logger.debug("variables ok")
|
||||||
|
self.msg_set_status("checking variables:", varrow,"Ok")
|
||||||
except AmountException:
|
except AmountException:
|
||||||
self.msg_set_status(
|
self.msg_set_status(
|
||||||
"checking variables",
|
"checking variables",
|
||||||
@@ -2091,7 +2091,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
)
|
)
|
||||||
+ "</font>",
|
+ "</font>",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.msg_set_checking()
|
self.msg_set_checking()
|
||||||
have_to_build = False
|
have_to_build = False
|
||||||
try:
|
try:
|
||||||
@@ -2238,8 +2238,9 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
if not self._stopping:
|
if not self._stopping:
|
||||||
self.loop_push()
|
self.loop_push()
|
||||||
|
|
||||||
def invalidate_task(self, tx, password):
|
def invalidate_task(self,password,bal_window,tx):
|
||||||
_logger.debug(f"invalidate tx: {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)
|
tx = self.bal_window.wallet.sign_transaction(tx, password)
|
||||||
try:
|
try:
|
||||||
if tx:
|
if tx:
|
||||||
@@ -2247,11 +2248,12 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.loop_broadcast_invalidating(tx)
|
self.loop_broadcast_invalidating(tx)
|
||||||
self.wait(5)
|
self.wait(5)
|
||||||
else:
|
else:
|
||||||
raise
|
raise Exception("tx not complete")
|
||||||
else:
|
else:
|
||||||
raise
|
raise Exception("not tx")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
self.msg_set_invalidating("Error")
|
(f"exception:{e}")
|
||||||
|
self.msg_set_invalidating(f"Error: {e}")
|
||||||
raise Exception("Impossible to sign")
|
raise Exception("Impossible to sign")
|
||||||
|
|
||||||
def on_success_invalidate(self, success):
|
def on_success_invalidate(self, success):
|
||||||
@@ -2265,12 +2267,12 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
def on_error(self, error):
|
def on_error(self, error):
|
||||||
_logger.error(error)
|
_logger.error(error)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_success_phase1(self, result):
|
def on_success_phase1(self, result):
|
||||||
self.have_to_sign, tx = list(result)
|
self.have_to_sign, tx = list(result)
|
||||||
_logger.debug("have to sign {}".format(self.have_to_sign))
|
_logger.debug("have to sign {}".format(self.have_to_sign))
|
||||||
password = None
|
password = None
|
||||||
if self.have_to_sign is None:
|
if self.have_to_sign is None:
|
||||||
|
_logger.debug("have to invalidate")
|
||||||
self.msg_set_invalidating()
|
self.msg_set_invalidating()
|
||||||
# need to sign invalidate and restart phase 1
|
# need to sign invalidate and restart phase 1
|
||||||
|
|
||||||
@@ -2283,7 +2285,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
self.thread.add(
|
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_success=self.on_success_invalidate,
|
||||||
on_done=self.on_accept,
|
on_done=self.on_accept,
|
||||||
on_error=self.on_error,
|
on_error=self.on_error,
|
||||||
@@ -2590,10 +2592,10 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_edit_key_from_coordinate(self, row, col):
|
def get_edit_key_from_coordinate(self, row, col):
|
||||||
return 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 + 1
|
||||||
)
|
)
|
||||||
|
return a
|
||||||
def create_toolbar(self, config):
|
def create_toolbar(self, config):
|
||||||
toolbar, menu = self.create_toolbar_with_menu("")
|
toolbar, menu = self.create_toolbar_with_menu("")
|
||||||
menu.addAction(_("&New Heir"), self.bal_window.new_heir_dialog)
|
menu.addAction(_("&New Heir"), self.bal_window.new_heir_dialog)
|
||||||
@@ -3244,24 +3246,27 @@ class WillExecutorList(MyTreeView):
|
|||||||
class Columns(MyTreeView.BaseColumnsEnum):
|
class Columns(MyTreeView.BaseColumnsEnum):
|
||||||
SELECTED = enum.auto()
|
SELECTED = enum.auto()
|
||||||
URL = enum.auto()
|
URL = enum.auto()
|
||||||
|
STATUS = enum.auto()
|
||||||
BASE_FEE = enum.auto()
|
BASE_FEE = enum.auto()
|
||||||
INFO = enum.auto()
|
INFO = enum.auto()
|
||||||
ADDRESS = enum.auto()
|
ADDRESS = enum.auto()
|
||||||
STATUS = enum.auto()
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
Columns.SELECTED: _(""),
|
Columns.SELECTED: _(""),
|
||||||
Columns.URL: _("Url"),
|
Columns.URL: _("Url"),
|
||||||
|
Columns.STATUS: _("S"),
|
||||||
Columns.BASE_FEE: _("Base fee"),
|
Columns.BASE_FEE: _("Base fee"),
|
||||||
Columns.INFO: _("Info"),
|
Columns.INFO: _("Info"),
|
||||||
Columns.ADDRESS: _("Default Address"),
|
Columns.ADDRESS: _("Default Address"),
|
||||||
Columns.STATUS: _("S"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ROLE_HEIR_KEY = Qt.ItemDataRole.UserRole + 2000
|
filter_columns = [Columns.URL]
|
||||||
|
|
||||||
|
ROLE_SORT_ORDER = Qt.ItemDataRole.UserRole + 3000
|
||||||
|
ROLE_HEIR_KEY = Qt.ItemDataRole.UserRole + 3001
|
||||||
key_role = ROLE_HEIR_KEY
|
key_role = ROLE_HEIR_KEY
|
||||||
|
|
||||||
def __init__(self, parent: "WillExecutorDialog"):
|
def __init__(self, parent: "WillExecutorWidget"):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
parent=parent,
|
parent=parent,
|
||||||
stretch_column=self.Columns.ADDRESS,
|
stretch_column=self.Columns.ADDRESS,
|
||||||
@@ -3272,8 +3277,13 @@ class WillExecutorList(MyTreeView):
|
|||||||
self.Columns.INFO,
|
self.Columns.INFO,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
self.parent = parent
|
self.parent=parent
|
||||||
self.setModel(QStandardItemModel(self))
|
try:
|
||||||
|
self.setModel(QStandardItemModel(self))
|
||||||
|
self.sortByColumn(self.Columns.SELECTED, Qt.SortOrder.AscendingOrder)
|
||||||
|
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
self.setSortingEnabled(True)
|
self.setSortingEnabled(True)
|
||||||
self.std_model = self.model()
|
self.std_model = self.model()
|
||||||
self.config = parent.bal_plugin.config
|
self.config = parent.bal_plugin.config
|
||||||
@@ -3333,8 +3343,9 @@ class WillExecutorList(MyTreeView):
|
|||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
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(row, col, role=self.ROLE_HEIR_KEY + col)
|
role=self.ROLE_HEIR_KEY+col
|
||||||
return a
|
a = self.get_role_data_from_coordinate(row, col, role=role)
|
||||||
|
return a
|
||||||
|
|
||||||
def delete(self, selected_keys):
|
def delete(self, selected_keys):
|
||||||
for key in selected_keys:
|
for key in selected_keys:
|
||||||
@@ -3391,19 +3402,17 @@ class WillExecutorList(MyTreeView):
|
|||||||
labels = [""] * len(self.Columns)
|
labels = [""] * len(self.Columns)
|
||||||
labels[self.Columns.URL] = url
|
labels[self.Columns.URL] = url
|
||||||
if Willexecutors.is_selected(value):
|
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:
|
else:
|
||||||
labels[self.Columns.SELECTED] = ""
|
labels[self.Columns.SELECTED] = ""
|
||||||
labels[self.Columns.BASE_FEE] = Util.decode_amount(
|
labels[self.Columns.BASE_FEE] = Util.decode_amount(
|
||||||
value.get("base_fee", 0), self.get_decimal_point()
|
value.get("base_fee", 0), self.get_decimal_point()
|
||||||
)
|
)
|
||||||
if str(value.get("status", 0)) == "200":
|
if str(value.get("status", 0)) == "200":
|
||||||
labels[self.Columns.STATUS] = [
|
labels[self.Columns.STATUS] = [read_QIcon_from_bytes(self.parent.bal_plugin.read_file("icons/status_connected.png")),""]
|
||||||
read_QIcon("icons/status_connected.png"),
|
|
||||||
"",
|
|
||||||
]
|
|
||||||
else:
|
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.ADDRESS] = str(value.get("address", ""))
|
||||||
labels[self.Columns.INFO] = str(value.get("info", ""))
|
labels[self.Columns.INFO] = str(value.get("info", ""))
|
||||||
|
|
||||||
@@ -3423,17 +3432,17 @@ class WillExecutorList(MyTreeView):
|
|||||||
items[self.Columns.BASE_FEE].setEditable(True)
|
items[self.Columns.BASE_FEE].setEditable(True)
|
||||||
items[self.Columns.STATUS].setEditable(False)
|
items[self.Columns.STATUS].setEditable(False)
|
||||||
|
|
||||||
items[self.Columns.URL].setData(url, self.ROLE_HEIR_KEY + 1)
|
items[self.Columns.URL].setData(url, self.ROLE_HEIR_KEY + self.Columns.URL)
|
||||||
items[self.Columns.BASE_FEE].setData(url, self.ROLE_HEIR_KEY + 2)
|
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 + 3)
|
items[self.Columns.INFO].setData(url, self.ROLE_HEIR_KEY + self.Columns.INFO)
|
||||||
items[self.Columns.ADDRESS].setData(url, self.ROLE_HEIR_KEY + 4)
|
items[self.Columns.ADDRESS].setData(url, self.ROLE_HEIR_KEY + self.Columns.ADDRESS)
|
||||||
row_count = self.model().rowCount()
|
row_count = self.model().rowCount()
|
||||||
self.model().insertRow(row_count, items)
|
self.model().insertRow(row_count, items)
|
||||||
if url == current_key:
|
if url == current_key:
|
||||||
idx = self.model().index(row_count, self.Columns.NAME)
|
idx = self.model().index(row_count, self.Columns.URL)
|
||||||
set_current = QPersistentModelIndex(idx)
|
set_current = QPersistentModelIndex(idx)
|
||||||
self.set_current_idx(set_current)
|
self.set_current_idx(set_current)
|
||||||
|
self.filter()
|
||||||
self.parent.save_willexecutors()
|
self.parent.save_willexecutors()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -3494,7 +3503,7 @@ class WillExecutorWidget(QWidget, MessageBoxMixin):
|
|||||||
buttonbox.addWidget(b)
|
buttonbox.addWidget(b)
|
||||||
|
|
||||||
vbox.addLayout(buttonbox)
|
vbox.addLayout(buttonbox)
|
||||||
self.willexecutor_list.update()
|
#self.willexecutor_list.update()
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
self.willexecutors_list["http://localhost:8080"] = {
|
self.willexecutors_list["http://localhost:8080"] = {
|
||||||
@@ -3526,17 +3535,10 @@ class WillExecutorWidget(QWidget, MessageBoxMixin):
|
|||||||
|
|
||||||
def update_willexecutors(self, wes=None):
|
def update_willexecutors(self, wes=None):
|
||||||
if not wes:
|
if not wes:
|
||||||
self.willexecutors_list = Willexecutors.get_willexecutors(
|
wes=self.willexecutors_list
|
||||||
self.bal_plugin,
|
self.bal_window.ping_willexecutors(wes, self.parent)
|
||||||
update=True,
|
self.willexecutors_list.update(wes)
|
||||||
bal_window=self.bal_window,
|
self.willexecutor_list.update()
|
||||||
force=True,
|
|
||||||
task=self,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.bal_window.ping_willexecutors(wes, self.parent)
|
|
||||||
self.willexecutors_list.update(wes)
|
|
||||||
self.willexecutor_list.update()
|
|
||||||
|
|
||||||
def import_json_file(self, path):
|
def import_json_file(self, path):
|
||||||
data = read_json_file(path)
|
data = read_json_file(path)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from PyQt6.QtWidgets import (
|
|||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt
|
||||||
from electrum.storage import WalletStorage
|
from electrum.storage import WalletStorage
|
||||||
from electrum.util import MyEncoder
|
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):
|
class WalletUtilityGUI(QMainWindow):
|
||||||
@@ -175,7 +175,7 @@ class WalletUtilityGUI(QMainWindow):
|
|||||||
|
|
||||||
if have_to_save:
|
if have_to_save:
|
||||||
try:
|
try:
|
||||||
save_wallet(json_wallet, storage)
|
save(json_wallet, storage)
|
||||||
self.log_message(f"SUCCESS: {message}")
|
self.log_message(f"SUCCESS: {message}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log_message(f"Save error: {str(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:
|
if utxo_str in prevout_to_spend:
|
||||||
balance += inputs[utxo_str][0][2].value_sats()
|
balance += inputs[utxo_str][0][2].value_sats()
|
||||||
utxo_to_spend.append(utxo)
|
utxo_to_spend.append(utxo)
|
||||||
|
|
||||||
if len(utxo_to_spend) > 0:
|
if len(utxo_to_spend) > 0:
|
||||||
change_addresses = wallet.get_change_addresses_for_new_transaction()
|
change_addresses = wallet.get_change_addresses_for_new_transaction()
|
||||||
out = PartialTxOutput.from_address_and_value(change_addresses[0], balance)
|
out = PartialTxOutput.from_address_and_value(change_addresses[0], balance)
|
||||||
@@ -428,7 +427,6 @@ class Will:
|
|||||||
if not inp_str in utxos_list:
|
if not inp_str in utxos_list:
|
||||||
if wallet:
|
if wallet:
|
||||||
height = Will.check_tx_height(w.tx, wallet)
|
height = Will.check_tx_height(w.tx, wallet)
|
||||||
print(type(height))
|
|
||||||
if height < 0:
|
if height < 0:
|
||||||
Will.set_invalidate(wid, willtree)
|
Will.set_invalidate(wid, willtree)
|
||||||
elif height == 0:
|
elif height == 0:
|
||||||
@@ -473,23 +471,16 @@ class Will:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def check_will(will, all_utxos, wallet, block_to_check, timestamp_to_check):
|
def check_will(will, all_utxos, wallet, block_to_check, timestamp_to_check):
|
||||||
print("check will2")
|
|
||||||
Will.add_willtree(will)
|
Will.add_willtree(will)
|
||||||
print("willtree")
|
|
||||||
utxos_list = Will.utxos_strs(all_utxos)
|
utxos_list = Will.utxos_strs(all_utxos)
|
||||||
print("utxo_list")
|
|
||||||
|
|
||||||
Will.check_invalidated(will, utxos_list, wallet)
|
Will.check_invalidated(will, utxos_list, wallet)
|
||||||
print("check invalidate")
|
|
||||||
|
|
||||||
all_inputs = Will.get_all_inputs(will, only_valid=True)
|
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)
|
all_inputs_min_locktime = Will.get_all_inputs_min_locktime(all_inputs)
|
||||||
print("min_locktime")
|
|
||||||
Will.check_will_expired(
|
Will.check_will_expired(
|
||||||
all_inputs_min_locktime, block_to_check, timestamp_to_check
|
all_inputs_min_locktime, block_to_check, timestamp_to_check
|
||||||
)
|
)
|
||||||
print("check expired")
|
|
||||||
|
|
||||||
all_inputs = Will.get_all_inputs(will, only_valid=True)
|
all_inputs = Will.get_all_inputs(will, only_valid=True)
|
||||||
|
|
||||||
@@ -507,9 +498,7 @@ class Will:
|
|||||||
wallet=False,
|
wallet=False,
|
||||||
callback_not_valid_tx=None,
|
callback_not_valid_tx=None,
|
||||||
):
|
):
|
||||||
print("is_will_valid")
|
|
||||||
Will.check_will(will, all_utxos, wallet, block_to_check, timestamp_to_check)
|
Will.check_will(will, all_utxos, wallet, block_to_check, timestamp_to_check)
|
||||||
print("check will")
|
|
||||||
if heirs:
|
if heirs:
|
||||||
if not Will.check_willexecutors_and_heirs(
|
if not Will.check_willexecutors_and_heirs(
|
||||||
will,
|
will,
|
||||||
@@ -665,11 +654,11 @@ class WillItem(Logger):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def set_status(self, status, value=True):
|
def set_status(self, status, value=True):
|
||||||
_logger.debug(
|
#_logger.trace(
|
||||||
"set status {} - {} {} -> {}".format(
|
# "set status {} - {} {} -> {}".format(
|
||||||
self._id, status, self.STATUS[status][1], value
|
# self._id, status, self.STATUS[status][1], value
|
||||||
)
|
# )
|
||||||
)
|
#)
|
||||||
if self.STATUS[status][1] == bool(value):
|
if self.STATUS[status][1] == bool(value):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -35,34 +35,34 @@ class Willexecutors:
|
|||||||
continue
|
continue
|
||||||
Willexecutors.initialize_willexecutor(willexecutors[w], w)
|
Willexecutors.initialize_willexecutor(willexecutors[w], w)
|
||||||
for w in to_del:
|
for w in to_del:
|
||||||
print("ERROR: WILLEXECUTOR TO DELETE:", w)
|
_logger.error("error Willexecutor to delete type:{} ", type(willexecutor[w]),w)
|
||||||
del willexecutors[w]
|
del willexecutors[w]
|
||||||
bal = bal_plugin.WILLEXECUTORS.default.get(constants.net.NET_NAME, {})
|
bal = bal_plugin.WILLEXECUTORS.default.get(constants.net.NET_NAME, {})
|
||||||
for bal_url, bal_executor in bal.items():
|
for bal_url, bal_executor in bal.items():
|
||||||
if not bal_url in willexecutors:
|
if not bal_url in willexecutors:
|
||||||
_logger.debug(f"force add {bal_url} willexecutor")
|
_logger.debug(f"force add {bal_url} willexecutor")
|
||||||
willexecutors[bal_url] = bal_executor
|
willexecutors[bal_url] = bal_executor
|
||||||
if update:
|
#if update:
|
||||||
found = False
|
# found = False
|
||||||
for url, we in willexecutors.items():
|
# for url, we in willexecutors.items():
|
||||||
if Willexecutors.is_selected(we):
|
# if Willexecutors.is_selected(we):
|
||||||
found = True
|
# found = True
|
||||||
if found or force:
|
# if found or force:
|
||||||
if bal_plugin.PING_WILLEXECUTORS.get() or force:
|
# if bal_plugin.PING_WILLEXECUTORS.get() or force:
|
||||||
ping_willexecutors = True
|
# ping_willexecutors = True
|
||||||
if bal_plugin.ASK_PING_WILLEXECUTORS.get() and not force:
|
# if bal_plugin.ASK_PING_WILLEXECUTORS.get() and not force:
|
||||||
if bal_window:
|
# if bal_window:
|
||||||
ping_willexecutors = bal_window.window.question(
|
# ping_willexecutors = bal_window.window.question(
|
||||||
_(
|
# _(
|
||||||
"Contact willexecutors servers to update payment informations?"
|
# "Contact willexecutors servers to update payment informations?"
|
||||||
)
|
# )
|
||||||
)
|
# )
|
||||||
|
|
||||||
if ping_willexecutors:
|
# if ping_willexecutors:
|
||||||
if task:
|
# if task:
|
||||||
bal_window.ping_willexecutors(willexecutors, task)
|
# bal_window.ping_willexecutors(willexecutors, task)
|
||||||
else:
|
# else:
|
||||||
bal_window.ping_willexecutors_task(willexecutors)
|
# bal_window.ping_willexecutors_task(willexecutors)
|
||||||
w_sorted = dict(
|
w_sorted = dict(
|
||||||
sorted(
|
sorted(
|
||||||
willexecutors.items(), key=lambda w: w[1].get("sort", 0), reverse=True
|
willexecutors.items(), key=lambda w: w[1].get("sort", 0), reverse=True
|
||||||
|
|||||||
Reference in New Issue
Block a user