3 Commits

Author SHA1 Message Date
c99f0fd70f msg_update not recreate labels update text 2026-04-09 05:58:01 -04:00
ab6aa7a698 msg_update window size 2026-04-09 05:46:43 -04:00
b55493221d bug in log 2026-04-09 05:02:21 -04:00
5 changed files with 59 additions and 31 deletions

2
bal.py
View File

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

View File

@@ -30,9 +30,11 @@ from electrum.transaction import (
PartialTransaction,
PartialTxInput,
PartialTxOutput,
TxOutput,
TxOutpoint,
# TxOutput,
)
from electrum.payment_identifier import PaymentIdentifier
from electrum.util import (
bfh,
read_json_file,
@@ -44,7 +46,6 @@ 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
@@ -71,28 +72,22 @@ def reduce_outputs(in_amount, out_amount, fee, outputs):
output.value = math.floor((in_amount - fee) / out_amount * output.value)
"""
#TODO: put this method inside wallet.db to replace or complete get_locktime_for_new_transaction
def get_current_height(network:'Network'):
#if no network or not up to date, just set locktime to zero
if not network:
return 0
chain = network.blockchain()
if chain.is_tip_stale():
return 0
# figure out current block height
chain_height = chain.height() # learnt from all connected servers, SPV-checked
server_height = network.get_server_height() # height claimed by main server, unverified
# note: main server might be lagging (either is slow, is malicious, or there is an SPV-invisible-hard-fork)
# - if it's lagging too much, it is the network's job to switch away
if server_height < chain_height - 10:
# the diff is suspiciously large... give up and use something non-fingerprintable
return 0
# discourage "fee sniping"
height = min(chain_height, server_height)
return height
"""
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
script = b'\x6a' + bytes([len(data)]) + data
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):
available_utxos = sorted(
@@ -167,6 +162,13 @@ def prepare_transactions(locktimes, available_utxos, fees, wallet):
outputs.append(change)
for i in range(0, 100):
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(
used_utxos,
outputs,

View File

@@ -1,7 +1,7 @@
{
"name": "BAL",
"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",
"available_for": ["qt"],
"icon":"icons/bal32x32.png"

25
qt.py
View File

@@ -2015,6 +2015,7 @@ class BalWaitingDialog(BalDialog):
self.thread.stop()
def update_message(self, msg):
print(msg)
self.message_label.setText(msg)
def update(self, msg):
@@ -2534,13 +2535,25 @@ class BalBuildWillDialog(BalDialog):
w.setParent(None)
w.deleteLater()
#def msg_update(self):
# self.clear_layout(self.labelsbox)
# for label in self.labels:
# label=label.replace("\n","<br>")
# qlabel=QLabel(label)
# qlabel.setWordWrap(True)
# self.labelsbox.addWidget(qlabel)
# self.labelsbox.activate()
# self.qwidget.setMinimumSize(self.labelsbox.sizeHint())
# self.qwidget.adjustSize()
# from PyQt6.QtWidgets import QApplication
# QApplication.processEvents()
#
# self.adjustSize()
def msg_update(self):
self.clear_layout(self.labelsbox)
for label in self.labels:
label=label.replace("\n","<br>")
qlabel=QLabel(label)
self.labelsbox.addWidget(QLabel(label),1)
self.setMinimumHeight(30*(len(self.labels)+2))
full_text = "<br><br>".join(self.labels).replace("\n", "<br>")
self.message_label.setText(full_text)
self.adjustSize()
def get_text(self):

13
util.py
View File

@@ -494,3 +494,16 @@ class Util:
del will[txid]["tx_fees"]
have_to_update = True
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"