mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
keystore: 'get_tx_derivations' no longer public
This commit is contained in:
parent
beee880dba
commit
07f5d6b745
4 changed files with 12 additions and 9 deletions
|
@ -33,6 +33,7 @@ from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from . import bitcoin, ecc, constants, bip32
|
from . import bitcoin, ecc, constants, bip32
|
||||||
from .bitcoin import deserialize_privkey, serialize_privkey
|
from .bitcoin import deserialize_privkey, serialize_privkey
|
||||||
|
from .transaction import Transaction, PartialTransaction, PartialTxInput, PartialTxOutput
|
||||||
from .bip32 import (convert_bip32_path_to_list_of_uint32, BIP32_PRIME,
|
from .bip32 import (convert_bip32_path_to_list_of_uint32, BIP32_PRIME,
|
||||||
is_xpub, is_xprv, BIP32Node, normalize_bip32_derivation,
|
is_xpub, is_xprv, BIP32Node, normalize_bip32_derivation,
|
||||||
convert_bip32_intpath_to_strpath)
|
convert_bip32_intpath_to_strpath)
|
||||||
|
@ -47,7 +48,6 @@ from .logging import Logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .gui.qt.util import TaskThread
|
from .gui.qt.util import TaskThread
|
||||||
from .transaction import Transaction, PartialTransaction, PartialTxInput, PartialTxOutput
|
|
||||||
from .plugins.hw_wallet import HW_PluginBase, HardwareClientBase
|
from .plugins.hw_wallet import HW_PluginBase, HardwareClientBase
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class KeyStore(Logger, ABC):
|
||||||
"""Returns whether the keystore can be encrypted with a password."""
|
"""Returns whether the keystore can be encrypted with a password."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_tx_derivations(self, tx: 'PartialTransaction') -> Dict[str, Union[Sequence[int], str]]:
|
def _get_tx_derivations(self, tx: 'PartialTransaction') -> Dict[str, Union[Sequence[int], str]]:
|
||||||
keypairs = {}
|
keypairs = {}
|
||||||
for txin in tx.inputs():
|
for txin in tx.inputs():
|
||||||
if txin.is_complete():
|
if txin.is_complete():
|
||||||
|
@ -90,10 +90,13 @@ class KeyStore(Logger, ABC):
|
||||||
keypairs[pubkey.hex()] = derivation
|
keypairs[pubkey.hex()] = derivation
|
||||||
return keypairs
|
return keypairs
|
||||||
|
|
||||||
def can_sign(self, tx) -> bool:
|
def can_sign(self, tx: 'Transaction', *, ignore_watching_only=False) -> bool:
|
||||||
if self.is_watching_only():
|
"""Returns whether this keystore could sign *something* in this tx."""
|
||||||
|
if not ignore_watching_only and self.is_watching_only():
|
||||||
return False
|
return False
|
||||||
return bool(self.get_tx_derivations(tx))
|
if not isinstance(tx, PartialTransaction):
|
||||||
|
return False
|
||||||
|
return bool(self._get_tx_derivations(tx))
|
||||||
|
|
||||||
def ready_to_sign(self) -> bool:
|
def ready_to_sign(self) -> bool:
|
||||||
return not self.is_watching_only()
|
return not self.is_watching_only()
|
||||||
|
@ -169,7 +172,7 @@ class Software_KeyStore(KeyStore):
|
||||||
# Raise if password is not correct.
|
# Raise if password is not correct.
|
||||||
self.check_password(password)
|
self.check_password(password)
|
||||||
# Add private keys
|
# Add private keys
|
||||||
keypairs = self.get_tx_derivations(tx)
|
keypairs = self._get_tx_derivations(tx)
|
||||||
for k, v in keypairs.items():
|
for k, v in keypairs.items():
|
||||||
keypairs[k] = self.get_private_key(v, password)
|
keypairs[k] = self.get_private_key(v, password)
|
||||||
# Sign
|
# Sign
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Plugin(TrustedCoinPlugin):
|
||||||
if not wallet.can_sign_without_server():
|
if not wallet.can_sign_without_server():
|
||||||
self.logger.info("twofactor:sign_tx")
|
self.logger.info("twofactor:sign_tx")
|
||||||
auth_code = None
|
auth_code = None
|
||||||
if wallet.keystores['x3/'].get_tx_derivations(tx):
|
if wallet.keystores['x3/'].can_sign(tx, ignore_watching_only=True):
|
||||||
msg = _('Please enter your Google Authenticator code:')
|
msg = _('Please enter your Google Authenticator code:')
|
||||||
auth_code = int(input(msg))
|
auth_code = int(input(msg))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -66,7 +66,7 @@ class HandlerTwoFactor(QObject, Logger):
|
||||||
return
|
return
|
||||||
if wallet.can_sign_without_server():
|
if wallet.can_sign_without_server():
|
||||||
return
|
return
|
||||||
if not wallet.keystores['x3/'].get_tx_derivations(tx):
|
if not wallet.keystores['x3/'].can_sign(tx, ignore_watching_only=True):
|
||||||
self.logger.info("twofactor: xpub3 not needed")
|
self.logger.info("twofactor: xpub3 not needed")
|
||||||
return
|
return
|
||||||
window = self.window.top_level_window()
|
window = self.window.top_level_window()
|
||||||
|
|
|
@ -458,7 +458,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||||
return
|
return
|
||||||
if wallet.can_sign_without_server():
|
if wallet.can_sign_without_server():
|
||||||
return
|
return
|
||||||
if not wallet.keystores['x3/'].get_tx_derivations(tx):
|
if not wallet.keystores['x3/'].can_sign(tx, ignore_watching_only=True):
|
||||||
self.logger.info("twofactor: xpub3 not needed")
|
self.logger.info("twofactor: xpub3 not needed")
|
||||||
return
|
return
|
||||||
def wrapper(tx):
|
def wrapper(tx):
|
||||||
|
|
Loading…
Add table
Reference in a new issue