This commit is contained in:
bitcoinafterlife 2025-08-29 17:06:47 -04:00
parent 2ec5d060d3
commit a9b50105a6
Signed by: bitcoinafterlife
GPG Key ID: FE756706E833E0D1
2 changed files with 34 additions and 47 deletions

78
qt.py
View File

@ -331,7 +331,6 @@ _logger = get_logger(__name__)
class Plugin(BalPlugin,Logger):
def __init__(self, parent, config, name):
Logger.__init__(self)
self.logger.info("INIT BALPLUGIN")
@ -764,14 +763,11 @@ class BalWindow(Logger):
def show_critical(self,text):
self.window.show_critical(text)
def init_heirs_to_locktime(self):
for heir in self.heirs:
h=self.heirs[heir]
self.heirs[heir]=[h[0],h[1],self.will_settings['locktime']]
def init_class_variables(self):
if not self.heirs:
raise NoHeirsException()
@ -858,6 +854,7 @@ class BalWindow(Logger):
return self.willitems
except Exception as e:
raise e
def show_transaction_real(
self,
tx: Transaction,
@ -968,7 +965,6 @@ class BalWindow(Logger):
password = self.get_wallet_password(message)
return password
def on_close(self):
try:
if not self.disable_plugin:
@ -1144,11 +1140,13 @@ class BalWindow(Logger):
else:
pinged.append(url)
def ping_willexecutors(self,wes):
def ping_willexecutors(self,wes,parent=None):
if not parent:
parent=self
def on_success(result):
del self.waiting_dialog
try:
self.willexecutor_dialog.willexecutor_list.update()
parent.willexecutor_list.update()
except Exception as e:
_logger.error(f"error updating willexecutors {e}")
pass
@ -1177,9 +1175,7 @@ def add_widget(grid,label,widget,row,help_):
grid.addWidget(widget,row,1)
grid.addWidget(HelpButton(help_),row,2)
class HeirsLockTimeEdit(QWidget):
valueEdited = pyqtSignal()
locktime_threshold = 50000000
def __init__(self, parent=None,default_index = 1):
@ -1244,7 +1240,6 @@ class HeirsLockTimeEdit(QWidget):
def set_locktime(self, x: Any,force=True) -> None:
self.editor.set_locktime(x,force)
class _LockTimeEditor:
min_allowed_value = NLOCKTIME_MIN
max_allowed_value = NLOCKTIME_MAX
@ -1264,9 +1259,7 @@ class _LockTimeEditor:
return False
return cls.min_allowed_value <= x <= cls.max_allowed_value
class LockTimeRawEdit(QLineEdit, _LockTimeEditor):
def __init__(self, parent=None,time_edit=None):
QLineEdit.__init__(self, parent)
self.setFixedWidth(14 * char_width_in_lineedit())
@ -1363,7 +1356,6 @@ class LockTimeHeightEdit(LockTimeRawEdit):
painter.setPen(ColorScheme.GRAY.as_color())
painter.drawText(textRect, int(Qt.AlignRight | Qt.AlignVCenter), "height")
def get_max_allowed_timestamp() -> int:
ts = NLOCKTIME_MAX
# Test if this value is within the valid timestamp limits (which is platform-dependent).
@ -1375,7 +1367,6 @@ def get_max_allowed_timestamp() -> int:
datetime.fromtimestamp(ts) # test if raises
return ts
class LockTimeDateEdit(QDateTimeEdit, _LockTimeEditor):
min_allowed_value = NLOCKTIME_BLOCKHEIGHT_MAX + 1
max_allowed_value = get_max_allowed_timestamp()
@ -1404,10 +1395,8 @@ class LockTimeDateEdit(QDateTimeEdit, _LockTimeEditor):
dt = datetime.fromtimestamp(x)
self.setDateTime(dt)
_NOT_GIVEN = object() # sentinel value
class PercAmountEdit(BTCAmountEdit):
def __init__(self, decimal_point, is_int=False, parent=None, *, max_amount=_NOT_GIVEN):
super().__init__(decimal_point, is_int, parent, max_amount=max_amount)
@ -1466,13 +1455,15 @@ class PercAmountEdit(BTCAmountEdit):
if len(self.text())==0:
painter.drawText(textRect, int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter), self.base_unit() + " or perc value")
class BalDialog(WindowModalDialog):
def __init__(self,parent,title=None, icon = 'bal32x32.png'):
#print("éééééééééééé")
#print(parent)
#print(dir(parent))
#print("éééééééééééééééééé")
self.parent=parent
WindowModalDialog.__init__(self,self.parent,title)
WindowModalDialog.__init__(self,parent,title)
#WindowModalDialog.__init__(self,parent)
self.setWindowIcon(read_bal_QIcon(icon))
class BalWizardDialog(BalDialog):
@ -1527,7 +1518,6 @@ class BalWizardDialog(BalDialog):
print("close event")
pass
class BalWizardWidget(QWidget):
title = None
message = None
@ -1588,7 +1578,6 @@ class BalWizardWidget(QWidget):
def validate(self):
return True
class BalWizardHeirsWidget(BalWizardWidget):
title="Bitcoin After Life Heirs"
message="Please add your heirs\n remember that 100% of wallet balance will be spent"
@ -1637,11 +1626,23 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
index = self.combo.currentIndex()
_logger.debug(f"selected index:{index}")
if index < 2:
willexecutors = Willexecutors.download_list(self.bal_window.bal_plugin)
if index < 1:
for we in willexecutors.values():
we['selected']=True
def on_success(willexecutors):
self.bal_window.willexecutors.update(willexecutors)
self.bal_window.ping_willexecutors(self.bal_window.willexecutors)
if index < 1:
for we in self.bal_window.willexecutors:
if self.bal_window.willexecutors[we]['status']==200:
self.bal_window.willexecutors[we]['selected']=True
Willexecutors.save(self.bal_window.bal_plugin,self.bal_window.willexecutors)
def on_failure(fail):
print(f"fail")
pass
task = partial(Willexecutors.download_list,self.bal_window.bal_plugin)
msg = _("Downloading Will-Executors list")
self.waiting_dialog = BalWaitingDialog(self.bal_window, msg, task, on_success, on_failure,exe=False)
self.waiting_dialog.exe()
elif index == 2:
#TODO import from file
pass
@ -1782,8 +1783,6 @@ class BalWaitingDialog(BalDialog):
def closeEvent(self,event):
self.thread.stop()
class BalBlockingWaitingDialog(BalDialog):
def __init__(self, bal_window: 'BalWindow', message: str, task: Callable[[], Any]):
BalDialog.__init__(self, bal_window, _("Please wait"))
@ -1812,10 +1811,6 @@ class bal_checkbox(QCheckBox):
variable.get()
self.stateChanged.connect(on_check)
class BalBuildWillDialog(BalDialog):
updatemessage=pyqtSignal()
def __init__(self,bal_window,parent=None):
@ -2140,13 +2135,9 @@ class BalBuildWillDialog(BalDialog):
def get_text(self):
return self.message_label.text()
def ThreadStopped(Exception):
pass
class HeirList(MyTreeView,MessageBoxMixin):
class Columns(MyTreeView.BaseColumnsEnum):
NAME = enum.auto()
ADDRESS = enum.auto()
@ -2670,8 +2661,6 @@ def read_bal_QIcon(icon_basename: str=DEFAULT_ICON) -> QIcon:
def read_bal_QPixmap(icon_basename: str=DEFAULT_ICON) -> QPixmap:
return QPixmap(icon_path(icon_basename))
class WillDetailDialog(BalDialog):
def __init__(self, bal_window):
@ -2823,7 +2812,6 @@ class WillWidget(QWidget):
hlayout.addWidget(detailw)
hlayout.addWidget(WillWidget(w,parent = parent))
class WillExecutorList(MyTreeView):
class Columns(MyTreeView.BaseColumnsEnum):
SELECTED = enum.auto()
@ -2997,7 +2985,6 @@ class WillExecutorList(MyTreeView):
except Exception as e:
_logger.error(e)
class WillExecutorWidget(QWidget,MessageBoxMixin):
def __init__(self,parent,bal_window,willexecutors=None):
self.bal_window=bal_window
@ -3070,9 +3057,9 @@ class WillExecutorWidget(QWidget,MessageBoxMixin):
def update_willexecutors(self,wes=None):
if not wes:
self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin, update = True, bal_window = self.bal_window,force=True)
self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin, update = True, bal_window = self.bal_window,force=True,task=self)
else:
self.bal_window.ping_willexecutors(wes)
self.bal_window.ping_willexecutors(wes,self.parent)
self.willexecutors_list.update(wes)
self.willexecutor_list.update()
@ -3091,11 +3078,12 @@ class WillExecutorWidget(QWidget,MessageBoxMixin):
Willexecutors.save(self.bal_window.bal_plugin, self.willexecutors_list)
class WillExecutorDialog(BalDialog,MessageBoxMixin):
def __init__(self, bal_window):
BalDialog.__init__(self,bal_window.window)
def __init__(self, bal_window,parent=None):
if not parent:
parent=bal_window.window
BalDialog.__init__(self,parent)
self.bal_plugin = bal_window.bal_plugin
self.config = self.bal_plugin.config
self.window = bal_window.window
self.bal_window = bal_window
self.willexecutors_list = Willexecutors.get_willexecutors(self.bal_plugin)

View File

@ -18,7 +18,6 @@ class Willexecutors:
def save(bal_plugin, willexecutors):
aw=bal_plugin.WILLEXECUTORS.get()
aw[constants.net.NET_NAME]=willexecutors
print("save",aw)
bal_plugin.WILLEXECUTORS.set(aw)
def get_willexecutors(bal_plugin, update = False,bal_window=False,force=False,task=True):
@ -46,7 +45,7 @@ class Willexecutors:
if ping_willexecutors:
if task:
bal_window.ping_willexecutors(willexecutors)
bal_window.ping_willexecutors(willexecutors,task)
else:
bal_window.ping_willexecutors_task(willexecutors)
w_sorted = dict(sorted(willexecutors.items(), key=lambda w:w[1].get('sort',0),reverse=True))