URI: 
       tqt wallet information: added keystore type - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit b68729115aed62651da1f83c1106d5f24963a993
   DIR parent 2a60a701bfb4bada026795fdb92cd1644d58bb48
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Tue, 23 Oct 2018 02:54:54 +0200
       
       qt wallet information: added keystore type
       
       Diffstat:
         M electrum/gui/qt/main_window.py      |       7 ++++++-
         M electrum/keystore.py                |      42 ++++++++++++++++++-------------
       
       2 files changed, 31 insertions(+), 18 deletions(-)
       ---
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -2085,6 +2085,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                if self.wallet.is_watching_only():
                    wallet_type += ' [{}]'.format(_('watching-only'))
                seed_available = _('True') if self.wallet.has_seed() else _('False')
       +        keystore_types = [k.get_type_text() for k in self.wallet.get_keystores()]
                grid = QGridLayout()
                basename = os.path.basename(self.wallet.storage.path)
                grid.addWidget(QLabel(_("Wallet name")+ ':'), 0, 0)
       t@@ -2095,6 +2096,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                grid.addWidget(QLabel(self.wallet.txin_type), 2, 1)
                grid.addWidget(QLabel(_("Seed available") + ':'), 3, 0)
                grid.addWidget(QLabel(str(seed_available)), 3, 1)
       +        if len(keystore_types) <= 1:
       +            grid.addWidget(QLabel(_("Keystore type") + ':'), 4, 0)
       +            ks_type = str(keystore_types[0]) if keystore_types else _('No keystore')
       +            grid.addWidget(QLabel(ks_type), 4, 1)
                vbox.addLayout(grid)
                if self.wallet.is_deterministic():
                    mpk_text = ShowQRTextEdit()
       t@@ -2106,7 +2111,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                    if len(mpk_list) > 1:
                        def label(key):
                            if isinstance(self.wallet, Multisig_Wallet):
       -                        return _("cosigner") + ' ' + str(key+1)
       +                        return f'{_("cosigner")} {key+1} ( keystore: {keystore_types[key]} )'
                            return ''
                        labels = [label(i) for i in range(len(mpk_list))]
                        on_click = lambda clayout: show_mpk(clayout.selected_index())
   DIR diff --git a/electrum/keystore.py b/electrum/keystore.py
       t@@ -47,6 +47,9 @@ class KeyStore(PrintError):
            def can_import(self):
                return False
        
       +    def get_type_text(self) -> str:
       +        return f'{self.type}'
       +
            def may_have_password(self):
                """Returns whether the keystore can be encrypted with a password."""
                raise NotImplementedError()
       t@@ -117,6 +120,8 @@ class Software_KeyStore(KeyStore):
        class Imported_KeyStore(Software_KeyStore):
            # keystore for imported private keys
        
       +    type = 'imported'
       +
            def __init__(self, d):
                Software_KeyStore.__init__(self)
                self.keypairs = d.get('keypairs', {})
       t@@ -129,7 +134,7 @@ class Imported_KeyStore(Software_KeyStore):
        
            def dump(self):
                return {
       -            'type': 'imported',
       +            'type': self.type,
                    'keypairs': self.keypairs,
                }
        
       t@@ -200,6 +205,7 @@ class Deterministic_KeyStore(Software_KeyStore):
                    d['seed'] = self.seed
                if self.passphrase:
                    d['passphrase'] = self.passphrase
       +        d['type'] = self.type
                return d
        
            def has_seed(self):
       t@@ -282,6 +288,8 @@ class Xpub:
        
        class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
        
       +    type = 'bip32'
       +
            def __init__(self, d):
                Xpub.__init__(self)
                Deterministic_KeyStore.__init__(self, d)
       t@@ -293,7 +301,6 @@ class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
        
            def dump(self):
                d = Deterministic_KeyStore.dump(self)
       -        d['type'] = 'bip32'
                d['xpub'] = self.xpub
                d['xprv'] = self.xprv
                return d
       t@@ -342,6 +349,8 @@ class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
        
        class Old_KeyStore(Deterministic_KeyStore):
        
       +    type = 'old'
       +
            def __init__(self, d):
                Deterministic_KeyStore.__init__(self, d)
                self.mpk = d.get('mpk')
       t@@ -352,7 +361,6 @@ class Old_KeyStore(Deterministic_KeyStore):
            def dump(self):
                d = Deterministic_KeyStore.dump(self)
                d['mpk'] = self.mpk
       -        d['type'] = 'old'
                return d
        
            def add_seed(self, seedphrase):
       t@@ -481,7 +489,7 @@ class Hardware_KeyStore(KeyStore, Xpub):
            #   - DEVICE_IDS
            #   - wallet_type
        
       -    #restore_wallet_class = BIP32_RD_Wallet
       +    type = 'hardware'
            max_change_outputs = 1
        
            def __init__(self, d):
       t@@ -505,9 +513,12 @@ class Hardware_KeyStore(KeyStore, Xpub):
            def is_deterministic(self):
                return True
        
       +    def get_type_text(self) -> str:
       +        return f'hw[{self.hw_type}]'
       +
            def dump(self):
                return {
       -            'type': 'hardware',
       +            'type': self.type,
                    'hw_type': self.hw_type,
                    'xpub': self.xpub,
                    'derivation':self.derivation,
       t@@ -669,7 +680,8 @@ def hardware_keystore(d):
            if hw_type in hw_keystores:
                constructor = hw_keystores[hw_type]
                return constructor(d)
       -    raise WalletFileException('unknown hardware type: {}. hw_keystores: {}'.format(hw_type, list(hw_keystores.keys())))
       +    raise WalletFileException(f'unknown hardware type: {hw_type}. '
       +                              f'hw_keystores: {list(hw_keystores)}')
        
        def load_keystore(storage, name):
            d = storage.get(name, {})
       t@@ -678,17 +690,13 @@ def load_keystore(storage, name):
                raise WalletFileException(
                    'Wallet format requires update.\n'
                    'Cannot find keystore for name {}'.format(name))
       -    if t == 'old':
       -        k = Old_KeyStore(d)
       -    elif t == 'imported':
       -        k = Imported_KeyStore(d)
       -    elif t == 'bip32':
       -        k = BIP32_KeyStore(d)
       -    elif t == 'hardware':
       -        k = hardware_keystore(d)
       -    else:
       -        raise WalletFileException(
       -            'Unknown type {} for keystore named {}'.format(t, name))
       +    keystore_constructors = {ks.type: ks for ks in [Old_KeyStore, Imported_KeyStore, BIP32_KeyStore]}
       +    keystore_constructors['hardware'] = hardware_keystore
       +    try:
       +        ks_constructor = keystore_constructors[t]
       +    except KeyError:
       +        raise WalletFileException(f'Unknown type {t} for keystore named {name}')
       +    k = ks_constructor(d)
            return k