1
0

qt: fix: addresses tab broken for imported watchonly wallets

fixes https://github.com/spesmilo/electrum/issues/10435

regression from https://github.com/spesmilo/electrum/pull/10376
This commit is contained in:
SomberNight
2026-01-23 17:35:14 +00:00
parent 69093cc183
commit 0e07128ccf
2 changed files with 13 additions and 4 deletions

View File

@@ -25,7 +25,7 @@
import enum
from enum import IntEnum
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Optional
from PyQt6.QtCore import Qt, QPersistentModelIndex, QModelIndex
from PyQt6.QtGui import QStandardItemModel, QStandardItem, QFont
@@ -244,8 +244,14 @@ class AddressList(MyTreeView):
# update counter
self.num_addr_label.setText(_("{} addresses").format(num_shown))
def address_index_as_sortable_key(self, address_index: 'AddressIndexGeneric'):
return address_index if isinstance(address_index, str) else ''.join(f'{i:08x}' for i in address_index)
@staticmethod
def address_index_as_sortable_key(address_index: Optional['AddressIndexGeneric']) -> str:
if isinstance(address_index, str): # pubkey hex
return address_index
elif address_index is None:
return ""
else:
return "".join(f"{i:08x}" for i in address_index)
def refresh_row(self, key, row):
assert row is not None

View File

@@ -3784,7 +3784,10 @@ class Imported_Wallet(Simple_Wallet):
return self.db.has_imported_address(address)
def get_address_index(self, address) -> Optional[str]:
# returns None if address is not mine
# Return pubkey for address if we know it.
# If we don't know it, return None, which might happen:
# - if address is not is_mine
# - if this is an "imported address", we don't have the pubkey for. (watch-only imported wallet)
return self.get_public_key(address)
def get_address_path_str(self, address):