Skip to content

Commit 8d00558

Browse files
committed
accept xpriv objects in dump_bip32_privkeys
1 parent c88faf8 commit 8d00558

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pywallet.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3474,8 +3474,8 @@ def xpriv_version_bytes(cls):return 0x0488ADE4
34743474
@classmethod
34753475
def xpub_version_bytes(cls):return 0x0488B21E
34763476
@classmethod
3477-
def from_seed(cls, s):
3478-
I = hmac.new(b'Bitcoin seed', s, digestmod=hashlib.sha512).digest()
3477+
def from_seed(cls, s, seed = b'Bitcoin seed'):
3478+
I = hmac.new(seed, s, digestmod=hashlib.sha512).digest()
34793479
mk, cc = I[:32], I[32:]
34803480
return cls(cls.xpriv_version_bytes(), 0, '\x00'*4, 0, cc, 0, mk)
34813481
def clone(self):
@@ -3536,10 +3536,13 @@ def hprivcontent(self):
35363536
def hpubcontent(self):
35373537
return binascii.hexlify(DecodeBase58Check(self.xpub()))
35383538

3539-
def dump_bip32_privkeys(xpriv, paths, format):
3539+
def dump_bip32_privkeys(xpriv, paths, fmt):
35403540
dump_key = lambda x:x.wif
3541-
if format == 'addr':dump_key = lambda x:x.addr
3542-
for child in Xpriv.b58decode(xpriv).multi_ckd_xpriv(paths):
3541+
if fmt == 'addr':dump_key = lambda x:x.addr
3542+
try:
3543+
xpriv = Xpriv.b58decode(xpriv)
3544+
except:pass
3545+
for child in xpriv.multi_ckd_xpriv(paths):
35433546
print('%s: %s'%(child.fullpath, dump_key(keyinfo(child))))
35443547

35453548
class TestPywallet(unittest.TestCase):

0 commit comments

Comments
 (0)