5 Commits

Author SHA1 Message Date
936d4ef467 version 2026-01-04 16:54:27 -04:00
5512ee0e61 version 2026-01-04 16:49:43 -04:00
3e9a841e21 version 2026-01-04 16:41:53 -04:00
5d9636cda1 txfees fixer 2026-01-04 13:45:31 -04:00
b384ac562c wallet utils 2025-11-30 16:29:01 -04:00
7 changed files with 58 additions and 65 deletions

View File

@@ -1 +1 @@
0.2.2b 0.2.2d

5
bal.py
View File

@@ -27,7 +27,6 @@ def get_will(x):
class BalConfig(): class BalConfig():
def __init__(self, config, name, default): def __init__(self, config, name, default):
print("init bal_config")
self.config = config self.config = config
self.name = name self.name = name
self.default = default self.default = default
@@ -131,8 +130,8 @@ class BalPlugin(BasePlugin):
self.HIDE_REPLACED.set(self._hide_replaced) self.HIDE_REPLACED.set(self._hide_replaced)
def validate_will_settings(self,will_settings): def validate_will_settings(self,will_settings):
print(type(will_settings)) #print(type(will_settings))
print(will_settings.get('baltx_fees',1),1) #print(will_settings.get('baltx_fees',1),1)
if int(will_settings.get('baltx_fees',1))<1: if int(will_settings.get('baltx_fees',1))<1:
will_settings['baltx_fees']=1 will_settings['baltx_fees']=1
if not will_settings.get('threshold'): if not will_settings.get('threshold'):

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

6
qt.py
View File

@@ -390,6 +390,7 @@ class Plugin(BalPlugin,Logger):
def load_wallet(self,wallet, main_window): def load_wallet(self,wallet, main_window):
self.logger.info("HOOK load wallet") self.logger.info("HOOK load wallet")
w = self.get_window(main_window) w = self.get_window(main_window)
#havetoupdate = Util.fix_will_settings_tx_fees(wallet.db)
w.wallet = wallet w.wallet = wallet
w.init_will() w.init_will()
w.willexecutors = Willexecutors.get_willexecutors(self, update=False, bal_window=w) w.willexecutors = Willexecutors.get_willexecutors(self, update=False, bal_window=w)
@@ -575,6 +576,7 @@ class BalWindow(Logger):
self.heirs = Heirs._validate(Heirs(self.wallet.db)) self.heirs = Heirs._validate(Heirs(self.wallet.db))
if not self.will: if not self.will:
self.will=self.wallet.db.get_dict("will") self.will=self.wallet.db.get_dict("will")
Util.fix_will_tx_fees(self.will)
if self.will: if self.will:
self.willitems = {} self.willitems = {}
try: try:
@@ -587,6 +589,8 @@ class BalWindow(Logger):
if not self.will_settings: if not self.will_settings:
self.will_settings=self.wallet.db.get_dict("will_settings") self.will_settings=self.wallet.db.get_dict("will_settings")
Util.fix_will_settings_tx_fees(self.will_settings)
self.logger.info("will_settings: {}".format(self.will_settings)) self.logger.info("will_settings: {}".format(self.will_settings))
if not self.will_settings: if not self.will_settings:
Util.copy(self.will_settings,self.bal_plugin.default_will_settings()) Util.copy(self.will_settings,self.bal_plugin.default_will_settings())
@@ -1856,7 +1860,7 @@ class BalBuildWillDialog(BalDialog):
def __init__(self,bal_window,parent=None): def __init__(self,bal_window,parent=None):
if not parent: if not parent:
parent = bal_window.window parent = bal_window.window
BalDialog.__init__(self,parent,babl_window.bal_plugin, "Building Will") BalDialog.__init__(self,parent,bal_window.bal_plugin, "Building Will")
self.updatemessage.connect(self.update) self.updatemessage.connect(self.update)
self.bal_window=bal_window self.bal_window=bal_window
self.message_label = QLabel("Building Will:") self.message_label = QLabel("Building Will:")

19
util.py
View File

@@ -435,3 +435,22 @@ class Util:
def copy(dicto,dictfrom): def copy(dicto,dictfrom):
for k,v in dictfrom.items(): for k,v in dictfrom.items():
dicto[k]=v dicto[k]=v
def fix_will_settings_tx_fees(will_settings):
tx_fees = will_settings.get('tx_fees',False)
have_to_update=False
if tx_fees:
will_settings['baltx_fees']=tx_fees
del will_settings['tx_fees']
have_to_update=True
return have_to_update
def fix_will_tx_fees(will):
have_to_update = False
for txid,willitem in will.items():
tx_fees=willitem.get('tx_fees',False)
if tx_fees:
will[txid]['baltx_fees']=tx_fees
del will[txid]['tx_fees']
have_to_update=True
return have_to_update

View File

