Skip to content

Commit acb94d6

Browse files
committed
bip32: fixup from_xpriv()
1 parent 57cda59 commit acb94d6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

bip32/bip32.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,19 @@ def from_xpriv(cls, xpriv):
156156
extended_key = base58.b58decode_check(xpriv)
157157
(prefix, depth, fingerprint,
158158
index, chaincode, key) = _unserialize_extended_key(extended_key)
159-
return BIP32(chaincode, key, None)
159+
# We need to remove the trailing `0` before the actual private key !!
160+
return BIP32(chaincode, privkey=key[1:], pubkey=None)
160161

161162
@classmethod
162-
def from_xpub(cls, xpriv):
163+
def from_xpub(cls, xpub):
163164
"""Get a BIP32 "wallet" out of this xpub
164165
165166
:param xpub: (str) The encoded serialized extended public key.
166167
"""
167-
extended_key = base58.b58decode_check(xpriv)
168+
extended_key = base58.b58decode_check(xpub)
168169
(prefix, depth, fingerprint,
169170
index, chaincode, key) = _unserialize_extended_key(extended_key)
170-
return BIP32(chaincode, None, key)
171+
return BIP32(chaincode, privkey=None, pubkey=key)
171172

172173
@classmethod
173174
def from_seed(cls, seed):

0 commit comments

Comments
 (0)