partial commit to fix wallet utils

this commit provide a lot of changes in will-settings including export to ics calendar file.
This commit is contained in:
2026-04-27 10:03:05 -04:00
parent 9204c90e4c
commit b5eda4f05a
9 changed files with 839 additions and 635 deletions

View File

@@ -34,6 +34,7 @@ from electrum.transaction import (
# TxOutput,
)
from electrum.util import (
BitcoinException,
bfh,
read_json_file,
to_string,
@@ -43,7 +44,7 @@ from electrum.util import (
from .util import Util
from .willexecutors import Willexecutors
from electrum.util import BitcoinException
if TYPE_CHECKING:
from .simple_config import SimpleConfig
@@ -73,10 +74,10 @@ def reduce_outputs(in_amount, out_amount, fee, outputs):
def create_op_return_script(data_hex: str) -> bytes:
"""Crea scriptpubkey OP_RETURN in bytes"""
data = bytes.fromhex(data_hex)
if len(data) > 80:
raise ValueError("OP_RETURN data too big (max 80 bytes)")
# Costruzione manuale: OP_RETURN + push data
if len(data) <= 75:
# Formato più comune: OP_RETURN + 1-byte length + data
@@ -84,7 +85,7 @@ def create_op_return_script(data_hex: str) -> bytes:
else:
# Per dati più grandi (fino a 80) si usa OP_PUSHDATA1
script = b'\x6a\x4c' + bytes([len(data)]) + data
return script
def prepare_transactions(locktimes, available_utxos, fees, wallet):
@@ -162,7 +163,7 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
random.shuffle(outputs)
#op_return_text = "Hello Bal!"
## Convert text to hex
#op_return_hex = op_return_text.encode('utf-8').hex()
#op_return_script = create_op_return_script(op_return_hex)