Skip to content

Commit

Permalink
accept xpriv objects in dump_bip32_privkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
jackjack-jj committed Oct 13, 2021
1 parent c88faf8 commit 8d00558
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pywallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3474,8 +3474,8 @@ def xpriv_version_bytes(cls):return 0x0488ADE4
@classmethod
def xpub_version_bytes(cls):return 0x0488B21E
@classmethod
def from_seed(cls, s):
I = hmac.new(b'Bitcoin seed', s, digestmod=hashlib.sha512).digest()
def from_seed(cls, s, seed = b'Bitcoin seed'):
I = hmac.new(seed, s, digestmod=hashlib.sha512).digest()
mk, cc = I[:32], I[32:]
return cls(cls.xpriv_version_bytes(), 0, '\x00'*4, 0, cc, 0, mk)
def clone(self):
Expand Down Expand Up @@ -3536,10 +3536,13 @@ def hprivcontent(self):
def hpubcontent(self):
return binascii.hexlify(DecodeBase58Check(self.xpub()))

def dump_bip32_privkeys(xpriv, paths, format):
def dump_bip32_privkeys(xpriv, paths, fmt):
dump_key = lambda x:x.wif
if format == 'addr':dump_key = lambda x:x.addr
for child in Xpriv.b58decode(xpriv).multi_ckd_xpriv(paths):
if fmt == 'addr':dump_key = lambda x:x.addr
try:
xpriv = Xpriv.b58decode(xpriv)
except:pass
for child in xpriv.multi_ckd_xpriv(paths):
print('%s: %s'%(child.fullpath, dump_key(keyinfo(child))))

class TestPywallet(unittest.TestCase):
Expand Down

0 comments on commit 8d00558

Please sign in to comment.