Browse Source

bugfix dumpprivkey HD path, logs dir

master
Adam Gibson 8 years ago
parent
commit
726545f1b7
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 2
      jmclient/jmclient/configure.py
  2. 12
      jmclient/jmclient/wallet_utils.py

2
jmclient/jmclient/configure.py

@ -29,6 +29,8 @@ class AttributeDict(object):
def __init__(self, **entries):
self.currentnick = None
self.add_entries(**entries)
if not os.path.exists('logs'):
os.makedirs('logs')
def add_entries(self, **entries):
for key, value in entries.items():

12
jmclient/jmclient/wallet_utils.py

@ -90,16 +90,18 @@ def bip32pathparse(path):
if not path.startswith('m'):
return False
elements = path.split(bip32sep)[1:]
ret_elements = []
for e in elements:
if e[-1] == "'": e = e[:-1]
try:
x = int(e)
except:
return False
if not e >= -1:
if not x >= -1:
#-1 is allowed for dummy branches for imported keys
return False
return True
ret_elements.append(x)
return ret_elements
def test_bip32_pathparse():
assert bip32pathparse("m/2/1/0017")
@ -479,8 +481,10 @@ def wallet_importprivkey(wallet, mixdepth):
print('Private key(s) successfully imported')
def wallet_dumpprivkey(wallet, hdpath):
if bip32pathparse(hdpath):
m, forchange, k = [int(y) for y in hdpath[4:].split('/')]
pathlist = bip32pathparse(hdpath)
print('got pathlist: ' + str(pathlist))
if pathlist and len(pathlist) == 5:
cointype, purpose, m, forchange, k = pathlist
key = wallet.get_key(m, forchange, k)
wifkey = btc.wif_compressed_privkey(key, vbyte=get_p2pk_vbyte())
return wifkey

Loading…
Cancel
Save