Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtendedSigningKey from hd wallet: use key type from class #400

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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