mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
ledger: bump min btchip-python version
and minor simplification
This commit is contained in:
parent
c1101ee258
commit
48993118ad
2 changed files with 22 additions and 13 deletions
|
@ -11,7 +11,7 @@ Cython>=0.27
|
|||
trezor[hidapi]>=0.12.0
|
||||
safet>=0.1.5
|
||||
keepkey>=6.3.1
|
||||
btchip-python>=0.1.26
|
||||
btchip-python>=0.1.30
|
||||
ckcc-protocol>=0.7.7
|
||||
bitbox02>=3.0.0
|
||||
hidapi
|
||||
|
|
|
@ -18,7 +18,7 @@ from electrum.base_wizard import ScriptTypeNotSupported
|
|||
from electrum.logging import get_logger
|
||||
|
||||
from ..hw_wallet import HW_PluginBase, HardwareClientBase
|
||||
from ..hw_wallet.plugin import is_any_tx_output_on_change_branch, validate_op_return_output
|
||||
from ..hw_wallet.plugin import is_any_tx_output_on_change_branch, validate_op_return_output, LibraryFoundButUnusable
|
||||
|
||||
|
||||
_logger = get_logger(__name__)
|
||||
|
@ -45,7 +45,6 @@ MULTI_OUTPUT_SUPPORT = '1.1.4'
|
|||
SEGWIT_SUPPORT = '1.1.10'
|
||||
SEGWIT_SUPPORT_SPECIAL = '1.0.4'
|
||||
SEGWIT_TRUSTEDINPUTS = '1.4.0'
|
||||
UTIL_SEGWIT_TRUSTEDINPUTS = '0.1.29'
|
||||
|
||||
|
||||
def test_pin_unlocked(func):
|
||||
|
@ -188,12 +187,7 @@ class Ledger_Client(HardwareClientBase):
|
|||
self.multiOutputSupported = versiontuple(firmware) >= versiontuple(MULTI_OUTPUT_SUPPORT)
|
||||
self.nativeSegwitSupported = versiontuple(firmware) >= versiontuple(SEGWIT_SUPPORT)
|
||||
self.segwitSupported = self.nativeSegwitSupported or (firmwareInfo['specialVersion'] == 0x20 and versiontuple(firmware) >= versiontuple(SEGWIT_SUPPORT_SPECIAL))
|
||||
try:
|
||||
import btchip
|
||||
utilVersion = btchip.__version__
|
||||
except:
|
||||
utilVersion = "0.0.0"
|
||||
self.segwitTrustedInputs = versiontuple(firmware) >= versiontuple(SEGWIT_TRUSTEDINPUTS) and versiontuple(utilVersion) >= versiontuple(UTIL_SEGWIT_TRUSTEDINPUTS)
|
||||
self.segwitTrustedInputs = versiontuple(firmware) >= versiontuple(SEGWIT_TRUSTEDINPUTS)
|
||||
|
||||
if not checkFirmware(firmwareInfo):
|
||||
self.close()
|
||||
|
@ -454,7 +448,7 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
|||
tmp += bfh(int_to_hex(utxo[6], 8)) # txin['value']
|
||||
chipInputs.append({'value' : tmp, 'witness' : True, 'sequence' : sequence})
|
||||
redeemScripts.append(bfh(utxo[2]))
|
||||
elif (not p2shTransaction) or (p2shTransaction and client_electrum.supports_multi_output()):
|
||||
elif (not p2shTransaction) or client_electrum.supports_multi_output():
|
||||
txtmp = bitcoinTransaction(bfh(utxo[0]))
|
||||
trustedInput = self.get_client().getTrustedInput(txtmp, utxo[1])
|
||||
trustedInput['sequence'] = sequence
|
||||
|
@ -573,8 +567,8 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
|||
self.handler.finished()
|
||||
|
||||
class LedgerPlugin(HW_PluginBase):
|
||||
libraries_available = BTCHIP
|
||||
keystore_class = Ledger_KeyStore
|
||||
minimum_library = (0, 1, 30)
|
||||
client = None
|
||||
DEVICE_IDS = [
|
||||
(0x2581, 0x1807), # HW.1 legacy btchip
|
||||
|
@ -596,8 +590,23 @@ class LedgerPlugin(HW_PluginBase):
|
|||
def __init__(self, parent, config, name):
|
||||
self.segwit = config.get("segwit")
|
||||
HW_PluginBase.__init__(self, parent, config, name)
|
||||
if self.libraries_available:
|
||||
self.device_manager().register_devices(self.DEVICE_IDS, plugin=self)
|
||||
self.libraries_available = self.check_libraries_available()
|
||||
if not self.libraries_available:
|
||||
return
|
||||
self.device_manager().register_devices(self.DEVICE_IDS, plugin=self)
|
||||
|
||||
def get_library_version(self):
|
||||
try:
|
||||
import btchip
|
||||
version = btchip.__version__
|
||||
except ImportError:
|
||||
raise
|
||||
except:
|
||||
version = "unknown"
|
||||
if BTCHIP:
|
||||
return version
|
||||
else:
|
||||
raise LibraryFoundButUnusable(library_version=version)
|
||||
|
||||
def get_btchip_device(self, device):
|
||||
ledger = False
|
||||
|
|
Loading…
Add table
Reference in a new issue