Compare commits
12 Commits
v0.2.1
...
609db44c1a
| Author | SHA1 | Date | |
|---|---|---|---|
|
609db44c1a
|
|||
|
0df6786f50
|
|||
|
2a4eab81fd
|
|||
|
d86b941fcb
|
|||
|
1836cdd892
|
|||
|
2416d0ce8d
|
|||
|
8e4e401d1b
|
|||
|
b8859ee5c1
|
|||
|
faeff1ff3c
|
|||
|
437105477d
|
|||
|
4c12136470
|
|||
|
a918c5564d
|
25
bal.py
25
bal.py
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# import random
|
# import random
|
||||||
# import zipfile as zipfile_lib
|
# import zipfile as zipfile_lib
|
||||||
|
|
||||||
@@ -9,7 +10,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)
|
||||||
@@ -17,7 +19,6 @@ json_db.register_dict("will", dict, None)
|
|||||||
json_db.register_dict("will_settings", lambda x: x, None)
|
json_db.register_dict("will_settings", lambda x: x, None)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_will(x):
|
def get_will(x):
|
||||||
try:
|
try:
|
||||||
x["tx"] = tx_from_any(x["tx"])
|
x["tx"] = tx_from_any(x["tx"])
|
||||||
@@ -62,21 +63,14 @@ 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")
|
||||||
self.plugin_dir = os.path.split(os.path.realpath(__file__))[0]
|
self.plugin_dir = os.path.split(os.path.realpath(__file__))[0]
|
||||||
zipfile = "/".join(self.plugin_dir.split("/")[:-1])
|
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
|
import sys
|
||||||
|
|
||||||
sys.path.insert(0, zipfile)
|
sys.path.insert(0, zipfile)
|
||||||
# print("sono state listate?")
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.config = config
|
self.config = config
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -96,10 +90,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)
|
||||||
@@ -145,16 +139,13 @@ class BalPlugin(BasePlugin):
|
|||||||
self.HIDE_REPLACED.set(self._hide_replaced)
|
self.HIDE_REPLACED.set(self._hide_replaced)
|
||||||
|
|
||||||
def validate_will_settings(self, will_settings):
|
def validate_will_settings(self, will_settings):
|
||||||
# print(type(will_settings))
|
|
||||||
# print(will_settings.get('baltx_fees',1),1)
|
|
||||||
if int(will_settings.get("baltx_fees", 1)) < 1:
|
if int(will_settings.get("baltx_fees", 1)) < 1:
|
||||||
will_settings["baltx_fees"] = 1
|
will_settings["baltx_fees"] = 1
|
||||||
if not will_settings.get("threshold"):
|
if not will_settings.get("threshold"):
|
||||||
will_settings["threshold"] = "180d"
|
will_settings["threshold"] = "180d"
|
||||||
if not will_settings.get("locktime") == "":
|
if not will_settings.get("locktime"):
|
||||||
will_settings["locktime"] = "1y"
|
will_settings["locktime"] = "1y"
|
||||||
return will_settings
|
return will_settings
|
||||||
|
|
||||||
def default_will_settings(self):
|
def default_will_settings(self):
|
||||||
return {"baltx_fees": 100, "threshold": "180d", "locktime": "1y"}
|
return {"baltx_fees": 100, "threshold": "180d", "locktime": "1y"}
|
||||||
|
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
56
heirs.py
56
heirs.py
@@ -29,6 +29,8 @@ from electrum.util import (
|
|||||||
|
|
||||||
from .util import Util
|
from .util import Util
|
||||||
from .willexecutors import Willexecutors
|
from .willexecutors import Willexecutors
|
||||||
|
from electrum.util import BitcoinException
|
||||||
|
from electrum import constants
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .simple_config import SimpleConfig
|
from .simple_config import SimpleConfig
|
||||||
@@ -41,6 +43,7 @@ HEIR_ADDRESS = 0
|
|||||||
HEIR_AMOUNT = 1
|
HEIR_AMOUNT = 1
|
||||||
HEIR_LOCKTIME = 2
|
HEIR_LOCKTIME = 2
|
||||||
HEIR_REAL_AMOUNT = 3
|
HEIR_REAL_AMOUNT = 3
|
||||||
|
HEIR_DUST_AMOUNT = 4
|
||||||
TRANSACTION_LABEL = "inheritance transaction"
|
TRANSACTION_LABEL = "inheritance transaction"
|
||||||
|
|
||||||
|
|
||||||
@@ -88,6 +91,7 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
|
|||||||
txsout = {}
|
txsout = {}
|
||||||
locktime, _ = Util.get_lowest_locktimes(locktimes)
|
locktime, _ = Util.get_lowest_locktimes(locktimes)
|
||||||
if not locktime:
|
if not locktime:
|
||||||
|
_logger.info("prepare transactions, no locktime")
|
||||||
return
|
return
|
||||||
locktime = locktime[0]
|
locktime = locktime[0]
|
||||||
|
|
||||||
@@ -101,22 +105,27 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
|
|||||||
outputs = []
|
outputs = []
|
||||||
paid_heirs = {}
|
paid_heirs = {}
|
||||||
for name, heir in heirs.items():
|
for name, heir in heirs.items():
|
||||||
|
if len(heir) > HEIR_REAL_AMOUNT and not "DUST" in str(
|
||||||
|
heir[HEIR_REAL_AMOUNT]
|
||||||
|
):
|
||||||
try:
|
try:
|
||||||
if len(heir) > HEIR_REAL_AMOUNT:
|
|
||||||
real_amount = heir[HEIR_REAL_AMOUNT]
|
real_amount = heir[HEIR_REAL_AMOUNT]
|
||||||
out_amount += real_amount
|
|
||||||
description += f"{name}\n"
|
|
||||||
paid_heirs[name] = heir
|
|
||||||
outputs.append(
|
outputs.append(
|
||||||
PartialTxOutput.from_address_and_value(
|
PartialTxOutput.from_address_and_value(
|
||||||
heir[HEIR_ADDRESS], real_amount
|
heir[HEIR_ADDRESS], real_amount
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
out_amount += real_amount
|
||||||
pass
|
description += f"{name}\n"
|
||||||
|
except BitcoinException as e:
|
||||||
|
_logger.info("exception decoding output{} - {}".format(type(e), e))
|
||||||
|
heir[HEIR_REAL_AMOUNT] = e
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
heir[HEIR_REAL_AMOUNT] = e
|
||||||
|
_logger.info(f"error preparing transactions {e}")
|
||||||
pass
|
pass
|
||||||
|
paid_heirs[name] = heir
|
||||||
|
|
||||||
in_amount = 0.0
|
in_amount = 0.0
|
||||||
used_utxos = []
|
used_utxos = []
|
||||||
@@ -125,12 +134,18 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
|
|||||||
value = utxo.value_sats()
|
value = utxo.value_sats()
|
||||||
in_amount += value
|
in_amount += value
|
||||||
used_utxos.append(utxo)
|
used_utxos.append(utxo)
|
||||||
if in_amount > out_amount:
|
if in_amount >= out_amount:
|
||||||
break
|
break
|
||||||
|
|
||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
|
_logger.info(
|
||||||
|
f"error preparing transactions index error {e} {in_amount}, {out_amount}"
|
||||||
|
)
|
||||||
pass
|
pass
|
||||||
if int(in_amount) < int(out_amount):
|
if int(in_amount) < int(out_amount):
|
||||||
|
_logger.info(
|
||||||
|
"error preparing transactions in_amount < out_amount ({} < {}) "
|
||||||
|
)
|
||||||
break
|
break
|
||||||
heirsvalue = out_amount
|
heirsvalue = out_amount
|
||||||
change = get_change_output(wallet, in_amount, out_amount, fee)
|
change = get_change_output(wallet, in_amount, out_amount, fee)
|
||||||
@@ -138,7 +153,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,
|
||||||
@@ -264,9 +278,10 @@ def get_change_output(wallet, in_amount, out_amount, fee):
|
|||||||
|
|
||||||
class Heirs(dict, Logger):
|
class Heirs(dict, Logger):
|
||||||
|
|
||||||
def __init__(self, db: "WalletDB"):
|
def __init__(self, wallet):
|
||||||
Logger.__init__(self)
|
Logger.__init__(self)
|
||||||
self.db = db
|
self.db = wallet.db
|
||||||
|
self.wallet = wallet
|
||||||
d = self.db.get("heirs", {})
|
d = self.db.get("heirs", {})
|
||||||
try:
|
try:
|
||||||
self.update(d)
|
self.update(d)
|
||||||
@@ -328,6 +343,10 @@ class Heirs(dict, Logger):
|
|||||||
if value > wallet.dust_threshold():
|
if value > wallet.dust_threshold():
|
||||||
heir_list[key].insert(HEIR_REAL_AMOUNT, value)
|
heir_list[key].insert(HEIR_REAL_AMOUNT, value)
|
||||||
amount += value
|
amount += value
|
||||||
|
else:
|
||||||
|
heir_list[key].insert(HEIR_REAL_AMOUNT, f"DUST: {value}")
|
||||||
|
heir_list[key].insert(HEIR_DUST_AMOUNT, value)
|
||||||
|
_logger.info(f"{key}, {value} is dust will be ignored")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
@@ -450,6 +469,7 @@ class Heirs(dict, Logger):
|
|||||||
):
|
):
|
||||||
Heirs._validate(self)
|
Heirs._validate(self)
|
||||||
if len(self) <= 0:
|
if len(self) <= 0:
|
||||||
|
_logger.info("while building transactions there was no heirs")
|
||||||
return
|
return
|
||||||
balance = 0.0
|
balance = 0.0
|
||||||
len_utxo_set = 0
|
len_utxo_set = 0
|
||||||
@@ -465,6 +485,7 @@ class Heirs(dict, Logger):
|
|||||||
len_utxo_set += 1
|
len_utxo_set += 1
|
||||||
available_utxos.append(utxo)
|
available_utxos.append(utxo)
|
||||||
if len_utxo_set == 0:
|
if len_utxo_set == 0:
|
||||||
|
_logger.info("no usable utxos")
|
||||||
return
|
return
|
||||||
j = -2
|
j = -2
|
||||||
willexecutorsitems = list(willexecutors.items())
|
willexecutorsitems = list(willexecutors.items())
|
||||||
@@ -506,6 +527,7 @@ class Heirs(dict, Logger):
|
|||||||
if not txs:
|
if not txs:
|
||||||
return {}
|
return {}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
_logger.info(f"error preparing transactions{e}")
|
||||||
try:
|
try:
|
||||||
if "w!ll3x3c" in e.heirname:
|
if "w!ll3x3c" in e.heirname:
|
||||||
Willexecutors.is_selected(willexecutors[w], False)
|
Willexecutors.is_selected(willexecutors[w], False)
|
||||||
@@ -633,7 +655,7 @@ class Heirs(dict, Logger):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def validate_address(address):
|
def validate_address(address):
|
||||||
if not bitcoin.is_address(address):
|
if not bitcoin.is_address(address, net=constants.net):
|
||||||
raise NotAnAddress(f"not an address,{address}")
|
raise NotAnAddress(f"not an address,{address}")
|
||||||
return address
|
return address
|
||||||
|
|
||||||
@@ -662,12 +684,14 @@ class Heirs(dict, Logger):
|
|||||||
return (address, amount, locktime)
|
return (address, amount, locktime)
|
||||||
|
|
||||||
def _validate(data, timestamp_to_check=False):
|
def _validate(data, timestamp_to_check=False):
|
||||||
|
|
||||||
for k, v in list(data.items()):
|
for k, v in list(data.items()):
|
||||||
if k == "heirs":
|
if k == "heirs":
|
||||||
return Heirs._validate(v)
|
return Heirs._validate(v, timestamp_to_check)
|
||||||
try:
|
try:
|
||||||
Heirs.validate_heir(k, v)
|
Heirs.validate_heir(k, v, timestamp_to_check)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
_logger.info(f"exception heir removed {e}")
|
||||||
data.pop(k)
|
data.pop(k)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -686,3 +710,7 @@ class LocktimeNotValid(ValueError):
|
|||||||
|
|
||||||
class HeirExpiredException(LocktimeNotValid):
|
class HeirExpiredException(LocktimeNotValid):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class HeirAmountIsDustException(Exception):
|
||||||
|
pass
|
||||||
|
|||||||
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"
|
||||||
|
|||||||
256
qt.py
256
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 (
|
||||||
@@ -144,7 +145,7 @@ from electrum.util import (
|
|||||||
|
|
||||||
from .bal import BalPlugin
|
from .bal import BalPlugin
|
||||||
from .bal_resources import DEFAULT_ICON, icon_path
|
from .bal_resources import DEFAULT_ICON, icon_path
|
||||||
from .heirs import Heirs
|
from .heirs import Heirs, HEIR_REAL_AMOUNT, HEIR_DUST_AMOUNT
|
||||||
from .util import Util
|
from .util import Util
|
||||||
from .will import (
|
from .will import (
|
||||||
AmountException,
|
AmountException,
|
||||||
@@ -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(
|
||||||
@@ -402,13 +401,13 @@ class BalWindow(Logger):
|
|||||||
self.willitems = {}
|
self.willitems = {}
|
||||||
self.willexecutors = {}
|
self.willexecutors = {}
|
||||||
self.will_settings = None
|
self.will_settings = None
|
||||||
self.heirs_tab = self.create_heirs_tab()
|
|
||||||
self.will_tab = self.create_will_tab()
|
|
||||||
self.ok = False
|
self.ok = False
|
||||||
self.disable_plugin = True
|
self.disable_plugin = True
|
||||||
self.bal_plugin.get_decimal_point = self.window.get_decimal_point
|
self.bal_plugin.get_decimal_point = self.window.get_decimal_point
|
||||||
|
|
||||||
if self.window.wallet:
|
if self.window.wallet:
|
||||||
|
self.heirs_tab = self.create_heirs_tab()
|
||||||
|
self.will_tab = self.create_will_tab()
|
||||||
self.wallet = self.window.wallet
|
self.wallet = self.window.wallet
|
||||||
self.heirs_tab.wallet = self.wallet
|
self.heirs_tab.wallet = self.wallet
|
||||||
self.will_tab.wallet = self.wallet
|
self.will_tab.wallet = self.wallet
|
||||||
@@ -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):
|
||||||
@@ -474,7 +473,7 @@ class BalWindow(Logger):
|
|||||||
self.bal_plugin, update=False, bal_window=self
|
self.bal_plugin, update=False, bal_window=self
|
||||||
)
|
)
|
||||||
if not self.heirs:
|
if not self.heirs:
|
||||||
self.heirs = Heirs._validate(Heirs(self.wallet.db))
|
self.heirs = Heirs._validate(Heirs(self.wallet))
|
||||||
if not self.will:
|
if not self.will:
|
||||||
self.will = self.wallet.db.get_dict("will")
|
self.will = self.wallet.db.get_dict("will")
|
||||||
Util.fix_will_tx_fees(self.will)
|
Util.fix_will_tx_fees(self.will)
|
||||||
@@ -499,7 +498,6 @@ class BalWindow(Logger):
|
|||||||
if not self.will_settings:
|
if not self.will_settings:
|
||||||
Util.copy(self.will_settings, self.bal_plugin.default_will_settings())
|
Util.copy(self.will_settings, self.bal_plugin.default_will_settings())
|
||||||
self.logger.debug("not_will_settings {}".format(self.will_settings))
|
self.logger.debug("not_will_settings {}".format(self.will_settings))
|
||||||
|
|
||||||
self.bal_plugin.validate_will_settings(self.will_settings)
|
self.bal_plugin.validate_will_settings(self.will_settings)
|
||||||
self.heir_list.update_will_settings()
|
self.heir_list.update_will_settings()
|
||||||
|
|
||||||
@@ -515,7 +513,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):
|
||||||
@@ -656,7 +654,7 @@ 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):
|
||||||
|
_logger.debug("building will...")
|
||||||
will = {}
|
will = {}
|
||||||
willtodelete = []
|
willtodelete = []
|
||||||
willtoappend = {}
|
willtoappend = {}
|
||||||
@@ -665,7 +663,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
|
||||||
@@ -673,6 +670,7 @@ class BalWindow(Logger):
|
|||||||
if Willexecutors.is_selected(w):
|
if Willexecutors.is_selected(w):
|
||||||
f = True
|
f = True
|
||||||
if not f:
|
if not f:
|
||||||
|
_logger.error("No Will-Executor or backup transaction selected")
|
||||||
raise NoWillExecutorNotPresent(
|
raise NoWillExecutorNotPresent(
|
||||||
"No Will-Executor or backup transaction selected"
|
"No Will-Executor or backup transaction selected"
|
||||||
)
|
)
|
||||||
@@ -683,7 +681,8 @@ class BalWindow(Logger):
|
|||||||
None,
|
None,
|
||||||
self.date_to_check,
|
self.date_to_check,
|
||||||
)
|
)
|
||||||
self.logger.info(txs)
|
|
||||||
|
self.logger.info(f"txs built: {txs}")
|
||||||
creation_time = time.time()
|
creation_time = time.time()
|
||||||
if txs:
|
if txs:
|
||||||
for txid in txs:
|
for txid in txs:
|
||||||
@@ -702,7 +701,13 @@ class BalWindow(Logger):
|
|||||||
tx["txchildren"] = []
|
tx["txchildren"] = []
|
||||||
will[txid] = WillItem(tx, _id=txid, wallet=self.wallet)
|
will[txid] = WillItem(tx, _id=txid, wallet=self.wallet)
|
||||||
self.update_will(will)
|
self.update_will(will)
|
||||||
|
else:
|
||||||
|
self.logger.info("No transactions was built")
|
||||||
|
self.logger.info(f"will-settings: {self.will_settings}")
|
||||||
|
self.logger.info(f"date_to_check:{self.date_to_check}")
|
||||||
|
self.logger.info(f"heirs: {self.heirs}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
self.logger.info(f"Exception build_will: {e}")
|
||||||
raise e
|
raise e
|
||||||
pass
|
pass
|
||||||
return self.willitems
|
return self.willitems
|
||||||
@@ -1180,7 +1185,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 +1583,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 +1693,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 +1765,9 @@ 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:
|
||||||
@@ -1821,6 +1828,7 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
|
|||||||
widget = QWidget()
|
widget = QWidget()
|
||||||
self.heir_locktime = HeirsLockTimeEdit(widget, 0)
|
self.heir_locktime = HeirsLockTimeEdit(widget, 0)
|
||||||
will_settings = self.bal_window.bal_plugin.WILL_SETTINGS.get()
|
will_settings = self.bal_window.bal_plugin.WILL_SETTINGS.get()
|
||||||
|
will_settings = self.bal_window.will_settings
|
||||||
self.heir_locktime.set_locktime(will_settings["locktime"])
|
self.heir_locktime.set_locktime(will_settings["locktime"])
|
||||||
|
|
||||||
def on_heir_locktime():
|
def on_heir_locktime():
|
||||||
@@ -2029,6 +2037,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 +2088,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",
|
||||||
@@ -2108,7 +2118,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
_logger.debug("no heirs")
|
_logger.debug("no heirs")
|
||||||
self.msg_set_checking("No Heirs")
|
self.msg_set_checking("No Heirs")
|
||||||
except NotCompleteWillException as e:
|
except NotCompleteWillException as e:
|
||||||
_logger.debug("not complete", e)
|
_logger.debug(f"not complete {e} true")
|
||||||
message = False
|
message = False
|
||||||
have_to_build = True
|
have_to_build = True
|
||||||
if isinstance(e, HeirChangeException):
|
if isinstance(e, HeirChangeException):
|
||||||
@@ -2122,7 +2132,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
elif isinstance(e, HeirNotFoundException):
|
elif isinstance(e, HeirNotFoundException):
|
||||||
message = "Heir not found"
|
message = "Heir not found"
|
||||||
if message:
|
if message:
|
||||||
_logger.debug("message")
|
_logger.debug(f"message: {message}")
|
||||||
self.msg_set_checking(message)
|
self.msg_set_checking(message)
|
||||||
else:
|
else:
|
||||||
self.msg_set_checking("New")
|
self.msg_set_checking("New")
|
||||||
@@ -2138,6 +2148,18 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.msg_set_building(self.msg_error(e))
|
self.msg_set_building(self.msg_error(e))
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
excluded_heirs = []
|
||||||
|
for wid in Will.only_valid(self.bal_window.willitems):
|
||||||
|
heirs = self.bal_window.willitems[wid].heirs
|
||||||
|
for hid, heir in heirs.items():
|
||||||
|
if "DUST" in str(heir[HEIR_REAL_AMOUNT]):
|
||||||
|
self.msg_set_status(
|
||||||
|
f'<font color="red">{hid},{heir[HEIR_DUST_AMOUNT]} is DUST',
|
||||||
|
None,
|
||||||
|
f"Excluded from will {wid}</font>",
|
||||||
|
)
|
||||||
|
|
||||||
have_to_sign = False
|
have_to_sign = False
|
||||||
for wid in Will.only_valid(self.bal_window.willitems):
|
for wid in Will.only_valid(self.bal_window.willitems):
|
||||||
if not self.bal_window.willitems[wid].get_status("COMPLETE"):
|
if not self.bal_window.willitems[wid].get_status("COMPLETE"):
|
||||||
@@ -2238,8 +2260,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 +2270,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):
|
||||||
@@ -2271,6 +2295,7 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
_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 +2308,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,
|
||||||
@@ -2395,8 +2420,6 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
self.password = self.bal_window.get_wallet_password(msg, parent=self)
|
self.password = self.bal_window.get_wallet_password(msg, parent=self)
|
||||||
|
|
||||||
def msg_edit_row(self, line, row=None):
|
def msg_edit_row(self, line, row=None):
|
||||||
_logger.debug(f"{row},{line}")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.labels[row] = line
|
self.labels[row] = line
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -2569,9 +2592,15 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
items[self.Columns.NAME].setEditable(True)
|
items[self.Columns.NAME].setEditable(True)
|
||||||
items[self.Columns.ADDRESS].setEditable(True)
|
items[self.Columns.ADDRESS].setEditable(True)
|
||||||
items[self.Columns.AMOUNT].setEditable(True)
|
items[self.Columns.AMOUNT].setEditable(True)
|
||||||
items[self.Columns.NAME].setData(key, self.ROLE_HEIR_KEY + 1)
|
items[self.Columns.NAME].setData(
|
||||||
items[self.Columns.ADDRESS].setData(key, self.ROLE_HEIR_KEY + 2)
|
key, self.ROLE_HEIR_KEY + self.Columns.NAME
|
||||||
items[self.Columns.AMOUNT].setData(key, self.ROLE_HEIR_KEY + 3)
|
)
|
||||||
|
items[self.Columns.ADDRESS].setData(
|
||||||
|
key, self.ROLE_HEIR_KEY + self.Columns.ADDRESS
|
||||||
|
)
|
||||||
|
items[self.Columns.AMOUNT].setData(
|
||||||
|
key, self.ROLE_HEIR_KEY + self.Columns.AMOUNT
|
||||||
|
)
|
||||||
|
|
||||||
row_count = self.model().rowCount()
|
row_count = self.model().rowCount()
|
||||||
self.model().insertRow(row_count, items)
|
self.model().insertRow(row_count, items)
|
||||||
@@ -2590,9 +2619,8 @@ 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)
|
||||||
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("")
|
||||||
@@ -2689,8 +2717,8 @@ class HeirList(MyTreeView, MessageBoxMixin):
|
|||||||
def update_will_settings(self):
|
def update_will_settings(self):
|
||||||
try:
|
try:
|
||||||
self.heir_locktime.set_locktime(self.bal_window.will_settings["locktime"])
|
self.heir_locktime.set_locktime(self.bal_window.will_settings["locktime"])
|
||||||
self.heir_tx_fees.setValue(int(self.bal_window.will_settings["baltx_fees"]))
|
|
||||||
self.heir_threshold.set_locktime(self.bal_window.will_settings["threshold"])
|
self.heir_threshold.set_locktime(self.bal_window.will_settings["threshold"])
|
||||||
|
self.heir_tx_fees.setValue(int(self.bal_window.will_settings["baltx_fees"]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.debug(f"Exception update_will_settings {e}")
|
_logger.debug(f"Exception update_will_settings {e}")
|
||||||
@@ -2735,6 +2763,7 @@ class PreviewList(MyTreeView):
|
|||||||
|
|
||||||
self.wallet = bal_window.window.wallet
|
self.wallet = bal_window.window.wallet
|
||||||
self.setModel(QStandardItemModel(self))
|
self.setModel(QStandardItemModel(self))
|
||||||
|
self.sortByColumn(self.Columns.LOCKTIME, Qt.SortOrder.AscendingOrder)
|
||||||
self.setSortingEnabled(True)
|
self.setSortingEnabled(True)
|
||||||
self.std_model = self.model()
|
self.std_model = self.model()
|
||||||
self.config = bal_window.bal_plugin.config
|
self.config = bal_window.bal_plugin.config
|
||||||
@@ -2893,6 +2922,8 @@ class PreviewList(MyTreeView):
|
|||||||
tmp = self.replace(set_current, current_key, txid, bal_tx)
|
tmp = self.replace(set_current, current_key, txid, bal_tx)
|
||||||
if tmp:
|
if tmp:
|
||||||
set_current = tmp
|
set_current = tmp
|
||||||
|
self.sortByColumn(self.Columns.LOCKTIME, Qt.SortOrder.AscendingOrder)
|
||||||
|
self.setSortingEnabled(True)
|
||||||
|
|
||||||
def create_toolbar(self, config):
|
def create_toolbar(self, config):
|
||||||
toolbar, menu = self.create_toolbar_with_menu("")
|
toolbar, menu = self.create_toolbar_with_menu("")
|
||||||
@@ -2911,6 +2942,9 @@ class PreviewList(MyTreeView):
|
|||||||
display = QPushButton(_("Display"))
|
display = QPushButton(_("Display"))
|
||||||
display.clicked.connect(self.bal_window.preview_modal_dialog)
|
display.clicked.connect(self.bal_window.preview_modal_dialog)
|
||||||
|
|
||||||
|
display = QPushButton(_("refresh"))
|
||||||
|
display.clicked.connect(self.check)
|
||||||
|
|
||||||
widget = QWidget()
|
widget = QWidget()
|
||||||
hlayout = QHBoxLayout(widget)
|
hlayout = QHBoxLayout(widget)
|
||||||
hlayout.addWidget(wizard)
|
hlayout.addWidget(wizard)
|
||||||
@@ -2952,10 +2986,25 @@ class PreviewList(MyTreeView):
|
|||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
|
Will.add_willtree(self.bal_window.willitems)
|
||||||
|
all_utxos = self.bal_window.wallet.get_utxos()
|
||||||
|
utxos_list = Will.utxos_strs(all_utxos)
|
||||||
|
Will.check_invalidated(
|
||||||
|
self.bal_window.willitems, utxos_list, self.bal_window.wallet
|
||||||
|
)
|
||||||
|
|
||||||
|
close_window = BalBuildWillDialog(self.bal_window)
|
||||||
|
close_window.build_will_task()
|
||||||
|
|
||||||
will = {}
|
will = {}
|
||||||
for wid, w in self.bal_window.willitems.items():
|
for wid, w in self.bal_window.willitems.items():
|
||||||
if w.get_status("VALID"):
|
if (
|
||||||
|
w.get_status("VALID")
|
||||||
|
and w.get_status("PUSHED")
|
||||||
|
and not w.get_status("CHECKED")
|
||||||
|
):
|
||||||
will[wid] = w
|
will[wid] = w
|
||||||
|
if will:
|
||||||
self.bal_window.check_transactions(will)
|
self.bal_window.check_transactions(will)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@@ -2989,6 +3038,10 @@ class PreviewDialog(BalDialog, MessageBoxMixin):
|
|||||||
self.setMinimumSize(1000, 200)
|
self.setMinimumSize(1000, 200)
|
||||||
self.size_label = QLabel()
|
self.size_label = QLabel()
|
||||||
self.transactions_list = PreviewList(self.bal_window, self.will)
|
self.transactions_list = PreviewList(self.bal_window, self.will)
|
||||||
|
|
||||||
|
self.bal_window.init_class_variables()
|
||||||
|
self.check_will()
|
||||||
|
|
||||||
vbox = QVBoxLayout(self)
|
vbox = QVBoxLayout(self)
|
||||||
vbox.addWidget(self.size_label)
|
vbox.addWidget(self.size_label)
|
||||||
vbox.addWidget(self.transactions_list)
|
vbox.addWidget(self.transactions_list)
|
||||||
@@ -3039,14 +3092,6 @@ class PreviewDialog(BalDialog, MessageBoxMixin):
|
|||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
|
|
||||||
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):
|
class WillDetailDialog(BalDialog):
|
||||||
def __init__(self, bal_window):
|
def __init__(self, bal_window):
|
||||||
|
|
||||||
@@ -3244,24 +3289,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,
|
||||||
@@ -3273,7 +3321,12 @@ class WillExecutorList(MyTreeView):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
try:
|
||||||
self.setModel(QStandardItemModel(self))
|
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,7 +3386,8 @@ 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
|
||||||
|
a = self.get_role_data_from_coordinate(row, col, role=role)
|
||||||
return a
|
return a
|
||||||
|
|
||||||
def delete(self, selected_keys):
|
def delete(self, selected_keys):
|
||||||
@@ -3391,7 +3445,13 @@ 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(
|
||||||
@@ -3399,11 +3459,20 @@ class WillExecutorList(MyTreeView):
|
|||||||
)
|
)
|
||||||
if str(value.get("status", 0)) == "200":
|
if str(value.get("status", 0)) == "200":
|
||||||
labels[self.Columns.STATUS] = [
|
labels[self.Columns.STATUS] = [
|
||||||
read_QIcon("icons/status_connected.png"),
|
read_QIcon_from_bytes(
|
||||||
|
self.parent.bal_plugin.read_file(
|
||||||
|
"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 +3492,25 @@ 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(
|
||||||
items[self.Columns.BASE_FEE].setData(url, self.ROLE_HEIR_KEY + 2)
|
url, self.ROLE_HEIR_KEY + self.Columns.URL
|
||||||
items[self.Columns.INFO].setData(url, self.ROLE_HEIR_KEY + 3)
|
)
|
||||||
items[self.Columns.ADDRESS].setData(url, self.ROLE_HEIR_KEY + 4)
|
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 + self.Columns.INFO
|
||||||
|
)
|
||||||
|
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 +3571,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,14 +3603,7 @@ 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,
|
|
||||||
update=True,
|
|
||||||
bal_window=self.bal_window,
|
|
||||||
force=True,
|
|
||||||
task=self,
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.bal_window.ping_willexecutors(wes, self.parent)
|
self.bal_window.ping_willexecutors(wes, self.parent)
|
||||||
self.willexecutors_list.update(wes)
|
self.willexecutors_list.update(wes)
|
||||||
self.willexecutor_list.update()
|
self.willexecutor_list.update()
|
||||||
|
|||||||
@@ -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)}")
|
||||||
|
|||||||
62
will.py
62
will.py
@@ -28,7 +28,6 @@ _logger = get_logger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
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:
|
||||||
@@ -82,8 +81,6 @@ class Will:
|
|||||||
for txin in will[wid].tx.inputs():
|
for txin in will[wid].tx.inputs():
|
||||||
txid = txin.prevout.txid.hex()
|
txid = txin.prevout.txid.hex()
|
||||||
if txid in will:
|
if txid in will:
|
||||||
# print(will[txid].tx.outputs())
|
|
||||||
# print(txin.prevout.out_idx)
|
|
||||||
change = will[txid].tx.outputs()[txin.prevout.out_idx]
|
change = will[txid].tx.outputs()[txin.prevout.out_idx]
|
||||||
txin._trusted_value_sats = change.value
|
txin._trusted_value_sats = change.value
|
||||||
try:
|
try:
|
||||||
@@ -155,6 +152,16 @@ class Will:
|
|||||||
inp._TxInput__value_sats = change.value
|
inp._TxInput__value_sats = change.value
|
||||||
return inp
|
return inp
|
||||||
|
|
||||||
|
"""
|
||||||
|
in questa situazione sono presenti due transazioni con id differente(quindi transazioni differenti)
|
||||||
|
per prima cosa controllo il locktime
|
||||||
|
se il locktime della nuova transazione e' maggiore del locktime della vecchia transazione, allora
|
||||||
|
confronto gli eredi, per locktime se corrispondono controllo i willexecutor
|
||||||
|
se hanno la stessa url ma le fee vecchie sono superiori alle fee nuove, allora anticipare.
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
def check_anticipate(ow: "WillItem", nw: "WillItem"):
|
def check_anticipate(ow: "WillItem", nw: "WillItem"):
|
||||||
anticipate = Util.anticipate_locktime(ow.tx.locktime, days=1)
|
anticipate = Util.anticipate_locktime(ow.tx.locktime, days=1)
|
||||||
if int(nw.tx.locktime) >= int(anticipate):
|
if int(nw.tx.locktime) >= int(anticipate):
|
||||||
@@ -258,7 +265,7 @@ class Will:
|
|||||||
to_append = {}
|
to_append = {}
|
||||||
new_inputs = Will.get_all_inputs(will, only_valid=True)
|
new_inputs = Will.get_all_inputs(will, only_valid=True)
|
||||||
for nid, nwi in will.items():
|
for nid, nwi in will.items():
|
||||||
if nwi.search_anticipate(new_inputs) or nwi.search_anticipate(old_inputs):
|
if nwi.search_anticipate(new_inputs):
|
||||||
if nid != nwi.tx.txid():
|
if nid != nwi.tx.txid():
|
||||||
redo = True
|
redo = True
|
||||||
to_delete.append(nid)
|
to_delete.append(nid)
|
||||||
@@ -268,6 +275,17 @@ class Will:
|
|||||||
Will.change_input(
|
Will.change_input(
|
||||||
will, nid, i, outputs[i], new_inputs, to_delete, to_append
|
will, nid, i, outputs[i], new_inputs, to_delete, to_append
|
||||||
)
|
)
|
||||||
|
if nwi.search_anticipate(old_inputs):
|
||||||
|
if nid != nwi.tx.txid():
|
||||||
|
redo = True
|
||||||
|
|
||||||
|
to_delete.append(nid)
|
||||||
|
to_append[nwi.tx.txid()] = nwi
|
||||||
|
outputs = nwi.tx.outputs()
|
||||||
|
for i in range(0, len(outputs)):
|
||||||
|
Will.change_input(
|
||||||
|
will, nid, i, outputs[i], new_inputs, to_delete, to_append
|
||||||
|
)
|
||||||
|
|
||||||
for w in to_delete:
|
for w in to_delete:
|
||||||
try:
|
try:
|
||||||
@@ -277,6 +295,7 @@ class Will:
|
|||||||
for k, w in to_append.items():
|
for k, w in to_append.items():
|
||||||
will[k] = w
|
will[k] = w
|
||||||
if redo:
|
if redo:
|
||||||
|
|
||||||
Will.search_anticipate_rec(will, old_inputs)
|
Will.search_anticipate_rec(will, old_inputs)
|
||||||
|
|
||||||
def update_will(old_will, new_will):
|
def update_will(old_will, new_will):
|
||||||
@@ -286,7 +305,6 @@ class Will:
|
|||||||
# check if the new input is already spent by other transaction
|
# check if the new input is already spent by other transaction
|
||||||
# if it is use the same locktime, or anticipate.
|
# if it is use the same locktime, or anticipate.
|
||||||
Will.search_anticipate_rec(new_will, all_old_inputs)
|
Will.search_anticipate_rec(new_will, all_old_inputs)
|
||||||
|
|
||||||
other_inputs = Will.get_all_inputs(old_will, {})
|
other_inputs = Will.get_all_inputs(old_will, {})
|
||||||
try:
|
try:
|
||||||
Will.normalize_will(new_will, others_inputs=other_inputs)
|
Will.normalize_will(new_will, others_inputs=other_inputs)
|
||||||
@@ -338,7 +356,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)
|
||||||
@@ -422,13 +439,16 @@ class Will:
|
|||||||
# check if transactions are stil valid tecnically valid
|
# check if transactions are stil valid tecnically valid
|
||||||
def check_invalidated(willtree, utxos_list, wallet):
|
def check_invalidated(willtree, utxos_list, wallet):
|
||||||
for wid, w in willtree.items():
|
for wid, w in willtree.items():
|
||||||
if not w.father:
|
if (
|
||||||
|
not w.father
|
||||||
|
or willtree[w.father].get_status("CONFIRMED")
|
||||||
|
or willtree[w.father].get_status("PENDING")
|
||||||
|
):
|
||||||
for inp in w.tx.inputs():
|
for inp in w.tx.inputs():
|
||||||
inp_str = Util.utxo_to_str(inp)
|
inp_str = Util.utxo_to_str(inp)
|
||||||
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 +493,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 +520,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,
|
||||||
@@ -643,7 +654,6 @@ class Will:
|
|||||||
|
|
||||||
|
|
||||||
class WillItem(Logger):
|
class WillItem(Logger):
|
||||||
|
|
||||||
STATUS_DEFAULT = {
|
STATUS_DEFAULT = {
|
||||||
"ANTICIPATED": ["Anticipated", False],
|
"ANTICIPATED": ["Anticipated", False],
|
||||||
"BROADCASTED": ["Broadcasted", False],
|
"BROADCASTED": ["Broadcasted", False],
|
||||||
@@ -665,15 +675,15 @@ 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
|
||||||
|
|
||||||
self.status += "." + ("NOT " if not value else "" + _(self.STATUS[status][0]))
|
self.status += "." + (("NOT " if not value else "") + _(self.STATUS[status][0]))
|
||||||
self.STATUS[status][1] = bool(value)
|
self.STATUS[status][1] = bool(value)
|
||||||
if value:
|
if value:
|
||||||
if status in ["INVALIDATED", "REPLACED", "CONFIRMED", "PENDING"]:
|
if status in ["INVALIDATED", "REPLACED", "CONFIRMED", "PENDING"]:
|
||||||
@@ -878,3 +888,7 @@ class PercAmountException(AmountException):
|
|||||||
|
|
||||||
class FixedAmountException(AmountException):
|
class FixedAmountException(AmountException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_invalidated():
|
||||||
|
Will.check_invalidated(will, utxos_list, wallet)
|
||||||
|
|||||||
@@ -35,34 +35,36 @@ 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
|
||||||
@@ -119,7 +121,7 @@ class Willexecutors:
|
|||||||
def send_request(method, url, data=None, *, timeout=10):
|
def send_request(method, url, data=None, *, timeout=10):
|
||||||
network = Network.get_instance()
|
network = Network.get_instance()
|
||||||
if not network:
|
if not network:
|
||||||
raise ErrorConnectingServer("You are offline.")
|
raise Exception("You are offline.")
|
||||||
_logger.debug(f"<-- {method} {url} {data}")
|
_logger.debug(f"<-- {method} {url} {data}")
|
||||||
headers = {}
|
headers = {}
|
||||||
headers["user-agent"] = f"BalPlugin v:{BalPlugin.version()}"
|
headers["user-agent"] = f"BalPlugin v:{BalPlugin.version()}"
|
||||||
@@ -171,7 +173,7 @@ class Willexecutors:
|
|||||||
out = True
|
out = True
|
||||||
try:
|
try:
|
||||||
|
|
||||||
_logger.debug(f"willexecutor['txs']")
|
_logger.debug(f"{willexecutor[url]}: {willexecutor['txs']}")
|
||||||
if w := Willexecutors.send_request(
|
if w := Willexecutors.send_request(
|
||||||
"post",
|
"post",
|
||||||
willexecutor["url"] + "/" + constants.net.NET_NAME + "/pushtxs",
|
willexecutor["url"] + "/" + constants.net.NET_NAME + "/pushtxs",
|
||||||
|
|||||||
Reference in New Issue
Block a user