Skip to content

Commit e1c2594

Browse files
committed
Add some x{pub,prv}key tests; correct typo in new from_xprvkey; v10.0.4
1 parent 721c09b commit e1c2594

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

slip39/api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def from_xpubkey( self, xpubkey: str, path: str = None ) -> "Account":
473473
return self
474474

475475
def from_xprvkey( self, xprvkey: str, path: str = None ) -> "Account":
476-
self.hdwallet.from_xpublic_key( xprvkey )
476+
self.hdwallet.from_xprivate_key( xprvkey )
477477
self.from_path( path )
478478
return self
479479

@@ -1081,7 +1081,7 @@ def accounts(
10811081

10821082

10831083
def accountgroups(
1084-
master_secret: bytes,
1084+
master_secret: Union[str,bytes],
10851085
cryptopaths: Optional[Sequence[Union[str,Tuple[str,str]]]] = None, # Default: ETH, BTC
10861086
allow_unbounded: bool = True,
10871087
) -> Sequence[Sequence[Account]]:
@@ -1118,7 +1118,7 @@ def accountgroups(
11181118

11191119

11201120
def address(
1121-
master_secret: bytes,
1121+
master_secret: Union[str,bytes],
11221122
crypto: str = None,
11231123
path: str = None,
11241124
format: str = None,
@@ -1133,7 +1133,7 @@ def address(
11331133

11341134

11351135
def addresses(
1136-
master_secret: bytes,
1136+
master_secret: Union[str,bytes],
11371137
crypto: str = None, # default 'ETH'
11381138
paths: str = None, # default: The crypto's path_default; supports ranges
11391139
format: str = None,
@@ -1149,7 +1149,7 @@ def addresses(
11491149

11501150

11511151
def addressgroups(
1152-
master_secret: bytes,
1152+
master_secret: Union[str,bytes],
11531153
cryptopaths: Optional[Sequence[Union[str,Tuple[str,str]]]] = None, # Default ETH, BTC
11541154
allow_unbounded: bool = True,
11551155
) -> Sequence[str]:

slip39/api_test.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .dependency_test import substitute, nonrandom_bytes, SEED_XMAS, SEED_ONES
2222

2323

24-
def test_account():
24+
def test_account_smoke():
2525
acct = account( SEED_XMAS )
2626
assert acct.address == '0x336cBeAB83aCCdb2541e43D514B62DC6C53675f4'
2727
assert acct.path == "m/44'/60'/0'/0/0"
@@ -30,6 +30,16 @@ def test_account():
3030
acct = account( SEED_XMAS, path="m/44'/60'/0'/0/1" )
3131
assert acct.address == '0x3b774e485fC818F0f377FBA657dfbF92B46f8504'
3232
assert acct.path == "m/44'/60'/0'/0/1"
33+
assert acct.pubkey == '03cbcf791b37011feab1c5d797cd76a3fa0f12ee5582adbe5aa4d8172a7bbaba5b'
34+
assert acct.key == acct.prvkey == 'bf299fe7a7d948fdb98474557bbee73395e01f3a6a73638d45d345f9adb451fb'
35+
assert acct.xpubkey == 'xpub6FVwqKQUrDre2ZPtAvcqR7GYW4662JTM7R1FGuwGAH3b1TjntLCbMa3HY7C1BR4ifXEtwfX63a69FEAcCSCgrgQZNd3WYgvKhAghRNucEc6'
36+
assert acct.xprvkey == 'xprvA2WbRosb1rJLp5KR4u5q3yKox2FbcqjVkC5eUXXebwWc8fQeLntLomiogp7vVMZcGfB4vaKeWRJ6eQmHSPRk6W7AJRNx2TT3Ai825JwH9kG'
37+
# And ensure we can round-trip the xprvkey (the x{pub/prv}keys encode other info, so won't be the same)
38+
acct = account( acct.xprvkey, path="m/" )
39+
assert acct.path is None
40+
assert acct.address == '0x3b774e485fC818F0f377FBA657dfbF92B46f8504'
41+
assert acct.pubkey == '03cbcf791b37011feab1c5d797cd76a3fa0f12ee5582adbe5aa4d8172a7bbaba5b'
42+
assert acct.key == acct.prvkey == 'bf299fe7a7d948fdb98474557bbee73395e01f3a6a73638d45d345f9adb451fb'
3343

3444
acct = account( SEED_XMAS, crypto='Bitcoin' )
3545
assert acct.address == 'bc1qz6kp20ukkyx8c5t4nwac6g8hsdc5tdkxhektrt'
@@ -50,6 +60,9 @@ def test_account():
5060
assert acct.address == 'bc1q9yscq3l2yfxlvnlk3cszpqefparrv7tk24u6pl'
5161
assert acct.path == "m/84'/0'/0'/0/0"
5262
assert acct.pubkey == '038f7fa5776f5359eb861994bee043f0b16a5ca24b66eb38696a7325d3e1717e72'
63+
assert acct.prvkey == acct.key == '80d5082773a4d2a07ee667a772ca13a120a5fc9d61bcf5a32f9e7ccf731bc0e6'
64+
assert acct.xpubkey == 'zpub6uMZYEpdewNa98z7Hge3R4GzeayoXCmtPUzFV7DVa4cc36k2Xh7oEDvs6baStXLxT8VtXkBZ56yfuk4D5JvM43nbB7EpdkmJC75ScEZm2QK'
65+
assert acct.xprvkey == 'zprvAgND8jHjpZpGveueBf733vLG6Z9K7k432G4egiot1j5dAJQsz9oYgRcPFJVUdpLe3tHnabyRmmuGY871GdTv8tkotCwyn6Ec5bZbb8RjtHF'
5366

5467
acct = account( SEED_XMAS, crypto='Litecoin' )
5568
assert acct.address == 'ltc1qfjepkelqd3jx4e73s7p79lls6kqvvmak5pxy97'
@@ -90,6 +103,7 @@ def test_account():
90103
assert acct.path == "m/44'/144'/0'/0/0" # Default
91104
assert acct.address == 'rUPzi4ZwoYxi7peKCqUkzqEuSrzSRyLguV'
92105
assert acct.pubkey == '039d65db4964cbf2049ad49467a6b73e7fec7d6e6f8a303cfbdb99fa21c7a1d2bc'
106+
assert acct.prvkey == '6501276b9d7f646742feb12fd066e107af8c1e26e4ad7c2694279d44c43bdfb2'
93107

94108

95109
@pytest.mark.skipif( not scrypt or not eth_account,

slip39/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = ( 10, 0, 3 )
1+
__version_info__ = ( 10, 0, 4 )
22
__version__ = '.'.join( map( str, __version_info__ ))

0 commit comments

Comments
 (0)