electrum icon indicating copy to clipboard operation
electrum copied to clipboard

WalletDB: add more type-check asserts, adb: change adb_added_verified_tx evt API

Open SomberNight opened this issue 5 months ago • 2 comments

  • WalletDB: add more asserts to {add,get}|_verified_tx
    • to fail early before writing to and right after reading from db
  • wallet: change adb_added_verified_tx evt API, passthrough txminedinfo
    • call adb.get_tx_height(tx_hash) earlier, and pass result through subsequent events
    • add assert to sanity-check result right after it is calculated
  • WalletDB: further tighten type-check asserts

This might fix https://github.com/spesmilo/electrum/issues/10098 or at least give us tracebacks that are closer to the cause.

SomberNight avatar Aug 04 '25 17:08 SomberNight

outstanding issue:

Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\util.py", line 1492, in on_qt_callback_signal
    return func(self, *args[1:])
  File "...\electrum\electrum\gui\qt\main_window.py", line 512, in on_event_blockchain_updated
    self.refresh_tabs()
  File "...\electrum\electrum\gui\qt\main_window.py", line 1150, in refresh_tabs
    self.history_model.refresh('refresh_tabs')
  File "...\electrum\electrum\util.py", line 509, in do_profile
    o = func(*args, **kw_args)
  File "...\electrum\electrum\gui\qt\history_list.py", line 300, in refresh
    transactions = wallet.get_full_history(
  File "...\electrum\electrum\util.py", line 509, in do_profile
    o = func(*args, **kw_args)
  File "...\electrum\electrum\wallet.py", line 1517, in get_full_history
    fiat_fields = self.get_tx_item_fiat(tx_hash=txid, amount_sat=value, fx=fx, tx_fee=item['fee_sat'])
  File "...\electrum\electrum\wallet.py", line 1652, in get_tx_item_fiat
    fiat_rate = self.price_at_timestamp(tx_hash, fx.timestamp_rate)
  File "...\electrum\electrum\wallet.py", line 3197, in price_at_timestamp
    timestamp = self.adb.get_tx_height(txid).timestamp
  File "...\electrum\electrum\address_synchronizer.py", line 719, in get_tx_height
    if verified_tx_mined_info := self.db.get_verified_tx(tx_hash):  # mined and spv-ed
  File "...\electrum\electrum\json_db.py", line 65, in wrapper
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\wallet_db.py", line 1507, in get_verified_tx
    assert is_hash256_str(txid), txid
AssertionError: ----

https://github.com/spesmilo/electrum/blob/825f3f152b0985d8acad273e67336e76b955960e/electrum/wallet.py#L1486

SomberNight avatar Aug 04 '25 18:08 SomberNight

related: https://github.com/spesmilo/electrum/tree/history_cleanup_part2

ecdsa avatar Sep 26 '25 14:09 ecdsa