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:
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import enum
|
import enum
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from PyQt6.QtCore import Qt, QPersistentModelIndex, QModelIndex
|
from PyQt6.QtCore import Qt, QPersistentModelIndex, QModelIndex
|
||||||
from PyQt6.QtGui import QStandardItemModel, QStandardItem, QFont
|
from PyQt6.QtGui import QStandardItemModel, QStandardItem, QFont
|
||||||
@@ -244,8 +244,14 @@ class AddressList(MyTreeView):
|
|||||||
# update counter
|
# update counter
|
||||||
self.num_addr_label.setText(_("{} addresses").format(num_shown))
|
self.num_addr_label.setText(_("{} addresses").format(num_shown))
|
||||||
|
|
||||||
def address_index_as_sortable_key(self, address_index: 'AddressIndexGeneric'):
|
@staticmethod
|
||||||
return address_index if isinstance(address_index, str) else ''.join(f'{i:08x}' for i in address_index)
|
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):
|
def refresh_row(self, key, row):
|
||||||
assert row is not None
|
assert row is not None
|
||||||
|
|||||||
@@ -3784,7 +3784,10 @@ class Imported_Wallet(Simple_Wallet):
|
|||||||
return self.db.has_imported_address(address)
|
return self.db.has_imported_address(address)
|
||||||
|
|
||||||
def get_address_index(self, address) -> Optional[str]:
|
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)
|
return self.get_public_key(address)
|
||||||
|
|
||||||
def get_address_path_str(self, address):
|
def get_address_path_str(self, address):
|
||||||
|
|||||||
Reference in New Issue
Block a user