Compare commits
6 Commits
461b0cb368
...
v0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
7c1fc04add
|
|||
|
fd7e849158
|
|||
|
b1b0338bc7
|
|||
|
a9b50105a6
|
|||
|
2ec5d060d3
|
|||
|
29c63fc5c8
|
19
__init__.py
19
__init__.py
@@ -1,20 +1 @@
|
||||
from electrum.i18n import _
|
||||
import subprocess
|
||||
from . import bal_resources
|
||||
BUILD_NUMBER = 3
|
||||
REVISION_NUMBER = 2
|
||||
VERSION_NUMBER = 0
|
||||
def _version():
|
||||
return f'{VERSION_NUMBER}.{REVISION_NUMBER}-{BUILD_NUMBER}'
|
||||
|
||||
version = _version()
|
||||
author = "Bal Enterprise inc."
|
||||
fullname = _('B.A.L.')
|
||||
description = ''.join([
|
||||
"<img src='",bal_resources.icon_path('bal16x16.png'),"'>", _("Bitcoin After Life"), '<br/>',
|
||||
_("For more information, visit"),
|
||||
" <a href=\"https://bitcoin-after.life/\">https://bitcoin-after.life/</a><br/>",
|
||||
"<p style='font-size:8pt;vertialAlign:bottom'>Version: ", _version(),"</p>"
|
||||
])
|
||||
#available_for = ['qt', 'cmdline', 'qml']
|
||||
available_for = ['qt']
|
||||
|
||||
53
bal.py
53
bal.py
@@ -1,5 +1,6 @@
|
||||
import random
|
||||
import os
|
||||
import zipfile as zipfile_lib
|
||||
|
||||
from electrum.plugin import BasePlugin
|
||||
from electrum import json_db
|
||||
@@ -31,7 +32,7 @@ class BalConfig():
|
||||
if not default is None:
|
||||
v = default
|
||||
else:
|
||||
v = v.default
|
||||
v = self.default
|
||||
return v
|
||||
|
||||
def set(self,value,save=True):
|
||||
@@ -56,31 +57,39 @@ class BalPlugin(BasePlugin):
|
||||
BasePlugin.__init__(self, parent, config, name)
|
||||
self.base_dir = os.path.join(config.electrum_path(), 'bal')
|
||||
self.plugin_dir = os.path.split(os.path.realpath(__file__))[0]
|
||||
self.logger.info(self.base_dir)
|
||||
|
||||
zipfile="/".join(self.plugin_dir.split("/")[:-1])
|
||||
#print("real path",os.path.realpath(__file__))
|
||||
#self.logger.info(self.base_dir)
|
||||
#print("base_dir:", self.base_dir)
|
||||
#print("suca:",zipfile)
|
||||
#print("plugin_dir:", self.plugin_dir)
|
||||
import sys
|
||||
sys.path.insert(0, zipfile)
|
||||
#print("sono state listate?")
|
||||
self.parent = parent
|
||||
self.config = config
|
||||
self.name = name
|
||||
|
||||
self.ASK_BROADCAST = BalConfig(config, "bal_ask_broadcast",True)
|
||||
self.BROADCAST = BalConfig(config, "bal_broadcast",True)
|
||||
self.LOCKTIME_TIME = BalConfig(config, "bal_locktime_time",90)
|
||||
self.LOCKTIME_BLOCKS = BalConfig(config, "bal_locktime_blocks",144*90)
|
||||
self.LOCKTIMEDELTA_TIME = BalConfig(config, "bal_locktimedelta_time",7)
|
||||
self.LOCKTIMEDELTA_BLOCKS = BalConfig(config, "bal_locktimedelta_blocks",144*7)
|
||||
self.TX_FEES = BalConfig(config, "bal_tx_fees",100)
|
||||
self.INVALIDATE = BalConfig(config, "bal_invalidate",True)
|
||||
self.ASK_INVALIDATE = BalConfig(config, "bal_ask_invalidate",True)
|
||||
self.PREVIEW = BalConfig(config, "bal_preview",True)
|
||||
self.SAVE_TXS = BalConfig(config, "bal_save_txs",True)
|
||||
self.WILLEXECUTORS = BalConfig(config, "bal_willexecutors",True)
|
||||
self.PING_WILLEXECUTORS = BalConfig(config, "bal_ping_willexecutors",True)
|
||||
self.ASK_PING_WILLEXECUTORS = BalConfig(config, "bal_ask_ping_willexecutors",True)
|
||||
self.NO_WILLEXECUTOR = BalConfig(config, "bal_no_willexecutor",True)
|
||||
self.HIDE_REPLACED = BalConfig(config, "bal_hide_replaced",True)
|
||||
self.HIDE_INVALIDATED = BalConfig(config, "bal_hide_invalidated",True)
|
||||
self.ALLOW_REPUSH = BalConfig(config, "bal_allow_repush",True)
|
||||
self.FIRST_EXECUTION = BalConfig(config, "bal_first_execution",True)
|
||||
self.ASK_BROADCAST = BalConfig(config, "bal_ask_broadcast", True)
|
||||
self.BROADCAST = BalConfig(config, "bal_broadcast", True)
|
||||
self.LOCKTIME_TIME = BalConfig(config, "bal_locktime_time", 90)
|
||||
self.LOCKTIME_BLOCKS = BalConfig(config, "bal_locktime_blocks", 144*90)
|
||||
self.LOCKTIMEDELTA_TIME = BalConfig(config, "bal_locktimedelta_time", 7)
|
||||
self.LOCKTIMEDELTA_BLOCKS = BalConfig(config, "bal_locktimedelta_blocks", 144*7)
|
||||
self.ENABLE_MULTIVERSE = BalConfig(config, "bal_enable_multiverse", False)
|
||||
self.TX_FEES = BalConfig(config, "bal_tx_fees", 100)
|
||||
self.INVALIDATE = BalConfig(config, "bal_invalidate", True)
|
||||
self.ASK_INVALIDATE = BalConfig(config, "bal_ask_invalidate", True)
|
||||
self.PREVIEW = BalConfig(config, "bal_preview", True)
|
||||
self.SAVE_TXS = BalConfig(config, "bal_save_txs", True)
|
||||
self.WILLEXECUTORS = BalConfig(config, "bal_willexecutors", True)
|
||||
self.PING_WILLEXECUTORS = BalConfig(config, "bal_ping_willexecutors", True)
|
||||
self.ASK_PING_WILLEXECUTORS = BalConfig(config, "bal_ask_ping_willexecutors", True)
|
||||
self.NO_WILLEXECUTOR = BalConfig(config, "bal_no_willexecutor", True)
|
||||
self.HIDE_REPLACED = BalConfig(config, "bal_hide_replaced", True)
|
||||
self.HIDE_INVALIDATED = BalConfig(config, "bal_hide_invalidated", True)
|
||||
self.ALLOW_REPUSH = BalConfig(config, "bal_allow_repush", True)
|
||||
self.FIRST_EXECUTION = BalConfig(config, "bal_first_execution", True)
|
||||
self.WILLEXECUTORS = BalConfig(config, "bal_willexecutors", {
|
||||
"mainnet": {
|
||||
'https://we.bitcoin-after.life': {
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
|
||||
PLUGIN_DIR = os.path.split(os.path.realpath(__file__))[0]
|
||||
DEFAULT_ICON = 'bal32x32.png'
|
||||
DEFAULT_ICON_PATH = 'icons'
|
||||
DEFAULT_ICON_PATH = ''
|
||||
|
||||
|
||||
def icon_path(icon_basename: str = DEFAULT_ICON):
|
||||
|
||||
8
heirs.py
8
heirs.py
@@ -563,10 +563,7 @@ class Heirs(dict, Logger):
|
||||
|
||||
def validate_amount(amount):
|
||||
try:
|
||||
if Util.is_perc(amount):
|
||||
famount = float(amount[:-1])
|
||||
else:
|
||||
famount = float(amount)
|
||||
famount = float(amount[:-1]) if Util.is_perc(amount) else float(amount)
|
||||
if famount <= 0.00000001:
|
||||
raise AmountNotValid(f"amount have to be positive {famount} < 0")
|
||||
except Exception as e:
|
||||
@@ -575,9 +572,8 @@ class Heirs(dict, Logger):
|
||||
|
||||
def validate_locktime(locktime,timestamp_to_check=False):
|
||||
try:
|
||||
locktime = Util.parse_locktime_string(locktime,None)
|
||||
if timestamp_to_check:
|
||||
if locktime < timestamp_to_check:
|
||||
if Util.parse_locktime_string(locktime,None) < timestamp_to_check:
|
||||
raise HeirExpiredException()
|
||||
except Exception as e:
|
||||
raise LocktimeNotValid(f"locktime string not properly formatted, {e}")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "BAL",
|
||||
"fullname": "Bitcoin After Life",
|
||||
"description": "Provides free and decentralized inheritance support<br> Version: 0.2.1b",
|
||||
"description": "Provides free and decentralized inheritance support<br> Version: 0.2.2a",
|
||||
"author":"Svatantrya",
|
||||
"available_for": ["qt"],
|
||||
"icon":"icons/bal32x32.png"
|
||||
|
||||
289
qt.py
289
qt.py
@@ -259,6 +259,8 @@ from electrum.gui.qt.util import (
|
||||
TaskThread,
|
||||
WindowModalDialog,
|
||||
WWLabel,
|
||||
read_QIcon_from_bytes,
|
||||
read_QPixmap_from_bytes,
|
||||
)
|
||||
from electrum.gui.qt.main_window import StatusBarButton
|
||||
from electrum.gui.qt.my_treeview import (
|
||||
@@ -331,7 +333,6 @@ _logger = get_logger(__name__)
|
||||
|
||||
|
||||
class Plugin(BalPlugin,Logger):
|
||||
|
||||
def __init__(self, parent, config, name):
|
||||
Logger.__init__(self)
|
||||
self.logger.info("INIT BALPLUGIN")
|
||||
@@ -373,7 +374,7 @@ class Plugin(BalPlugin,Logger):
|
||||
def create_status_bar(self, sb):
|
||||
self.logger.info("HOOK create status bar")
|
||||
return
|
||||
b = StatusBarButton(read_bal_QIcon('bal32x32.png'), "Bal "+_("Bitcoin After Life"),
|
||||
b = StatusBarButton(read_QIcon_from_bytes(self.bal_plugin.read_file('bal32x32.png')), "Bal "+_("Bitcoin After Life"),
|
||||
partial(self.setup_dialog, sb), sb.height())
|
||||
sb.addPermanentWidget(b)
|
||||
|
||||
@@ -437,9 +438,9 @@ class Plugin(BalPlugin,Logger):
|
||||
|
||||
def settings_dialog(self,window,wallet):
|
||||
|
||||
d = BalDialog(window, self.get_window_title("Settings"))
|
||||
d = BalDialog(window,self,self.get_window_title("Settings"))
|
||||
d.setMinimumSize(100, 200)
|
||||
qicon=read_bal_QPixmap("bal32x32.png")
|
||||
qicon=read_QPixmap_from_bytes(self.read_file("bal32x32.png"))
|
||||
lbl_logo = QLabel()
|
||||
lbl_logo.setPixmap(qicon)
|
||||
|
||||
@@ -447,10 +448,15 @@ class Plugin(BalPlugin,Logger):
|
||||
heir_ask_ping_willexecutors = bal_checkbox(self.ASK_PING_WILLEXECUTORS)
|
||||
heir_no_willexecutor = bal_checkbox(self.NO_WILLEXECUTOR)
|
||||
|
||||
def on_multiverse_change():
|
||||
self.update_all()
|
||||
|
||||
heir_hide_replaced = bal_checkbox(self.HIDE_REPLACED,self)
|
||||
#heir_enable_multiverse = bal_checkbox(self.ENABLE_MULTIVERSE,on_multiverse_change)
|
||||
|
||||
heir_hide_replaced = bal_checkbox(self.HIDE_REPLACED,on_multiverse_change)
|
||||
|
||||
heir_hide_invalidated = bal_checkbox(self.HIDE_INVALIDATED,on_multiverse_change)
|
||||
|
||||
heir_hide_invalidated = bal_checkbox(self.HIDE_INVALIDATED,self)
|
||||
heir_repush = QPushButton("Rebroadcast transactions")
|
||||
heir_repush.clicked.connect(partial(self.broadcast_transactions,True))
|
||||
grid=QGridLayout(d)
|
||||
@@ -459,8 +465,9 @@ class Plugin(BalPlugin,Logger):
|
||||
add_widget(grid,"Ping Willexecutors",heir_ping_willexecutors,3,"Ping willexecutors to get payment info before compiling will")
|
||||
add_widget(grid," - Ask before",heir_ask_ping_willexecutors,4,"Ask before to ping willexecutor")
|
||||
add_widget(grid,"Backup Transaction",heir_no_willexecutor,5,"Add transactions without willexecutor")
|
||||
grid.addWidget(heir_repush,6,0)
|
||||
grid.addWidget(HelpButton("Broadcast all transactions to willexecutors including those already pushed"),6,2)
|
||||
#add_widget(grid,"Enable Multiverse(EXPERIMENTAL/BROKEN)",heir_enable_multiverse,6,"enable multiple locktimes, will import.... ")
|
||||
grid.addWidget(heir_repush,7,0)
|
||||
grid.addWidget(HelpButton("Broadcast all transactions to willexecutors including those already pushed"),7,2)
|
||||
|
||||
if ret := bool(d.exec()):
|
||||
try:
|
||||
@@ -527,8 +534,8 @@ class BalWindow(Logger):
|
||||
|
||||
|
||||
|
||||
add_optional_tab(self.window.tabs, self.heirs_tab, read_bal_QIcon("heir.png"), _("&Heirs"))
|
||||
add_optional_tab(self.window.tabs, self.will_tab, read_bal_QIcon("will.png"), _("&Will"))
|
||||
add_optional_tab(self.window.tabs, self.heirs_tab, read_QIcon_from_bytes(self.bal_plugin.read_file("heir.png")), _("&Heirs"))
|
||||
add_optional_tab(self.window.tabs, self.will_tab, read_QIcon_from_bytes(self.bal_plugin.read_file("will.png")), _("&Will"))
|
||||
tools_menu.addSeparator()
|
||||
self.tools_menu.willexecutors_action = tools_menu.addAction(_("&Will-Executors"), self.show_willexecutor_dialog)
|
||||
self.window.view_menu.addSeparator()
|
||||
@@ -600,26 +607,34 @@ class BalWindow(Logger):
|
||||
tab.is_shown_cv = shown_cv(True)
|
||||
return tab
|
||||
|
||||
def new_heir_dialog(self,heir=None):
|
||||
d = BalDialog(self.window, self.bal_plugin.get_window_title("New heir"))
|
||||
def new_heir_dialog(self,heir_key=None):
|
||||
heir = self.heirs.get(heir_key)
|
||||
title = "New heir"
|
||||
if heir:
|
||||
title = f"Edit: {heir_key}"
|
||||
|
||||
d = BalDialog(self.window, self.bal_plugin,self.bal_plugin.get_window_title(_(title)))
|
||||
|
||||
vbox = QVBoxLayout(d)
|
||||
grid = QGridLayout()
|
||||
|
||||
heir_name = QLineEdit()
|
||||
heir_name.setFixedWidth(32 * char_width_in_lineedit())
|
||||
if heir:
|
||||
heir_name.setText(heir[0])
|
||||
heir_name.setText(str(heir_key))
|
||||
heir_address = QLineEdit()
|
||||
heir_address.setFixedWidth(32 * char_width_in_lineedit())
|
||||
if heir:
|
||||
heir_address.setText(heir[1])
|
||||
heir_address.setText(str(heir[0]))
|
||||
heir_amount = PercAmountEdit(self.window.get_decimal_point)
|
||||
if heir:
|
||||
heir_amount.setText(heir[2])
|
||||
heir_amount.setText(str(Util.decode_amount(heir[1],self.bal_plugin.config.get_decimal_point())))
|
||||
heir_locktime = HeirsLockTimeEdit(self.window,0)
|
||||
if heir:
|
||||
heir_locktime.setText(heir[3])
|
||||
heir_locktime.set_locktime(heir[2])
|
||||
|
||||
heir_is_xpub = QCheckBox()
|
||||
|
||||
new_heir_button=QPushButton(_("Add another heir"))
|
||||
self.add_another_heir=False
|
||||
def new_heir():
|
||||
@@ -631,18 +646,28 @@ class BalWindow(Logger):
|
||||
|
||||
grid.addWidget(QLabel(_("Name")), 1, 0)
|
||||
grid.addWidget(heir_name, 1, 1)
|
||||
grid.addWidget(HelpButton("Unique name or description about heir"),1,2)
|
||||
grid.addWidget(HelpButton(_("Unique name or description about heir")),1,2)
|
||||
|
||||
grid.addWidget(QLabel(_("Address")), 2, 0)
|
||||
grid.addWidget(heir_address, 2, 1)
|
||||
grid.addWidget(HelpButton("heir bitcoin address"),2,2)
|
||||
grid.addWidget(HelpButton(_("heir bitcoin address")),2,2)
|
||||
|
||||
grid.addWidget(QLabel(_("Amount")),3,0)
|
||||
grid.addWidget(heir_amount,3,1)
|
||||
grid.addWidget(HelpButton("Fixed or Percentage amount if end with %"),3,2)
|
||||
grid.addWidget(HelpButton(_("Fixed or Percentage amount if end with %")),3,2)
|
||||
|
||||
locktime_label=QLabel(_("Locktime"))
|
||||
enable_multiverse=self.bal_plugin.ENABLE_MULTIVERSE.get()
|
||||
if enable_multiverse:
|
||||
grid.addWidget(locktime_label,4,0)
|
||||
grid.addWidget(heir_locktime,4,1)
|
||||
grid.addWidget(HelpButton(_("locktime")),4,2)
|
||||
|
||||
vbox.addLayout(grid)
|
||||
vbox.addLayout(Buttons(CancelButton(d), OkButton(d),new_heir_button))
|
||||
buttons=[CancelButton(d), OkButton(d)]
|
||||
if not heir:
|
||||
buttons.append(new_heir_button)
|
||||
vbox.addLayout(Buttons(*buttons))
|
||||
while d.exec():
|
||||
#TODO SAVE HEIR
|
||||
heir = [
|
||||
@@ -669,6 +694,7 @@ class BalWindow(Logger):
|
||||
|
||||
def set_heir(self,heir):
|
||||
heir=list(heir)
|
||||
if not self.bal_plugin.ENABLE_MULTIVERSE.get():
|
||||
heir[3]=self.will_settings['locktime']
|
||||
|
||||
h=Heirs.validate_heir(heir[0],heir[1:])
|
||||
@@ -711,6 +737,7 @@ class BalWindow(Logger):
|
||||
self.willexecutors = Willexecutors.get_willexecutors(self.bal_plugin, update=False, bal_window=self)
|
||||
|
||||
if not self.no_willexecutor:
|
||||
|
||||
f=False
|
||||
for u,w in self.willexecutors.items():
|
||||
if Willexecutors.is_selected(w):
|
||||
@@ -753,14 +780,12 @@ class BalWindow(Logger):
|
||||
def show_critical(self,text):
|
||||
self.window.show_critical(text)
|
||||
|
||||
|
||||
|
||||
def init_heirs_to_locktime(self):
|
||||
def init_heirs_to_locktime(self,multiverse=False):
|
||||
for heir in self.heirs:
|
||||
h=self.heirs[heir]
|
||||
if not multiverse:
|
||||
self.heirs[heir]=[h[0],h[1],self.will_settings['locktime']]
|
||||
|
||||
|
||||
def init_class_variables(self):
|
||||
if not self.heirs:
|
||||
raise NoHeirsException()
|
||||
@@ -773,7 +798,7 @@ class BalWindow(Logger):
|
||||
self.block_to_check = self.current_block + self.locktime_blocks
|
||||
self.no_willexecutor = self.bal_plugin.NO_WILLEXECUTOR.get()
|
||||
self.willexecutors = Willexecutors.get_willexecutors(self.bal_plugin,update=True,bal_window=self,task=False)
|
||||
self.init_heirs_to_locktime()
|
||||
self.init_heirs_to_locktime(self.bal_plugin.ENABLE_MULTIVERSE.get())
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(e)
|
||||
@@ -847,6 +872,7 @@ class BalWindow(Logger):
|
||||
return self.willitems
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
def show_transaction_real(
|
||||
self,
|
||||
tx: Transaction,
|
||||
@@ -864,7 +890,7 @@ class BalWindow(Logger):
|
||||
external_keypairs=external_keypairs,
|
||||
#payment_identifier=payment_identifier,
|
||||
)
|
||||
d.setWindowIcon(read_bal_QIcon("bal32x32.png"))
|
||||
d.setWindowIcon(read_QIcon_from_bytes(self.bal_plugin.read_file("bal32x32.png")))
|
||||
except SerializationError as e:
|
||||
self.logger.error('unable to deserialize the transaction')
|
||||
parent.show_critical(_("Electrum was unable to deserialize the transaction:") + "\n" + str(e))
|
||||
@@ -957,7 +983,6 @@ class BalWindow(Logger):
|
||||
password = self.get_wallet_password(message)
|
||||
return password
|
||||
|
||||
|
||||
def on_close(self):
|
||||
try:
|
||||
if not self.disable_plugin:
|
||||
@@ -1073,7 +1098,7 @@ class BalWindow(Logger):
|
||||
willitems = {}
|
||||
for k,v in data.items():
|
||||
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)
|
||||
except Exception as e:
|
||||
raise e
|
||||
@@ -1133,13 +1158,15 @@ 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("error updating willexecutors {e}")
|
||||
_logger.error(f"error updating willexecutors {e}")
|
||||
pass
|
||||
def on_failure(e):
|
||||
self.logger.error(e)
|
||||
@@ -1166,9 +1193,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):
|
||||
@@ -1201,6 +1226,11 @@ class HeirsLockTimeEdit(QWidget):
|
||||
for w in self.editors:
|
||||
hbox.addWidget(w)
|
||||
hbox.addStretch(1)
|
||||
#spacer_widget = QWidget()
|
||||
#spacer_widget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
#hbox.addWidget(spacer_widget)
|
||||
|
||||
|
||||
|
||||
self.locktime_raw_e.editingFinished.connect(self.valueEdited.emit)
|
||||
self.locktime_date_e.dateTimeChanged.connect(self.valueEdited.emit)
|
||||
@@ -1227,7 +1257,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
|
||||
@@ -1247,9 +1276,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())
|
||||
@@ -1346,7 +1373,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).
|
||||
@@ -1358,7 +1384,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()
|
||||
@@ -1387,10 +1412,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)
|
||||
@@ -1449,19 +1472,17 @@ 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'):
|
||||
def __init__(self,parent,bal_plugin,title=None, icon = 'bal32x32.png'):
|
||||
self.parent=parent
|
||||
WindowModalDialog.__init__(self,self.parent,title)
|
||||
self.setWindowIcon(read_bal_QIcon(icon))
|
||||
WindowModalDialog.__init__(self,parent,title)
|
||||
#WindowModalDialog.__init__(self,parent)
|
||||
self.setWindowIcon(read_QIcon_from_bytes(bal_plugin.read_file(icon)))
|
||||
|
||||
class BalWizardDialog(BalDialog):
|
||||
def __init__(self,bal_window: 'BalWindow' ):
|
||||
assert bal_window
|
||||
BalDialog.__init__(self, bal_window.window, _("Bal Wizard Setup"))
|
||||
BalDialog.__init__(self, bal_window.window, bal_window.bal_plugin, _("Bal Wizard Setup"))
|
||||
self.setMinimumSize(800, 400)
|
||||
self.bal_window = bal_window
|
||||
self.parent = bal_window.window
|
||||
@@ -1496,16 +1517,15 @@ class BalWizardDialog(BalDialog):
|
||||
def on_next_locktimeandfee(self):
|
||||
self.next_widget(BalWizardWEDownloadWidget(self.bal_window,self,self.on_next_wedonwload,self.on_next_heir,self.on_cancel_heir))
|
||||
def on_accept(self):
|
||||
print("accepted")
|
||||
pass
|
||||
def on_reject(self):
|
||||
print("rejected")
|
||||
pass
|
||||
def on_close(self):
|
||||
print("close")
|
||||
pass
|
||||
def closeEvent(self,event):
|
||||
self.bal_window.update_all()
|
||||
self.bal_window.heir_list.update_will_settings()
|
||||
print("close event")
|
||||
|
||||
pass
|
||||
|
||||
class BalWizardWidget(QWidget):
|
||||
title = None
|
||||
@@ -1567,7 +1587,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"
|
||||
@@ -1577,18 +1596,22 @@ class BalWizardHeirsWidget(BalWizardWidget):
|
||||
self.heirs_list=HeirList(self.bal_window,self.parent)
|
||||
button_add=QPushButton(_("Add"))
|
||||
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_export=QPushButton(_("Export"))
|
||||
button_import.clicked.connect(self.export_to_file)
|
||||
widget=QWidget()
|
||||
vbox=QVBoxLayout(widget)
|
||||
vbox.addWidget(self.heirs_list)
|
||||
vbox.addLayout(Buttons(button_add,button_import))
|
||||
vbox.addLayout(Buttons(button_add,button_import,button_export))
|
||||
return widget
|
||||
|
||||
|
||||
def import_from_file(self):
|
||||
self.bal_window.import_heirs()
|
||||
self.heirs_list.update()
|
||||
def export_to_file(self):
|
||||
self.bal_window.export_heirs()
|
||||
def add_heir(self):
|
||||
self.bal_window.new_heir_dialog()
|
||||
self.heirs_list.update()
|
||||
@@ -1613,17 +1636,37 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
|
||||
def validate(self):
|
||||
return True
|
||||
def _on_next(self):
|
||||
|
||||
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
|
||||
if index < 3:
|
||||
self.bal_window.willexecutors=Willexecutors.get_willexecutors(self.bal_window.bal_plugin)
|
||||
|
||||
elif index == 2:
|
||||
#TODO import from file
|
||||
if index == 2:
|
||||
def doNothing():
|
||||
self.bal_window.willexecutors.update(self.willexecutors)
|
||||
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):
|
||||
_logger.debug(f"Failed to download willexecutors list {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 == 3:
|
||||
#TODO DO NOTHING
|
||||
pass
|
||||
@@ -1631,6 +1674,14 @@ class BalWizardWEDownloadWidget(BalWizardWidget):
|
||||
if self.validate():
|
||||
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):
|
||||
title=("Bitcoin After Life Will-Executors")
|
||||
message=_("Configure and select your willexecutors")
|
||||
@@ -1685,6 +1736,10 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
|
||||
hlayout.addWidget(QLabel(label))
|
||||
hlayout.addWidget(twidget)
|
||||
hlayout.addWidget(HelpButton(help_text))
|
||||
hlayout.addStretch(1)
|
||||
spacer_widget = QWidget()
|
||||
spacer_widget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
hlayout.addWidget(spacer_widget)
|
||||
return tw
|
||||
|
||||
|
||||
@@ -1712,7 +1767,7 @@ class BalWaitingDialog(BalDialog):
|
||||
updatemessage=pyqtSignal([str], arguments=['message'])
|
||||
def __init__(self, bal_window: 'BalWindow', message: str, task, on_success=None, on_error=None, on_cancel=None,exe=True):
|
||||
assert bal_window
|
||||
BalDialog.__init__(self, bal_window.window, _("Please wait"))
|
||||
BalDialog.__init__(self, bal_window.window,bal_window.bal_plugin, _("Please wait"))
|
||||
self.message_label = QLabel(message)
|
||||
vbox = QVBoxLayout(self)
|
||||
vbox.addWidget(self.message_label)
|
||||
@@ -1757,11 +1812,9 @@ 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"))
|
||||
BalDialog.__init__(self, bal_window, bal_window.bal_plugin,_("Please wait"))
|
||||
self.message_label = QLabel(message)
|
||||
vbox = QVBoxLayout(self)
|
||||
vbox.addWidget(self.message_label)
|
||||
@@ -1779,24 +1832,23 @@ class BalBlockingWaitingDialog(BalDialog):
|
||||
self.accept()
|
||||
|
||||
class bal_checkbox(QCheckBox):
|
||||
def __init__(self, variable,window=None):
|
||||
def __init__(self, variable,on_click=None):
|
||||
QCheckBox.__init__(self)
|
||||
self.setChecked(variable.get())
|
||||
self.on_click=on_click
|
||||
def on_check(v):
|
||||
variable.set(v == 2)
|
||||
variable.get()
|
||||
if self.on_click:
|
||||
self.on_click()
|
||||
self.stateChanged.connect(on_check)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BalBuildWillDialog(BalDialog):
|
||||
updatemessage=pyqtSignal()
|
||||
def __init__(self,bal_window,parent=None):
|
||||
if not parent:
|
||||
parent = bal_window.window
|
||||
BalDialog.__init__(self,parent,"Building Will")
|
||||
BalDialog.__init__(self,parent,babl_window.bal_plugin, "Building Will")
|
||||
self.updatemessage.connect(self.update)
|
||||
self.bal_window=bal_window
|
||||
self.message_label = QLabel("Building Will:")
|
||||
@@ -2115,13 +2167,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()
|
||||
@@ -2161,6 +2209,13 @@ class HeirList(MyTreeView,MessageBoxMixin):
|
||||
|
||||
self.update()
|
||||
|
||||
def on_activated(self,idx):
|
||||
self.on_double_click(idx)
|
||||
|
||||
def on_double_click(self,idx):
|
||||
edit_key = self.get_edit_key_from_coordinate(idx.row(),idx.column())
|
||||
heir= self.bal_window.heirs.get(edit_key)
|
||||
self.bal_window.new_heir_dialog(edit_key)
|
||||
|
||||
def on_edited(self, idx, edit_key, *, text):
|
||||
original = prior_name = self.bal_window.heirs.get(edit_key)
|
||||
@@ -2331,7 +2386,7 @@ class HeirList(MyTreeView,MessageBoxMixin):
|
||||
self.heir_threshold.set_locktime(self.bal_window.will_settings['threshold'])
|
||||
|
||||
except Exception as e:
|
||||
print("Exception update_will_settings",e)
|
||||
_logger.error(f"Exception update_will_settings {e}")
|
||||
|
||||
def build_transactions(self):
|
||||
will = self.bal_window.prepare_will()
|
||||
@@ -2379,6 +2434,13 @@ class PreviewList(MyTreeView):
|
||||
self.bal_plugin=self.bal_window.bal_plugin
|
||||
|
||||
self.update()
|
||||
def on_activated(self,idx):
|
||||
self.on_double_click(idx)
|
||||
|
||||
def on_double_click(self,idx):
|
||||
idx = self.model().index(idx.row(), self.Columns.TXID)
|
||||
sel_key = self.model().itemFromIndex(idx).data(0)
|
||||
self.show_transaction([sel_key])
|
||||
|
||||
def create_menu(self, position):
|
||||
menu = QMenu()
|
||||
@@ -2443,6 +2505,17 @@ class PreviewList(MyTreeView):
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
try:
|
||||
self.menu.removeAction(self.importaction)
|
||||
except Exception as e:
|
||||
pass
|
||||
finally:
|
||||
if self.bal_plugin.ENABLE_MULTIVERSE.get():
|
||||
try:
|
||||
self.importaction=self.menu.addAction(_("Import"), self.import_will)
|
||||
except Exception as ex:
|
||||
pass
|
||||
|
||||
if self.will is None:
|
||||
return
|
||||
|
||||
@@ -2460,8 +2533,11 @@ class PreviewList(MyTreeView):
|
||||
if self.bal_window.bal_plugin._hide_invalidated and bal_tx.get_status('INVALIDATED'):
|
||||
continue
|
||||
|
||||
if not isinstance(bal_tx,WillItem):
|
||||
bal_tx=WillItem(bal_tx)
|
||||
|
||||
tx=bal_tx.tx
|
||||
|
||||
labels = [""] * len(self.Columns)
|
||||
labels[self.Columns.LOCKTIME] = Util.locktime_to_str(tx.locktime)
|
||||
labels[self.Columns.TXID] = txid
|
||||
@@ -2501,33 +2577,29 @@ class PreviewList(MyTreeView):
|
||||
menu.addAction(_("Display"), self.bal_window.preview_modal_dialog)
|
||||
menu.addAction(_("Sign"), self.ask_password_and_sign_transactions)
|
||||
menu.addAction(_("Export"), self.export_will)
|
||||
if self.bal_plugin.ENABLE_MULTIVERSE.get():
|
||||
self.importaction=menu.addAction(_("Import"), self.import_will)
|
||||
menu.addAction(_("Broadcast"), self.broadcast)
|
||||
menu.addAction(_("Check"), self.check)
|
||||
menu.addAction(_("Invalidate"), self.invalidate_will)
|
||||
|
||||
wizard=QPushButton(_("Setup Wizard"))
|
||||
wizard.clicked.connect(self.bal_window.init_wizard)
|
||||
display = QPushButton(_("Display"))
|
||||
display.clicked.connect(self.bal_window.preview_modal_dialog)
|
||||
|
||||
prepareButton = QPushButton(_("Prepare"))
|
||||
prepareButton.clicked.connect(self.build_transactions)
|
||||
signButton = QPushButton(_("Sign"))
|
||||
signButton.clicked.connect(self.ask_password_and_sign_transactions)
|
||||
pushButton = QPushButton(_("Broadcast"))
|
||||
pushButton.clicked.connect(self.broadcast)
|
||||
displayButton = QPushButton(_("Display"))
|
||||
displayButton.clicked.connect(self.bal_window.preview_modal_dialog)
|
||||
hlayout = QHBoxLayout()
|
||||
widget = QWidget()
|
||||
hlayout = QHBoxLayout(widget)
|
||||
hlayout.addWidget(wizard)
|
||||
hlayout.addWidget(prepareButton)
|
||||
hlayout.addWidget(signButton)
|
||||
hlayout.addWidget(pushButton)
|
||||
hlayout.addWidget(displayButton)
|
||||
widget.setLayout(hlayout)
|
||||
hlayout.addWidget(display)
|
||||
toolbar.insertWidget(2,widget)
|
||||
|
||||
|
||||
self.menu=menu
|
||||
self.toolbar=toolbar
|
||||
return toolbar
|
||||
|
||||
|
||||
def hide_replaced(self):
|
||||
self.bal_window.bal_plugin.hide_replaced()
|
||||
self.update()
|
||||
@@ -2569,7 +2641,7 @@ class PreviewList(MyTreeView):
|
||||
class PreviewDialog(BalDialog,MessageBoxMixin):
|
||||
def __init__(self, bal_window, will):
|
||||
self.parent = bal_window.window
|
||||
BalDialog.__init__(self,bal_window = bal_window)
|
||||
BalDialog.__init__(self,bal_window = bal_window,bal_plugin=bal_window.bal_plugin)
|
||||
self.bal_plugin = bal_window.bal_plugin
|
||||
self.gui_object = self.bal_plugin.gui_object
|
||||
self.config = self.bal_plugin.config
|
||||
@@ -2641,11 +2713,11 @@ class PreviewDialog(BalDialog,MessageBoxMixin):
|
||||
|
||||
def read_bal_QIcon(icon_basename: str=DEFAULT_ICON) -> QIcon:
|
||||
return QIcon(icon_path(icon_basename))
|
||||
|
||||
def read_bal_QPixmap(icon_basename: str=DEFAULT_ICON) -> QPixmap:
|
||||
return QPixmap(icon_path(icon_basename))
|
||||
|
||||
|
||||
|
||||
class WillDetailDialog(BalDialog):
|
||||
def __init__(self, bal_window):
|
||||
|
||||
@@ -2653,7 +2725,7 @@ class WillDetailDialog(BalDialog):
|
||||
self.threshold = Util.parse_locktime_string(bal_window.will_settings['threshold'])
|
||||
self.bal_window = bal_window
|
||||
Will.add_willtree(self.will)
|
||||
super().__init__(bal_window.window)
|
||||
super().__init__(bal_window.window,bal_window.bal_plugin)
|
||||
self.config = bal_window.window.config
|
||||
self.wallet = bal_window.wallet
|
||||
self.format_amount = bal_window.window.format_amount
|
||||
@@ -2770,7 +2842,10 @@ class WillWidget(QWidget):
|
||||
return QLabel(label)
|
||||
detaillayout.addWidget(qlabel("Locktime",locktime))
|
||||
detaillayout.addWidget(qlabel("Creation Time",creation))
|
||||
try:
|
||||
total_fees = self.will[w].tx.input_value() - self.will[w].tx.output_value()
|
||||
except:
|
||||
total_fees = -1
|
||||
decoded_fees = total_fees
|
||||
fee_per_byte = round(total_fees/self.will[w].tx.estimated_size(),3)
|
||||
fees_str = str(decoded_fees) + " ("+ str(fee_per_byte) + " sats/vbyte)"
|
||||
@@ -2797,7 +2872,6 @@ class WillWidget(QWidget):
|
||||
hlayout.addWidget(detailw)
|
||||
hlayout.addWidget(WillWidget(w,parent = parent))
|
||||
|
||||
|
||||
class WillExecutorList(MyTreeView):
|
||||
class Columns(MyTreeView.BaseColumnsEnum):
|
||||
SELECTED = enum.auto()
|
||||
@@ -2971,7 +3045,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
|
||||
@@ -3003,10 +3076,11 @@ class WillExecutorWidget(QWidget,MessageBoxMixin):
|
||||
vbox.addWidget(self.willexecutor_list)
|
||||
buttonbox = QHBoxLayout()
|
||||
|
||||
b = QPushButton(_('Ping'))
|
||||
b.clicked.connect(self.update_willexecutors)
|
||||
b = QPushButton(_('Add'))
|
||||
b.clicked.connect(self.add)
|
||||
buttonbox.addWidget(b)
|
||||
|
||||
|
||||
b = QPushButton(_('Download List'))
|
||||
b.clicked.connect(self.download_list)
|
||||
buttonbox.addWidget(b)
|
||||
@@ -3019,10 +3093,11 @@ class WillExecutorWidget(QWidget,MessageBoxMixin):
|
||||
b.clicked.connect(self.export_file)
|
||||
buttonbox.addWidget(b)
|
||||
|
||||
b = QPushButton(_('Add'))
|
||||
b.clicked.connect(self.add)
|
||||
b = QPushButton(_('Ping All'))
|
||||
b.clicked.connect(self.update_willexecutors)
|
||||
buttonbox.addWidget(b)
|
||||
|
||||
|
||||
vbox.addLayout(buttonbox)
|
||||
self.willexecutor_list.update()
|
||||
def add(self):
|
||||
@@ -3042,9 +3117,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()
|
||||
|
||||
@@ -3063,11 +3138,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,bal_window.bal_plugin)
|
||||
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)
|
||||
|
||||
@@ -3075,7 +3151,8 @@ class WillExecutorDialog(BalDialog,MessageBoxMixin):
|
||||
self.setMinimumSize(1000, 200)
|
||||
|
||||
vbox = QVBoxLayout(self)
|
||||
vbox.addWidget(WillExecutorWidget(self,self.bal_window,self.willexecutors_list))
|
||||
self.willexecutor_list= WillExecutorWidget(self,self.bal_window,self.willexecutors_list)
|
||||
vbox.addWidget(self.willexecutor_list)
|
||||
|
||||
|
||||
|
||||
|
||||
21
will.py
21
will.py
@@ -15,8 +15,8 @@ MIN_LOCKTIME = 1
|
||||
MIN_BLOCK = 1
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
#return an array with the list of children
|
||||
class Will:
|
||||
#return an array with the list of children
|
||||
def get_children(will,willid):
|
||||
out = []
|
||||
for _id in will:
|
||||
@@ -72,6 +72,8 @@ class Will:
|
||||
for txin in will[wid].tx.inputs():
|
||||
txid = txin.prevout.txid.hex()
|
||||
if txid in will:
|
||||
#print(will[txid].tx.outputs())
|
||||
#print(txin.prevout.out_idx)
|
||||
change = will[txid].tx.outputs()[txin.prevout.out_idx]
|
||||
txin._trusted_value_sats = change.value
|
||||
try:
|
||||
@@ -88,8 +90,11 @@ class Will:
|
||||
to_delete = []
|
||||
to_add = {}
|
||||
#add info from wallet
|
||||
willitems={}
|
||||
for wid in will:
|
||||
Will.add_info_from_will(will,wid,wallet)
|
||||
willitems[wid]=WillItem(will[wid])
|
||||
will=willitems
|
||||
errors ={}
|
||||
for wid in will:
|
||||
|
||||
@@ -110,7 +115,7 @@ class Will:
|
||||
outputs = will[wid].tx.outputs()
|
||||
ow=will[wid]
|
||||
ow.normalize_locktime(others_inputs)
|
||||
will[wid]=ow.to_dict()
|
||||
will[wid]=WillItem(ow.to_dict())
|
||||
|
||||
for i in range(0,len(outputs)):
|
||||
Will.change_input(will,wid,i,outputs[i],others_inputs,to_delete,to_add)
|
||||
@@ -319,7 +324,6 @@ class Will:
|
||||
locktime = Util.get_current_height(wallet.network)
|
||||
tx = PartialTransaction.from_io(utxo_to_spend, [out], locktime=locktime, version=2)
|
||||
tx.set_rbf(True)
|
||||
print("fees_per_byte:",fees_per_byte)
|
||||
fee=tx.estimated_size()*fees_per_byte
|
||||
if balance -fee >0:
|
||||
out = PartialTxOutput.from_address_and_value(change_addresses[0],balance - fee)
|
||||
@@ -744,10 +748,11 @@ class WillItem(Logger):
|
||||
else:
|
||||
return "#ffffff"
|
||||
|
||||
|
||||
class WillExpiredException(Exception):
|
||||
class WillException(Exception):
|
||||
pass
|
||||
class NotCompleteWillException(Exception):
|
||||
class WillExpiredException(WillException):
|
||||
pass
|
||||
class NotCompleteWillException(WillException):
|
||||
pass
|
||||
class HeirChangeException(NotCompleteWillException):
|
||||
pass
|
||||
@@ -761,9 +766,9 @@ class NoWillExecutorNotPresent(NotCompleteWillException):
|
||||
pass
|
||||
class WillExecutorNotPresent(NotCompleteWillException):
|
||||
pass
|
||||
class NoHeirsException(Exception):
|
||||
class NoHeirsException(WillException):
|
||||
pass
|
||||
class AmountException(Exception):
|
||||
class AmountException(WillException):
|
||||
pass
|
||||
class PercAmountException(AmountException):
|
||||
pass
|
||||
|
||||
@@ -18,15 +18,20 @@ 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):
|
||||
willexecutors = bal_plugin.WILLEXECUTORS.get()
|
||||
willexecutors=willexecutors.get(constants.net.NET_NAME,{})
|
||||
to_del=[]
|
||||
for w in willexecutors:
|
||||
if not isinstance(willexecutors[w],dict):
|
||||
to_del.append(w)
|
||||
continue
|
||||
Willexecutors.initialize_willexecutor(willexecutors[w],w)
|
||||
|
||||
for w in to_del:
|
||||
print("ERROR: WILLEXECUTOR TO DELETE:", w)
|
||||
del willexecutors[w]
|
||||
bal = bal_plugin.WILLEXECUTORS.default.get(constants.net.NET_NAME,{})
|
||||
for bal_url,bal_executor in bal.items():
|
||||
if not bal_url in willexecutors:
|
||||
@@ -46,7 +51,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))
|
||||
@@ -173,6 +178,7 @@ class Willexecutors:
|
||||
if constants.net.NET_NAME!="mainnet":
|
||||
netname=constants.net.NET_NAME
|
||||
w = Willexecutors.send_request('get',url+"/"+netname+"/info")
|
||||
|
||||
willexecutor['url']=url
|
||||
willexecutor['status'] = w['status']
|
||||
willexecutor['base_fee'] = w['base_fee']
|
||||
@@ -205,7 +211,7 @@ class Willexecutors:
|
||||
return l
|
||||
|
||||
except Exception as e:
|
||||
_logger.error(f"error downloading willexecutors list:{e}")
|
||||
_logger.error(f"Failed to download willexecutors list: {e}")
|
||||
return {}
|
||||
def get_willexecutors_list_from_json(bal_plugin):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user