@@ -1,6 +1,4 @@
#!env/bin/python3 #!env/bin/python3
#same as qt but for command line, useful if you are going to fix various wallet
#also easier to read the code
from electrum.storage import WalletStorage from electrum.storage import WalletStorage
from electrum.util import MyEncoder from electrum.util import MyEncoder
import json import json
@@ -12,11 +10,18 @@ default_fees= 100
def fix_will_settings_tx_fees(json_wallet): def fix_will_settings_tx_fees(json_wallet):
tx_fees = json_wallet.get('will_settings',{}).get('tx_fees',False) tx_fees = json_wallet.get('will_settings',{}).get('tx_fees',False)
have_to_update=False
if tx_fees: if tx_fees:
json_wallet['will_settings']['baltx_fees']=json_wallet.get('will_settings',{}).get('tx_fees',default_fees) json_wallet['will_settings']['baltx_fees']=tx_fees
del json_wallet['will_settings']['tx_fees'] del json_wallet['will_settings']['tx_fees']
return True have_to_update=True
return False for txid,willitem in json_wallet['will'].items():
tx_fees=willitem.get('tx_fees',False)
if tx_fees:
json_wallet['will'][txid]['baltx_fees']=tx_fees
del json_wallet['will'][txid]['tx_fees']
have_to_update=True
return have_to_update
def uninstall_bal(json_wallet): def uninstall_bal(json_wallet):
del json_wallet['will_settings'] del json_wallet['will_settings']
@@ -32,6 +37,15 @@ def save(json_wallet,storage):
sort_keys=bool(human_readable), sort_keys=bool(human_readable),
cls=MyEncoder, cls=MyEncoder,
)) ))
def read_wallet(path,password=False):
storage=WalletStorage(path)
if storage.is_encrypted():
if password==False:
password = getpass.getpass("Enter wallet password: ", stream = None)
storage.decrypt(password)
data=storage.read()
json_wallet=json.loads('['+data+']')[0]
return json_wallet
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) <3: if len(sys.argv) <3:
@@ -43,13 +57,7 @@ if __name__ == '__main__':
exit(1) exit(1)
command = sys.argv[1] command = sys.argv[1]
path = sys.argv[2] path = sys.argv[2]
json_wallet = read_wallet(path)
storage=WalletStorage(path)
if storage.is_encrypted():
password = getpass.getpass("Enter wallet password: ", stream = None)
storage.decrypt(password)
data=storage.read()
json_wallet=json.loads(data)
have_to_save=False have_to_save=False
if command == 'fix': if command == 'fix':
have_to_save = fix_will_settings_tx_fees(json_wallet) have_to_save = fix_will_settings_tx_fees(json_wallet)

View File

@@ -1,10 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#this script will help to fix tx_fees wallet bug
#also added an uninstall button to remove any bal data from wallet
#still very work in progress.
#
#have to be executed from electrum source code directory in example /home/user/projects/electrum/
#
import sys import sys
import os import os
import json import json
@@ -14,8 +8,7 @@ from PyQt6.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QHBoxLayout
from PyQt6.QtCore import Qt from PyQt6.QtCore import Qt
from electrum.storage import WalletStorage from electrum.storage import WalletStorage
from electrum.util import MyEncoder from electrum.util import MyEncoder
from bal_wallet_utils import fix_will_settings_tx_fees,uninstall_bal,read_wallet
default_fees = 100
class WalletUtilityGUI(QMainWindow): class WalletUtilityGUI(QMainWindow):
def __init__(self): def __init__(self):
@@ -94,8 +87,8 @@ class WalletUtilityGUI(QMainWindow):
file_path, _ = QFileDialog.getOpenFileName( file_path, _ = QFileDialog.getOpenFileName(
self, self,
"Select Wallet", "Select Wallet",
"", "*",
"Electrum Wallet (*.dat)" "Electrum Wallet (*)"
) )
if file_path: if file_path:
self.wallet_path_edit.setText(file_path) self.wallet_path_edit.setText(file_path)
@@ -110,37 +103,6 @@ class WalletUtilityGUI(QMainWindow):
def log_message(self, message): def log_message(self, message):
self.output_text.append(message) self.output_text.append(message)
def fix_will_settings_tx_fees(self, json_wallet):
tx_fees = json_wallet.get('will_settings',{}).get('tx_fees',False)
if tx_fees:
json_wallet['will_settings']['baltx_fees'] = json_wallet.get('will_settings',{}).get('tx_fees', default_fees)
del json_wallet['will_settings']['tx_fees']
return True
return False
def uninstall_bal(self, json_wallet):
if 'will_settings' in json_wallet:
del json_wallet['will_settings']
if 'will' in json_wallet:
del json_wallet['will']
if 'heirs' in json_wallet:
del json_wallet['heirs']
return True
def save_wallet(self, json_wallet, storage):
try:
human_readable = not storage.is_encrypted()
storage.write(json.dumps(
json_wallet,
indent=4 if human_readable else None,
sort_keys=bool(human_readable),
cls=MyEncoder,
))
return True
except Exception as e:
self.log_message(f"Save error: {str(e)}")
return False
def fix_wallet(self): def fix_wallet(self):
self.process_wallet('fix') self.process_wallet('fix')
@@ -180,24 +142,25 @@ class WalletUtilityGUI(QMainWindow):
# Read wallet # Read wallet
data = storage.read() data = storage.read()
json_wallet = json.loads(data) json_wallet = json.loads('[' + data + ']')[0]
have_to_save = False have_to_save = False
message = "" message = ""
if command == 'fix': if command == 'fix':
have_to_save = self.fix_will_settings_tx_fees(json_wallet) have_to_save = fix_will_settings_tx_fees(json_wallet)
message = "Fix applied successfully" if have_to_save else "No fix needed" message = "Fix applied successfully" if have_to_save else "No fix needed"
elif command == 'uninstall': elif command == 'uninstall':
have_to_save = self.uninstall_bal(json_wallet) have_to_save = uninstall_bal(json_wallet)
message = "BAL uninstalled successfully" if have_to_save else "No BAL settings found to uninstall" message = "BAL uninstalled successfully" if have_to_save else "No BAL settings found to uninstall"
if have_to_save: if have_to_save:
if self.save_wallet(json_wallet, storage): try:
save_wallet(json_wallet, storage)
self.log_message(f"SUCCESS: {message}") self.log_message(f"SUCCESS: {message}")
else: except Exception as e:
self.log_message("ERROR: Failed to save wallet") self.log_message(f"Save error: {str(e)}")
else: else:
self.log_message(f"INFO: {message}") self.log_message(f"INFO: {message}")