Compare commits
5 Commits
0.2.8
...
56586ef0a7
| Author | SHA1 | Date | |
|---|---|---|---|
|
56586ef0a7
|
|||
|
d439b1fdde
|
|||
|
c99f0fd70f
|
|||
|
ab6aa7a698
|
|||
|
b55493221d
|
2
bal.py
2
bal.py
@@ -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:
|
||||||
|
|||||||
46
heirs.py
46
heirs.py
@@ -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:
|
|
||||||
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
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
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):
|
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,
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
47
qt.py
47
qt.py
@@ -1331,6 +1331,12 @@ class HeirsLockTimeEdit(QWidget, _LockTimeEditor):
|
|||||||
self.on_current_index_changed(index)
|
self.on_current_index_changed(index)
|
||||||
|
|
||||||
def set_locktime(self, x: Any, force=True) -> None:
|
def set_locktime(self, x: Any, force=True) -> None:
|
||||||
|
try:
|
||||||
|
int(x)
|
||||||
|
self.set_index(1)
|
||||||
|
except:
|
||||||
|
if isinstance(x,str):
|
||||||
|
self.set_index(0)
|
||||||
self.editor.set_locktime(x, force)
|
self.editor.set_locktime(x, force)
|
||||||
|
|
||||||
|
|
||||||
@@ -2015,6 +2021,7 @@ class BalWaitingDialog(BalDialog):
|
|||||||
self.thread.stop()
|
self.thread.stop()
|
||||||
|
|
||||||
def update_message(self, msg):
|
def update_message(self, msg):
|
||||||
|
print(msg)
|
||||||
self.message_label.setText(msg)
|
self.message_label.setText(msg)
|
||||||
|
|
||||||
def update(self, msg):
|
def update(self, msg):
|
||||||
@@ -2526,21 +2533,35 @@ class BalBuildWillDialog(BalDialog):
|
|||||||
pass
|
pass
|
||||||
self.updatemessage.emit()
|
self.updatemessage.emit()
|
||||||
|
|
||||||
def clear_layout(self,layout):
|
#def clear_layout(self,layout):
|
||||||
while layout.count():
|
# while layout.count():
|
||||||
item = layout.takeAt(0)
|
# item = layout.takeAt(0)
|
||||||
w = item.widget()
|
# w = item.widget()
|
||||||
if w:
|
# if w:
|
||||||
w.setParent(None)
|
# w.setParent(None)
|
||||||
w.deleteLater()
|
# 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):
|
def msg_update(self):
|
||||||
self.clear_layout(self.labelsbox)
|
full_text = "<br><br>".join(self.labels).replace("\n", "<br>")
|
||||||
for label in self.labels:
|
self.message_label.setText(full_text)
|
||||||
label=label.replace("\n","<br>")
|
self.message_label.adjustSize()
|
||||||
qlabel=QLabel(label)
|
#self.setMinimumHeight(len(self.labels)*40)
|
||||||
self.labelsbox.addWidget(QLabel(label),1)
|
self.resize(self.sizeHint())
|
||||||
self.setMinimumHeight(30*(len(self.labels)+2))
|
|
||||||
|
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
|
|||||||
13
util.py
13
util.py
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user