1 Commits

Author SHA1 Message Date
b55493221d bug in log 2026-04-09 05:02:21 -04:00
5 changed files with 40 additions and 26 deletions

2
bal.py
View File

@@ -48,7 +48,7 @@ class BalConfig:
class BalPlugin(BasePlugin): class BalPlugin(BasePlugin):
_version=None _version=None
__version__ = "0.2.7" #AUTOMATICALLY GENERATED DO NOT EDIT __version__ = "0.2.8" #AUTOMATICALLY GENERATED DO NOT EDIT
def version(self): def version(self):
if not self._version: if not self._version:
try: try:

View File

@@ -30,9 +30,11 @@ from electrum.transaction import (
PartialTransaction, PartialTransaction,
PartialTxInput, PartialTxInput,
PartialTxOutput, PartialTxOutput,
TxOutput,
TxOutpoint, TxOutpoint,
# TxOutput, # TxOutput,
) )
from electrum.payment_identifier import PaymentIdentifier
from electrum.util import ( from electrum.util import (
bfh, bfh,
read_json_file, read_json_file,
@@ -44,7 +46,6 @@ 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.util import BitcoinException
if TYPE_CHECKING: if TYPE_CHECKING:
from .simple_config import SimpleConfig from .simple_config import SimpleConfig
@@ -71,28 +72,22 @@ def reduce_outputs(in_amount, out_amount, fee, outputs):
output.value = math.floor((in_amount - fee) / out_amount * output.value) output.value = math.floor((in_amount - fee) / out_amount * output.value)
""" def create_op_return_script(data_hex: str) -> bytes:
#TODO: put this method inside wallet.db to replace or complete get_locktime_for_new_transaction """Crea scriptpubkey OP_RETURN in bytes"""
def get_current_height(network:'Network'): data = bytes.fromhex(data_hex)
#if no network or not up to date, just set locktime to zero
if not network: if len(data) > 80:
return 0 raise ValueError("OP_RETURN data too big (max 80 bytes)")
chain = network.blockchain()
if chain.is_tip_stale(): # Costruzione manuale: OP_RETURN + push data
return 0 if len(data) <= 75:
# figure out current block height # Formato più comune: OP_RETURN + 1-byte length + data
chain_height = chain.height() # learnt from all connected servers, SPV-checked script = b'\x6a' + bytes([len(data)]) + data
server_height = network.get_server_height() # height claimed by main server, unverified else:
# note: main server might be lagging (either is slow, is malicious, or there is an SPV-invisible-hard-fork) # Per dati più grandi (fino a 80) si usa OP_PUSHDATA1
# - if it's lagging too much, it is the network's job to switch away script = b'\x6a\x4c' + bytes([len(data)]) + data
if server_height < chain_height - 10:
# the diff is suspiciously large... give up and use something non-fingerprintable return script
return 0
# discourage "fee sniping"
height = min(chain_height, server_height)
return height
"""
def prepare_transactions(locktimes, available_utxos, fees, wallet): def prepare_transactions(locktimes, available_utxos, fees, wallet):
available_utxos = sorted( available_utxos = sorted(
@@ -167,6 +162,13 @@ 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)
#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)
#outputs.append(PartialTxOutput(value=0, scriptpubkey=op_return_script))
tx = PartialTransaction.from_io( tx = PartialTransaction.from_io(
used_utxos, used_utxos,
outputs, outputs,

View File

@@ -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.7", "description": "Provides free and decentralized inheritance support<br> Version: 0.2.8",
"author":"Svatantrya", "author":"Svatantrya",
"available_for": ["qt"], "available_for": ["qt"],
"icon":"icons/bal32x32.png" "icon":"icons/bal32x32.png"

1
qt.py
View File

@@ -2540,7 +2540,6 @@ class BalBuildWillDialog(BalDialog):
label=label.replace("\n","<br>") label=label.replace("\n","<br>")
qlabel=QLabel(label) qlabel=QLabel(label)
self.labelsbox.addWidget(QLabel(label),1) self.labelsbox.addWidget(QLabel(label),1)
self.setMinimumHeight(30*(len(self.labels)+2))
def get_text(self): def get_text(self):

13
util.py
View File

@@ -494,3 +494,16 @@ class Util:
del will[txid]["tx_fees"] del will[txid]["tx_fees"]
have_to_update = True have_to_update = True
return have_to_update return have_to_update
def text_to_hex(text: str) -> str:
"""Convert text to hexadecimal string"""
hex_string = text.encode('utf-8').hex()
return hex_string
def hex_to_text(hex_string: str) -> str:
"""Convert hexadecimal string back to text (for verification)"""
try:
return bytes.fromhex(hex_string).decode('utf-8')
except Exception:
return "Error: Invalid hex string"