fix tx_fees wallet and other bug fixes to be compatible with electrum 0.6.2-master(0.6.3)

This commit is contained in:
2025-11-29 23:42:54 -04:00
parent 7c1fc04add
commit 9817546064
8 changed files with 348 additions and 31 deletions

51
qt.py
View File

@@ -336,12 +336,14 @@ class Plugin(BalPlugin,Logger):
def __init__(self, parent, config, name):
Logger.__init__(self)
self.logger.info("INIT BALPLUGIN")
print("init bal_plugin")
BalPlugin.__init__(self, parent, config, name)
self.bal_windows={}
@hook
def init_qt(self,gui_object):
print("hook init qt")
self.logger.info("HOOK init qt")
try:
self.gui_object=gui_object
@@ -396,10 +398,16 @@ class Plugin(BalPlugin,Logger):
@hook
def close_wallet(self,wallet):
print("HOOK close wallet")
for winid,win in self.bal_windows.items():
if win.wallet == wallet:
win.on_close()
@hook
def init_keystore(self):
print("init keystore")
@hook
def daemon_wallet_loaded(self,boh,wallet):
print("daemon wallet loaded")
def get_window(self,window):
w = self.bal_windows.get(window.winId,None)
if w is None:
@@ -510,6 +518,7 @@ class BalWindow(Logger):
self.will_tab = self.create_will_tab()
self.ok= False
self.disable_plugin = True
self.bal_plugin.get_decimal_point = self.window.get_decimal_point
if self.window.wallet:
self.wallet = self.window.wallet
@@ -628,7 +637,7 @@ class BalWindow(Logger):
heir_address.setText(str(heir[0]))
heir_amount = PercAmountEdit(self.window.get_decimal_point)
if heir:
heir_amount.setText(str(Util.decode_amount(heir[1],self.bal_plugin.config.get_decimal_point())))
heir_amount.setText(str(Util.decode_amount(heir[1],self.window.get_decimal_point())))
heir_locktime = HeirsLockTimeEdit(self.window,0)
if heir:
heir_locktime.set_locktime(heir[2])
@@ -673,7 +682,7 @@ class BalWindow(Logger):
heir = [
heir_name.text(),
heir_address.text(),
Util.encode_amount(heir_amount.text(),self.bal_plugin.config.get_decimal_point()),
Util.encode_amount(heir_amount.text(),self.window.get_decimal_point()),
str(heir_locktime.get_locktime()),
]
try:
@@ -744,7 +753,7 @@ class BalWindow(Logger):
f=True
if not f:
raise NoWillExecutorNotPresent("No Will-Executor or backup transaction selected")
txs = self.heirs.get_transactions(self.bal_plugin,self.window.wallet,self.will_settings['tx_fees'],None,self.date_to_check)
txs = self.heirs.get_transactions(self.bal_plugin,self.window.wallet,self.will_settings['baltx_fees'],None,self.date_to_check)
self.logger.info(txs)
creation_time = time.time()
if txs:
@@ -758,7 +767,7 @@ class BalWindow(Logger):
tx['description'] = txs[txid].description
tx['willexecutor'] = copy.deepcopy(txs[txid].willexecutor)
tx['status'] = _("New")
tx['tx_fees'] = txs[txid].tx_fees
tx['baltx_fees'] = txs[txid].tx_fees
tx['time'] = creation_time
tx['heirs'] = copy.deepcopy(txs[txid].heirs)
tx['txchildren'] = []
@@ -770,7 +779,7 @@ class BalWindow(Logger):
return self.willitems
def check_will(self):
return Will.is_will_valid(self.willitems, self.block_to_check, self.date_to_check, self.will_settings['tx_fees'],self.window.wallet.get_utxos(),heirs=self.heirs,willexecutors=self.willexecutors ,self_willexecutor=self.no_willexecutor, wallet = self.wallet, callback_not_valid_tx=self.delete_not_valid)
return Will.is_will_valid(self.willitems, self.block_to_check, self.date_to_check, self.will_settings['baltx_fees'],self.window.wallet.get_utxos(),heirs=self.heirs,willexecutors=self.willexecutors ,self_willexecutor=self.no_willexecutor, wallet = self.wallet, callback_not_valid_tx=self.delete_not_valid)
def show_message(self,text):
self.window.show_message(text)
def show_warning(self,text,parent =None):
@@ -918,7 +927,7 @@ class BalWindow(Logger):
def on_failure(exec_info):
self.show_error(f"ERROR:{exec_info}")
fee_per_byte=self.will_settings.get('tx_fees',1)
fee_per_byte=self.will_settings.get('baltx_fees',1)
task = partial(Will.invalidate_will,self.willitems,self.wallet,fee_per_byte)
msg = _("Calculating Transactions")
self.waiting_dialog = BalWaitingDialog(self, msg, task, on_success, on_failure,exe=False)
@@ -1107,7 +1116,6 @@ class BalWindow(Logger):
def check_transactions_task(self,will):
start = time.time()
for wid,w in will.items():
if w.we:
self.waiting_dialog.update("checking transaction: {}\n willexecutor: {}".format(wid,w.we['url']))
w.check_willexecutor()
@@ -1722,11 +1730,11 @@ class BalWizardLocktimeAndFeeWidget(BalWizardWidget):
self.heir_tx_fees.setMinimum(1)
self.heir_tx_fees.setMaximum(10000)
self.heir_tx_fees.setValue(will_settings['tx_fees'])
self.heir_tx_fees.setValue(will_settings['baltx_fees'])
def on_heir_tx_fees():
if not self.heir_tx_fees.value():
self.heir_tx_fees.set_value(1)
self.bal_window.will_settings['tx_fees'] = self.heir_tx_fees.value()
self.bal_window.will_settings['baltx_fees'] = self.heir_tx_fees.value()
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
self.heir_tx_fees.valueChanged.connect(on_heir_tx_fees)
@@ -1894,7 +1902,7 @@ class BalBuildWillDialog(BalDialog):
self.msg_set_checking('Ok')
except WillExpiredException as e:
self.msg_set_checking("Expired")
fee_per_byte=self.bal_window.will_settings.get('tx_fees',1)
fee_per_byte=self.bal_window.will_settings.get('baltx_fees',1)
return None, Will.invalidate_will(self.bal_window.willitems,self.bal_window.wallet,fee_per_byte)
except NoHeirsException:
self.msg_set_checking("No Heirs")
@@ -2194,7 +2202,7 @@ class HeirList(MyTreeView,MessageBoxMixin):
stretch_column=self.Columns.NAME,
editable_columns=[self.Columns.NAME,self.Columns.ADDRESS,self.Columns.AMOUNT],
)
self.decimal_point = bal_window.bal_plugin.config.get_decimal_point()
self.decimal_point = bal_window.window.get_decimal_point()
self.bal_window = bal_window
try:
@@ -2340,7 +2348,7 @@ class HeirList(MyTreeView,MessageBoxMixin):
def on_heir_tx_fees():
if not self.heir_tx_fees.value():
self.heir_tx_fees.set_value(1)
self.bal_window.will_settings['tx_fees'] = self.heir_tx_fees.value()
self.bal_window.will_settings['baltx_fees'] = self.heir_tx_fees.value()
self.bal_window.bal_plugin.WILL_SETTINGS.set(self.bal_window.will_settings)
self.heir_tx_fees.valueChanged.connect(on_heir_tx_fees)
@@ -2382,7 +2390,7 @@ class HeirList(MyTreeView,MessageBoxMixin):
def update_will_settings(self):
try:
self.heir_locktime.set_locktime(self.bal_window.will_settings['locktime'])
self.heir_tx_fees.setValue(int(self.bal_window.will_settings['tx_fees']))
self.heir_tx_fees.setValue(int(self.bal_window.will_settings['baltx_fees']))
self.heir_threshold.set_locktime(self.bal_window.will_settings['threshold'])
except Exception as e:
@@ -2416,7 +2424,7 @@ class PreviewList(MyTreeView):
)
self.parent=parent
self.bal_window=bal_window
self.decimal_point=bal_window.bal_plugin.config.get_decimal_point
self.decimal_point=bal_window.window.get_decimal_point
self.setModel(QStandardItemModel(self))
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
@@ -2631,7 +2639,11 @@ class PreviewList(MyTreeView):
self.update()
def check(self):
self.bal_window.check_transactions(self.bal_window.willitems)
will = {}
for wid, w in self.bal_window.willitems:
if w.get_status("VALID"):
will[wid]=w
self.bal_window.check_transactions(will)
self.update()
def invalidate_will(self):
@@ -2733,7 +2745,7 @@ class WillDetailDialog(BalDialog):
self.format_fiat_and_units = bal_window.window.format_fiat_and_units
self.fx = bal_window.window.fx
self.format_fee_rate = bal_window.window.format_fee_rate
self.decimal_point = bal_window.bal_plugin.config.get_decimal_point()
self.decimal_point = bal_window.window.get_decimal_point()
self.base_unit_name = decimal_point_to_base_unit_name(self.decimal_point)
self.setWindowTitle(_('Will Details'))
self.setMinimumSize(670,700)
@@ -2905,6 +2917,7 @@ class WillExecutorList(MyTreeView):
self.setSortingEnabled(True)
self.std_model = self.model()
self.config =parent.bal_plugin.config
self.get_decimal_point = parent.bal_plugin.get_decimal_point
self.update()
@@ -2977,7 +2990,7 @@ class WillExecutorList(MyTreeView):
self.parent.willexecutors_list[text]=self.parent.willexecutors_list[edit_key]
del self.parent.willexecutors_list[edit_key]
if col == self.Columns.BASE_FEE:
self.parent.willexecutors_list[edit_key]["base_fee"] = Util.encode_amount(text,self.config.get_decimal_point())
self.parent.willexecutors_list[edit_key]["base_fee"] = Util.encode_amount(text,self.get_decimal_point())
if col == self.Columns.ADDRESS:
self.parent.willexecutors_list[edit_key]["address"] = text
if col == self.Columns.INFO:
@@ -3004,7 +3017,7 @@ class WillExecutorList(MyTreeView):
labels[self.Columns.SELECTED] = [read_QIcon('confirmed.png'),'']
else:
labels[self.Columns.SELECTED] = ''
labels[self.Columns.BASE_FEE] = Util.decode_amount(value.get('base_fee',0),self.config.get_decimal_point())
labels[self.Columns.BASE_FEE] = Util.decode_amount(value.get('base_fee',0),self.get_decimal_point())
if str(value.get('status',0)) == "200":
labels[self.Columns.STATUS] = [read_QIcon('status_connected.png'),'']
else: