Skip to content

Commit dd259b7

Browse files
committed
Fix: root_xprivate_key & xprivate_key funcs of CardanoHD
1 parent 172f031 commit dd259b7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

hdwallet/hds/cardano.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,38 @@ def new_public_key_point(public_key: IPublicKey, zl: bytes, ecc: IEllipticCurveC
398398
)
399399
return self
400400

401+
def root_xprivate_key(
402+
self, version: Union[bytes, int] = Cardano.NETWORKS.MAINNET.XPRIVATE_KEY_VERSIONS.P2PKH, encoded: bool = True
403+
) -> Optional[str]:
404+
"""
405+
Generates the root extended private key (xprv) in serialized format.
406+
407+
:param version: The version bytes for the extended key. Defaults to Bitcoin mainnet P2PKH version.
408+
:type version: Union[bytes, int]
409+
:param encoded: Whether to return the key in encoded format. Defaults to True.
410+
:type encoded: bool
411+
412+
:return: The root extended private key (xprv) in serialized format, or None if the chain code is not set.
413+
:rtype: Optional[str]
414+
"""
415+
return super(CardanoHD, self).root_xprivate_key(version=version, encoded=encoded)
416+
417+
def xprivate_key(
418+
self, version: Union[bytes, int] = Cardano.NETWORKS.MAINNET.XPRIVATE_KEY_VERSIONS.P2PKH, encoded: bool = True
419+
) -> Optional[str]:
420+
"""
421+
Retrieves the extended private key (xprivate key) as a serialized string.
422+
423+
:param version: The version bytes or integer version of the xprivate key.
424+
:type version: Union[bytes, int]
425+
:param encoded: Flag indicating whether the key should be encoded.
426+
:type encoded: bool
427+
428+
:return: The serialized xprivate key as a string, or None if the private key or chain code is not set.
429+
:rtype: Optional[str]
430+
"""
431+
return super(CardanoHD, self).xprivate_key(version=version, encoded=encoded)
432+
401433
def path_key(self) -> Optional[str]:
402434
"""
403435
Derives a path key based on the current CardanoHD instance.

0 commit comments

Comments
 (0)