This commit is contained in:
2026-02-09 12:01:06 -04:00
parent 0df6786f50
commit 609db44c1a
5 changed files with 129 additions and 83 deletions

View File

@@ -31,6 +31,7 @@ from .util import Util
from .willexecutors import Willexecutors
from electrum.util import BitcoinException
from electrum import constants
if TYPE_CHECKING:
from .simple_config import SimpleConfig
from .wallet_db import WalletDB
@@ -104,7 +105,9 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
outputs = []
paid_heirs = {}
for name, heir in heirs.items():
if len(heir) > HEIR_REAL_AMOUNT and not "DUST" in str(heir[HEIR_REAL_AMOUNT]):
if len(heir) > HEIR_REAL_AMOUNT and not "DUST" in str(
heir[HEIR_REAL_AMOUNT]
):
try:
real_amount = heir[HEIR_REAL_AMOUNT]
outputs.append(
@@ -115,11 +118,11 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
out_amount += real_amount
description += f"{name}\n"
except BitcoinException as e:
_logger.info("exception decoding output{} - {}".format(type(e),e))
heir[HEIR_REAL_AMOUNT]=e
_logger.info("exception decoding output{} - {}".format(type(e), e))
heir[HEIR_REAL_AMOUNT] = e
except Exception as e:
heir[HEIR_REAL_AMOUNT]=e
heir[HEIR_REAL_AMOUNT] = e
_logger.info(f"error preparing transactions {e}")
pass
paid_heirs[name] = heir
@@ -135,10 +138,14 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
break
except IndexError as e:
_logger.info(f"error preparing transactions index error {e} {in_amount}, {out_amount}")
_logger.info(
f"error preparing transactions index error {e} {in_amount}, {out_amount}"
)
pass
if int(in_amount) < int(out_amount):
_logger.info("error preparing transactions in_amount < out_amount ({} < {}) ")
_logger.info(
"error preparing transactions in_amount < out_amount ({} < {}) "
)
break
heirsvalue = out_amount
change = get_change_output(wallet, in_amount, out_amount, fee)
@@ -274,7 +281,7 @@ class Heirs(dict, Logger):
def __init__(self, wallet):
Logger.__init__(self)
self.db = wallet.db
self.wallet=wallet
self.wallet = wallet
d = self.db.get("heirs", {})
try:
self.update(d)
@@ -337,8 +344,8 @@ class Heirs(dict, Logger):
heir_list[key].insert(HEIR_REAL_AMOUNT, value)
amount += value
else:
heir_list[key].insert(HEIR_REAL_AMOUNT,f"DUST: {value}")
heir_list[key].insert(HEIR_DUST_AMOUNT,value)
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:
@@ -648,7 +655,7 @@ class Heirs(dict, Logger):
return None
def validate_address(address):
if not bitcoin.is_address(address,net=constants.net):
if not bitcoin.is_address(address, net=constants.net):
raise NotAnAddress(f"not an address,{address}")
return address
@@ -677,10 +684,10 @@ class Heirs(dict, Logger):
return (address, amount, locktime)
def _validate(data, timestamp_to_check=False):
for k, v in list(data.items()):
if k == "heirs":
return Heirs._validate(v,timestamp_to_check)
return Heirs._validate(v, timestamp_to_check)
try:
Heirs.validate_heir(k, v, timestamp_to_check)
except Exception as e:
@@ -704,5 +711,6 @@ class LocktimeNotValid(ValueError):
class HeirExpiredException(LocktimeNotValid):
pass
class HeirAmountIsDustException(Exception):
pass