mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
qt wallet information: added keystore type
This commit is contained in:
parent
2a60a701bf
commit
b68729115a
2 changed files with 31 additions and 18 deletions
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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())
|
||||
|
|
|
@ -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()
|
||||
|
@ -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', {})
|
||||
|
@ -129,7 +134,7 @@ class Imported_KeyStore(Software_KeyStore):
|
|||
|
||||
def dump(self):
|
||||
return {
|
||||
'type': 'imported',
|
||||
'type': self.type,
|
||||
'keypairs': self.keypairs,
|
||||
}
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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,
|
||||
|
@ -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, {})
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue