Skip to content

Commit 178f915

Browse files
henryyuanheng-wangYuanheng WangYuanheng Wangdependabot[bot]
authored
Slight modification ExtendedSigningKey creation from HDWallet (#132)
* update plutus guide with vasil * fixing ExtendedSigning key from_hdwallet func Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Yuanheng Wang <[email protected]> Co-authored-by: Yuanheng Wang <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 29e95a7 commit 178f915

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

pycardano/key.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ def from_hdwallet(cls, hdwallet: HDWallet) -> ExtendedSigningKey:
194194
"The hdwallet doesn't contain extended private key or chain code info."
195195
)
196196

197-
return ExtendedSigningKey(
197+
return cls(
198198
payload=hdwallet.xprivate_key + hdwallet.public_key + hdwallet.chain_code,
199+
key_type="PaymentExtendedSigningKeyShelley_ed25519_bip32",
200+
description="Payment Signing Key",
199201
)
200202

201203

test/pycardano/crypto/test_bip32.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from pycardano.address import Address, PointerAddress
44
from pycardano.crypto.bip32 import HDWallet
5-
from pycardano.key import PaymentVerificationKey
5+
from pycardano.key import ExtendedSigningKey, PaymentVerificationKey
66
from pycardano.network import Network
77

88
# Tests copied from: https://github.com/Emurgo/cardano-serialization-lib/blob/master/rust/src/address.rs
@@ -284,6 +284,31 @@ def test_payment_address_24_base():
284284
)
285285

286286

287+
def test_payment_address_24_base_2():
288+
hdwallet = HDWallet.from_mnemonic(MNEMONIC_24)
289+
hdwallet_spend = hdwallet.derive_from_path("m/1852'/1815'/0'/0/0")
290+
spend_extended_sk = ExtendedSigningKey.from_hdwallet(hdwallet_spend)
291+
spend_extended_vk = spend_extended_sk.to_verification_key()
292+
293+
hdwallet_stake = hdwallet.derive_from_path("m/1852'/1815'/0'/2/0")
294+
stake_extended_sk = ExtendedSigningKey.from_hdwallet(hdwallet_stake)
295+
stake_extended_vk = stake_extended_sk.to_verification_key()
296+
297+
assert (
298+
Address(
299+
spend_extended_vk.hash(), stake_extended_vk.hash(), network=Network.TESTNET
300+
).encode()
301+
== "addr_test1qqy6nhfyks7wdu3dudslys37v252w2nwhv0fw2nfawemmn8k8ttq8f3gag0h89aepvx3xf69g0l9pf80tqv7cve0l33sw96paj"
302+
)
303+
304+
assert (
305+
Address(
306+
spend_extended_vk.hash(), stake_extended_vk.hash(), network=Network.MAINNET
307+
).encode()
308+
== "addr1qyy6nhfyks7wdu3dudslys37v252w2nwhv0fw2nfawemmn8k8ttq8f3gag0h89aepvx3xf69g0l9pf80tqv7cve0l33sdn8p3d"
309+
)
310+
311+
287312
def test_payment_address_24_enterprise():
288313
hdwallet = HDWallet.from_mnemonic(MNEMONIC_24)
289314
hdwallet_spend = hdwallet.derive_from_path("m/1852'/1815'/0'/0/0")

0 commit comments

Comments
 (0)