From cef3c29c7313719cb00e652973b1a1d564bf1a59 Mon Sep 17 00:00:00 2001 From: kyurais Date: Tue, 28 Nov 2023 19:45:49 +0400 Subject: [PATCH] Added return statement to HDWallet.from_index if hardened is True. Change return type to Optional to mirror the return type of called method --- hdwallet/hdwallet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hdwallet/hdwallet.py b/hdwallet/hdwallet.py index a66ac84d..b36fc81b 100644 --- a/hdwallet/hdwallet.py +++ b/hdwallet/hdwallet.py @@ -455,7 +455,7 @@ def from_path(self, path: Union[str, Derivation]) -> "HDWallet": self._path += str("/" + index) return self - def from_index(self, index: int, hardened: bool = False) -> "HDWallet": + def from_index(self, index: int, hardened: bool = False) -> Optional["HDWallet"]: """ Derivation from Index. @@ -464,7 +464,7 @@ def from_index(self, index: int, hardened: bool = False) -> "HDWallet": :param hardened: Hardened address, default to ``False``. :type hardened: bool - :returns: HDWallet -- Hierarchical Deterministic Wallet instance. + :returns: Optional[HDWallet] -- Hierarchical Deterministic Wallet instance. >>> from hdwallet import HDWallet >>> from hdwallet.symbols import BTC @@ -483,7 +483,7 @@ def from_index(self, index: int, hardened: bool = False) -> "HDWallet": if hardened: self._path += ("/%d'" % index) - self._derive_key_by_index(index + BIP32KEY_HARDEN) + return self._derive_key_by_index(index + BIP32KEY_HARDEN) else: self._path += ("/%d" % index) return self._derive_key_by_index(index)