This commit is contained in:
bitcoinafterlife 2025-08-31 14:48:10 -04:00
parent b1b0338bc7
commit fd7e849158
Signed by: bitcoinafterlife
GPG Key ID: FE756706E833E0D1
2 changed files with 51 additions and 30 deletions

66
qt.py
View File

@ -1080,7 +1080,7 @@ class BalWindow(Logger):
willitems = {} willitems = {}
for k,v in data.items(): for k,v in data.items():
data[k]['tx']=tx_from_any(v['tx']) data[k]['tx']=tx_from_any(v['tx'])
willitems[k]=Will.WillItem(data[k],_id=k) willitems[k]=WillItem(data[k],_id=k)
self.update_will(willitems) self.update_will(willitems)
except Exception as e: except Exception as e:
raise e raise e
@ -1587,18 +1587,22 @@ class BalWizardHeirsWidget(BalWizardWidget):
self.heirs_list=HeirList(self.bal_window,self.parent) self.heirs_list=HeirList(self.bal_window,self.parent)
button_add=QPushButton(_("Add")) button_add=QPushButton(_("Add"))
button_add.clicked.connect(self.add_heir) button_add.clicked.connect(self.add_heir)
button_import=QPushButton(_("Import from file")) 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_import.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)
vbox.addLayout(Buttons(button_add,button_import)) vbox.addLayout(Buttons(button_add,button_import,button_export))
return widget return widget
def import_from_file(self): def import_from_file(self):
self.bal_window.import_heirs() self.bal_window.import_heirs()
self.heirs_list.update() self.heirs_list.update()
def export_to_file(self):
self.bal_window.export_heirs()
def add_heir(self): def add_heir(self):
self.bal_window.new_heir_dialog() self.bal_window.new_heir_dialog()
self.heirs_list.update() self.heirs_list.update()
@ -1623,30 +1627,37 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
def validate(self): def validate(self):
return True return True
def _on_next(self): def _on_next(self):
index = self.combo.currentIndex() index = self.combo.currentIndex()
_logger.debug(f"selected index:{index}") _logger.debug(f"selected index:{index}")
if index < 2: if index < 3:
def on_success(willexecutors): self.bal_window.willexecutors=Willexecutors.get_willexecutors(self.bal_window.bal_plugin)
self.bal_window.willexecutors=Willexecutors.get_willexecutors(self.bal_window.bal_plugin)
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) if index == 2:
msg = _("Downloading Will-Executors list") def doNothing():
self.waiting_dialog = BalWaitingDialog(self.bal_window, msg, task, on_success, on_failure,exe=False) self.bal_window.willexecutors.update(self.willexecutors)
self.waiting_dialog.exe() Willexecutors.save(self.bal_window.bal_plugin,self.bal_window.willexecutors)
pass
import_meta_gui(self.bal_window.window, _('willexecutors.json'), self.import_json_file, doNothing)
if index < 2:
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
elif index == 3: elif index == 3:
#TODO DO NOTHING #TODO DO NOTHING
pass pass
@ -1654,6 +1665,14 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
if self.validate(): if self.validate():
return self.on_next() return self.on_next()
def import_json_file(self, path):
data = read_json_file(path)
data = self._validate(data)
self.willexecutors=data
def _validate(self,data):
return data
class BalWizardWEWidget(BalWizardWidget): class BalWizardWEWidget(BalWizardWidget):
title=("Bitcoin After Life Will-Executors") title=("Bitcoin After Life Will-Executors")
message=_("Configure and select your willexecutors") message=_("Configure and select your willexecutors")
@ -2532,6 +2551,7 @@ class PreviewList(MyTreeView):
menu.addAction(_("Display"), self.bal_window.preview_modal_dialog) menu.addAction(_("Display"), self.bal_window.preview_modal_dialog)
menu.addAction(_("Sign"), self.ask_password_and_sign_transactions) menu.addAction(_("Sign"), self.ask_password_and_sign_transactions)
menu.addAction(_("Export"), self.export_will) menu.addAction(_("Export"), self.export_will)
menu.addAction(_("Import"), self.import_will)
menu.addAction(_("Broadcast"), self.broadcast) menu.addAction(_("Broadcast"), self.broadcast)
menu.addAction(_("Check"), self.check) menu.addAction(_("Check"), self.check)
menu.addAction(_("Invalidate"), self.invalidate_will) menu.addAction(_("Invalidate"), self.invalidate_will)

13
will.py
View File

@ -15,8 +15,8 @@ MIN_LOCKTIME = 1
MIN_BLOCK = 1 MIN_BLOCK = 1
_logger = get_logger(__name__) _logger = get_logger(__name__)
#return an array with the list of children
class Will: class Will:
#return an array with the list of children
def get_children(will,willid): def get_children(will,willid):
out = [] out = []
for _id in will: for _id in will:
@ -744,10 +744,11 @@ class WillItem(Logger):
else: else:
return "#ffffff" return "#ffffff"
class WillException(Exception):
class WillExpiredException(Exception):
pass pass
class NotCompleteWillException(Exception): class WillExpiredException(WillException):
pass
class NotCompleteWillException(WillException):
pass pass
class HeirChangeException(NotCompleteWillException): class HeirChangeException(NotCompleteWillException):
pass pass
@ -761,9 +762,9 @@ class NoWillExecutorNotPresent(NotCompleteWillException):
pass pass
class WillExecutorNotPresent(NotCompleteWillException): class WillExecutorNotPresent(NotCompleteWillException):
pass pass
class NoHeirsException(Exception): class NoHeirsException(WillException):
pass pass
class AmountException(Exception): class AmountException(WillException):
pass pass
class PercAmountException(AmountException): class PercAmountException(AmountException):
pass pass