Skip to content

Commit b0c4bfa

Browse files
committed
Add: Root xpublic key derivation cleaner.
1 parent 1aa4438 commit b0c4bfa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

hdwallet/hdwallet.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,13 +719,21 @@ def clean_derivation(self) -> "HDWallet":
719719
None
720720
"""
721721

722-
if self._i:
722+
if self._root_private_key:
723723
self._path, self._depth, self._parent_fingerprint, self._index = (
724724
"m", 0, b"\0\0\0\0", 0
725725
)
726-
self._private_key, self._chain_code = self._i[:32], self._i[32:]
726+
self._private_key, self._chain_code = self._root_private_key
727727
self._key = ecdsa.SigningKey.from_string(self._private_key, curve=SECP256k1)
728728
self._verified_key = self._key.get_verifying_key()
729+
elif self._root_public_key:
730+
self._path, self._depth, self._parent_fingerprint, self._index = (
731+
"m", 0, b"\0\0\0\0", 0
732+
)
733+
self._chain_code = self._root_public_key[1]
734+
self._verified_key = ecdsa.VerifyingKey.from_string(
735+
self._root_public_key[0], curve=SECP256k1
736+
)
729737
return self
730738

731739
def uncompressed(self, compressed: Optional[str] = None) -> str:

0 commit comments

Comments
 (0)