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():
|
if self.wallet.is_watching_only():
|
||||||
wallet_type += ' [{}]'.format(_('watching-only'))
|
wallet_type += ' [{}]'.format(_('watching-only'))
|
||||||
seed_available = _('True') if self.wallet.has_seed() else _('False')
|
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()
|
grid = QGridLayout()
|
||||||
basename = os.path.basename(self.wallet.storage.path)
|
basename = os.path.basename(self.wallet.storage.path)
|
||||||
grid.addWidget(QLabel(_("Wallet name")+ ':'), 0, 0)
|
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(self.wallet.txin_type), 2, 1)
|
||||||
grid.addWidget(QLabel(_("Seed available") + ':'), 3, 0)
|
grid.addWidget(QLabel(_("Seed available") + ':'), 3, 0)
|
||||||
grid.addWidget(QLabel(str(seed_available)), 3, 1)
|
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)
|
vbox.addLayout(grid)
|
||||||
if self.wallet.is_deterministic():
|
if self.wallet.is_deterministic():
|
||||||
mpk_text = ShowQRTextEdit()
|
mpk_text = ShowQRTextEdit()
|
||||||
|
@ -2106,7 +2111,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
if len(mpk_list) > 1:
|
if len(mpk_list) > 1:
|
||||||
def label(key):
|
def label(key):
|
||||||
if isinstance(self.wallet, Multisig_Wallet):
|
if isinstance(self.wallet, Multisig_Wallet):
|
||||||
return _("cosigner") + ' ' + str(key+1)
|
return f'{_("cosigner")} {key+1} ( keystore: {keystore_types[key]} )'
|
||||||
return ''
|
return ''
|
||||||
labels = [label(i) for i in range(len(mpk_list))]
|
labels = [label(i) for i in range(len(mpk_list))]
|
||||||
on_click = lambda clayout: show_mpk(clayout.selected_index())
|
on_click = lambda clayout: show_mpk(clayout.selected_index())
|
||||||
|
|
|
@ -47,6 +47,9 @@ class KeyStore(PrintError):
|
||||||
def can_import(self):
|
def can_import(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_type_text(self) -> str:
|
||||||
|
return f'{self.type}'
|
||||||
|
|
||||||
def may_have_password(self):
|
def may_have_password(self):
|
||||||
"""Returns whether the keystore can be encrypted with a password."""
|
"""Returns whether the keystore can be encrypted with a password."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
@ -117,6 +120,8 @@ class Software_KeyStore(KeyStore):
|
||||||
class Imported_KeyStore(Software_KeyStore):
|
class Imported_KeyStore(Software_KeyStore):
|
||||||
# keystore for imported private keys
|
# keystore for imported private keys
|
||||||
|
|
||||||
|
type = 'imported'
|
||||||
|
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
Software_KeyStore.__init__(self)
|
Software_KeyStore.__init__(self)
|
||||||
self.keypairs = d.get('keypairs', {})
|
self.keypairs = d.get('keypairs', {})
|
||||||
|
@ -129,7 +134,7 @@ class Imported_KeyStore(Software_KeyStore):
|
||||||
|
|
||||||
def dump(self):
|
def dump(self):
|
||||||
return {
|
return {
|
||||||
'type': 'imported',
|
'type': self.type,
|
||||||
'keypairs': self.keypairs,
|
'keypairs': self.keypairs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +205,7 @@ class Deterministic_KeyStore(Software_KeyStore):
|
||||||
d['seed'] = self.seed
|
d['seed'] = self.seed
|
||||||
if self.passphrase:
|
if self.passphrase:
|
||||||
d['passphrase'] = self.passphrase
|
d['passphrase'] = self.passphrase
|
||||||
|
d['type'] = self.type
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def has_seed(self):
|
def has_seed(self):
|
||||||
|
@ -282,6 +288,8 @@ class Xpub:
|
||||||
|
|
||||||
class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
|
class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
|
||||||
|
|
||||||
|
type = 'bip32'
|
||||||
|
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
Xpub.__init__(self)
|
Xpub.__init__(self)
|
||||||
Deterministic_KeyStore.__init__(self, d)
|
Deterministic_KeyStore.__init__(self, d)
|
||||||
|
@ -293,7 +301,6 @@ class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
|
||||||
|
|
||||||
def dump(self):
|
def dump(self):
|
||||||
d = Deterministic_KeyStore.dump(self)
|
d = Deterministic_KeyStore.dump(self)
|
||||||
d['type'] = 'bip32'
|
|
||||||
d['xpub'] = self.xpub
|
d['xpub'] = self.xpub
|
||||||
d['xprv'] = self.xprv
|
d['xprv'] = self.xprv
|
||||||
return d
|
return d
|
||||||
|
@ -342,6 +349,8 @@ class BIP32_KeyStore(Deterministic_KeyStore, Xpub):
|
||||||
|
|
||||||
class Old_KeyStore(Deterministic_KeyStore):
|
class Old_KeyStore(Deterministic_KeyStore):
|
||||||
|
|
||||||
|
type = 'old'
|
||||||
|
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
Deterministic_KeyStore.__init__(self, d)
|
Deterministic_KeyStore.__init__(self, d)
|
||||||
self.mpk = d.get('mpk')
|
self.mpk = d.get('mpk')
|
||||||
|
@ -352,7 +361,6 @@ class Old_KeyStore(Deterministic_KeyStore):
|
||||||
def dump(self):
|
def dump(self):
|
||||||
d = Deterministic_KeyStore.dump(self)
|
d = Deterministic_KeyStore.dump(self)
|
||||||
d['mpk'] = self.mpk
|
d['mpk'] = self.mpk
|
||||||
d['type'] = 'old'
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def add_seed(self, seedphrase):
|
def add_seed(self, seedphrase):
|
||||||
|
@ -481,7 +489,7 @@ class Hardware_KeyStore(KeyStore, Xpub):
|
||||||
# - DEVICE_IDS
|
# - DEVICE_IDS
|
||||||
# - wallet_type
|
# - wallet_type
|
||||||
|
|
||||||
#restore_wallet_class = BIP32_RD_Wallet
|
type = 'hardware'
|
||||||
max_change_outputs = 1
|
max_change_outputs = 1
|
||||||
|
|
||||||
def __init__(self, d):
|
def __init__(self, d):
|
||||||
|
@ -505,9 +513,12 @@ class Hardware_KeyStore(KeyStore, Xpub):
|
||||||
def is_deterministic(self):
|
def is_deterministic(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_type_text(self) -> str:
|
||||||
|
return f'hw[{self.hw_type}]'
|
||||||
|
|
||||||
def dump(self):
|
def dump(self):
|
||||||
return {
|
return {
|
||||||
'type': 'hardware',
|
'type': self.type,
|
||||||
'hw_type': self.hw_type,
|
'hw_type': self.hw_type,
|
||||||
'xpub': self.xpub,
|
'xpub': self.xpub,
|
||||||
'derivation':self.derivation,
|
'derivation':self.derivation,
|
||||||
|
@ -669,7 +680,8 @@ def hardware_keystore(d):
|
||||||
if hw_type in hw_keystores:
|
if hw_type in hw_keystores:
|
||||||
constructor = hw_keystores[hw_type]
|
constructor = hw_keystores[hw_type]
|
||||||
return constructor(d)
|
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):
|
def load_keystore(storage, name):
|
||||||
d = storage.get(name, {})
|
d = storage.get(name, {})
|
||||||
|
@ -678,17 +690,13 @@ def load_keystore(storage, name):
|
||||||
raise WalletFileException(
|
raise WalletFileException(
|
||||||
'Wallet format requires update.\n'
|
'Wallet format requires update.\n'
|
||||||
'Cannot find keystore for name {}'.format(name))
|
'Cannot find keystore for name {}'.format(name))
|
||||||
if t == 'old':
|
keystore_constructors = {ks.type: ks for ks in [Old_KeyStore, Imported_KeyStore, BIP32_KeyStore]}
|
||||||
k = Old_KeyStore(d)
|
keystore_constructors['hardware'] = hardware_keystore
|
||||||
elif t == 'imported':
|
try:
|
||||||
k = Imported_KeyStore(d)
|
ks_constructor = keystore_constructors[t]
|
||||||
elif t == 'bip32':
|
except KeyError:
|
||||||
k = BIP32_KeyStore(d)
|
raise WalletFileException(f'Unknown type {t} for keystore named {name}')
|
||||||
elif t == 'hardware':
|
k = ks_constructor(d)
|
||||||
k = hardware_keystore(d)
|
|
||||||
else:
|
|
||||||
raise WalletFileException(
|
|
||||||
'Unknown type {} for keystore named {}'.format(t, name))
|
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue