clean-up hw-wallet "get_password_for_storage_encryption"-related code
This commit is contained in:
@@ -32,10 +32,11 @@ from electrum.bitcoin import is_address, opcodes
|
||||
from electrum.util import bfh, versiontuple, UserFacingException
|
||||
from electrum.transaction import TxOutput, Transaction, PartialTransaction, PartialTxInput, PartialTxOutput
|
||||
from electrum.bip32 import BIP32Node
|
||||
from electrum.storage import get_derivation_used_for_hw_device_encryption
|
||||
from electrum.keystore import Xpub, Hardware_KeyStore
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from electrum.wallet import Abstract_Wallet
|
||||
from electrum.keystore import Hardware_KeyStore
|
||||
|
||||
|
||||
class HW_PluginBase(BasePlugin):
|
||||
@@ -69,7 +70,7 @@ class HW_PluginBase(BasePlugin):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_client(self, keystore: 'Hardware_KeyStore', force_pair: bool = True):
|
||||
def get_client(self, keystore: 'Hardware_KeyStore', force_pair: bool = True) -> Optional['HardwareClientBase']:
|
||||
raise NotImplementedError()
|
||||
|
||||
def show_address(self, wallet: 'Abstract_Wallet', address, keystore: 'Hardware_KeyStore' = None):
|
||||
@@ -182,6 +183,13 @@ class HardwareClientBase:
|
||||
root_fingerprint = BIP32Node.from_xkey(child_of_root_xpub).fingerprint.hex().lower()
|
||||
return root_fingerprint
|
||||
|
||||
def get_password_for_storage_encryption(self) -> str:
|
||||
# note: using a different password based on hw device type is highly undesirable! see #5993
|
||||
derivation = get_derivation_used_for_hw_device_encryption()
|
||||
xpub = self.get_xpub(derivation, "standard")
|
||||
password = Xpub.get_pubkey_from_xpub(xpub, ()).hex()
|
||||
return password
|
||||
|
||||
|
||||
def is_any_tx_output_on_change_branch(tx: PartialTransaction) -> bool:
|
||||
return any([txout.is_change for txout in tx.outputs()])
|
||||
|
||||
Reference in New Issue
Block a user