mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
Merge pull request #3703 from SomberNight/ledger_pin_lock_exc
ledger: handle pin-locked state better
This commit is contained in:
commit
333b17fa60
1 changed files with 16 additions and 1 deletions
|
@ -60,6 +60,21 @@ class Ledger_Client():
|
||||||
def versiontuple(self, v):
|
def versiontuple(self, v):
|
||||||
return tuple(map(int, (v.split("."))))
|
return tuple(map(int, (v.split("."))))
|
||||||
|
|
||||||
|
def test_pin_unlocked(func):
|
||||||
|
"""Function decorator to test the Ledger for being unlocked, and if not,
|
||||||
|
raise a human-readable exception.
|
||||||
|
"""
|
||||||
|
def catch_exception(self, *args, **kwargs):
|
||||||
|
try:
|
||||||
|
return func(self, *args, **kwargs)
|
||||||
|
except BTChipException as e:
|
||||||
|
if e.sw == 0x6982:
|
||||||
|
raise Exception(_('Your Ledger is locked. Please unlock it.'))
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
return catch_exception
|
||||||
|
|
||||||
|
@test_pin_unlocked
|
||||||
def get_xpub(self, bip32_path, xtype):
|
def get_xpub(self, bip32_path, xtype):
|
||||||
self.checkDevice()
|
self.checkDevice()
|
||||||
# bip32_path is of the form 44'/0'/1'
|
# bip32_path is of the form 44'/0'/1'
|
||||||
|
@ -80,7 +95,7 @@ class Ledger_Client():
|
||||||
if len(splitPath) > 1:
|
if len(splitPath) > 1:
|
||||||
prevPath = "/".join(splitPath[0:len(splitPath) - 1])
|
prevPath = "/".join(splitPath[0:len(splitPath) - 1])
|
||||||
nodeData = self.dongleObject.getWalletPublicKey(prevPath)
|
nodeData = self.dongleObject.getWalletPublicKey(prevPath)
|
||||||
publicKey = compress_public_key(nodeData['publicKey'])#
|
publicKey = compress_public_key(nodeData['publicKey'])
|
||||||
h = hashlib.new('ripemd160')
|
h = hashlib.new('ripemd160')
|
||||||
h.update(hashlib.sha256(publicKey).digest())
|
h.update(hashlib.sha256(publicKey).digest())
|
||||||
fingerprint = unpack(">I", h.digest()[0:4])[0]
|
fingerprint = unpack(">I", h.digest()[0:4])[0]
|
||||||
|
|
Loading…
Add table
Reference in a new issue