Skip to content

Commit

Permalink
ExtendedSigningKey from hd wallet: use key type from class
Browse files Browse the repository at this point in the history
  • Loading branch information
gszabo authored and cffls committed Dec 7, 2024
1 parent 23cccaa commit 6c2d183
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pycardano/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def from_hdwallet(cls, hdwallet: HDWallet) -> ExtendedSigningKey:

return cls(
payload=hdwallet.xprivate_key + hdwallet.public_key + hdwallet.chain_code,
key_type="PaymentExtendedSigningKeyShelley_ed25519_bip32",
description="Payment Signing Key",
key_type=cls.KEY_TYPE,
description=cls.DESCRIPTION,
)


Expand Down
17 changes: 17 additions & 0 deletions test/pycardano/test_key.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import pathlib
import tempfile

from mnemonic import Mnemonic

from pycardano import HDWallet
from pycardano.key import (
ExtendedSigningKey,
ExtendedVerificationKey,
PaymentExtendedSigningKey,
PaymentKeyPair,
PaymentSigningKey,
PaymentVerificationKey,
StakeExtendedSigningKey,
StakePoolKeyPair,
StakePoolSigningKey,
StakePoolVerificationKey,
Expand Down Expand Up @@ -191,3 +196,15 @@ def test_stake_pool_key_hash():

assert len(sk_set) == 1
assert len(vk_set) == 1


def test_extended_signing_key_from_hd_wallet_uses_type_and_description_from_class():
hd_wallet = HDWallet.from_mnemonic(Mnemonic().generate())

extended_payment_key = PaymentExtendedSigningKey.from_hdwallet(hd_wallet)
assert extended_payment_key.key_type == PaymentExtendedSigningKey.KEY_TYPE
assert extended_payment_key.description == PaymentExtendedSigningKey.DESCRIPTION

extended_stake_key = StakeExtendedSigningKey.from_hdwallet(hd_wallet)
assert extended_stake_key.key_type == StakeExtendedSigningKey.KEY_TYPE
assert extended_stake_key.description == StakeExtendedSigningKey.DESCRIPTION

0 comments on commit 6c2d183

Please sign in to comment.