diff --git a/bal.py b/bal.py
index b6945b2..4c96915 100644
--- a/bal.py
+++ b/bal.py
@@ -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:
diff --git a/heirs.py b/heirs.py
index 7317ee6..e8cc3aa 100644
--- a/heirs.py
+++ b/heirs.py
@@ -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,
diff --git a/manifest.json b/manifest.json
index 5edff73..a6b2537 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"name": "BAL",
"fullname": "Bitcoin After Life",
- "description": "Provides free and decentralized inheritance support
Version: 0.2.7",
+ "description": "Provides free and decentralized inheritance support
Version: 0.2.8",
"author":"Svatantrya",
"available_for": ["qt"],
"icon":"icons/bal32x32.png"
diff --git a/qt.py b/qt.py
index 86e1b35..300ebb1 100644
--- a/qt.py
+++ b/qt.py
@@ -2540,7 +2540,6 @@ class BalBuildWillDialog(BalDialog):
label=label.replace("\n","
")
qlabel=QLabel(label)
self.labelsbox.addWidget(QLabel(label),1)
- self.setMinimumHeight(30*(len(self.labels)+2))
def get_text(self):
diff --git a/util.py b/util.py
index 5e1aa6b..af79d28 100644
--- a/util.py
+++ b/util.py
@@ -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"