added additional input key check
This commit is contained in:
parent
70a35822f1
commit
cd99ecb261
@ -136,38 +136,40 @@ def create_parent_pubkey_hdwallet(master_key):
|
|||||||
|
|
||||||
# Создание дочернего приватного ключа
|
# Создание дочернего приватного ключа
|
||||||
def create_child_privkey(key, child_idx):
|
def create_child_privkey(key, child_idx):
|
||||||
expanded_privkey = create_expanded_key(key, child_idx)
|
if key['is_private']:
|
||||||
if expanded_pubkey:
|
expanded_privkey = create_expanded_key(key, child_idx)
|
||||||
child_chain_code = expanded_pubkey[32:]
|
if expanded_privkey:
|
||||||
child_privkey = add_private_keys(expanded_pubkey[:32], key['key'])
|
child_chain_code = expanded_privkey[32:]
|
||||||
if validate_private_key(child_privkey):
|
child_privkey = add_private_keys(expanded_privkey[:32], key['key'])
|
||||||
finger_print = hash160(priv2pub(key['key']))[:4]
|
if validate_private_key(child_privkey):
|
||||||
return dict(version=key['version'],
|
finger_print = hash160(priv2pub(key['key']))[:4]
|
||||||
key=child_pubkey,
|
return dict(version=key['version'],
|
||||||
depth=key['depth'] + 1,
|
key=child_privkey,
|
||||||
child=child_idx,
|
depth=key['depth'] + 1,
|
||||||
finger_print=finger_print,
|
child=child_idx,
|
||||||
chain_code=child_chain_code,
|
finger_print=finger_print,
|
||||||
is_private=False)
|
chain_code=child_chain_code,
|
||||||
|
is_private=True)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
# создание дочернего публичного ключа
|
# создание дочернего публичного ключа
|
||||||
def create_child_pubkey(key, child_idx):
|
def create_child_pubkey(key, child_idx):
|
||||||
expanded_pubkey = create_expanded_key(key, child_idx)
|
if not key['is_private']:
|
||||||
if expanded_pubkey:
|
expanded_pubkey = create_expanded_key(key, child_idx)
|
||||||
child_chain_code = expanded_pubkey[32:]
|
if expanded_pubkey:
|
||||||
ext_value = priv2pub(expanded_pubkey[:32])
|
child_chain_code = expanded_pubkey[32:]
|
||||||
child_pubkey = add_public_keys(ext_value, key['key'])
|
ext_value = priv2pub(expanded_pubkey[:32])
|
||||||
if is_valid_pub(child_pubkey):
|
child_pubkey = add_public_keys(ext_value, key['key'])
|
||||||
finger_print = hash160(key['key'])[:4]
|
if is_valid_pub(child_pubkey):
|
||||||
return dict(version=key['version'],
|
finger_print = hash160(key['key'])[:4]
|
||||||
key=child_pubkey,
|
return dict(version=key['version'],
|
||||||
depth=key['depth'] + 1,
|
key=child_pubkey,
|
||||||
child=child_idx,
|
depth=key['depth'] + 1,
|
||||||
finger_print=finger_print,
|
child=child_idx,
|
||||||
chain_code=child_chain_code,
|
finger_print=finger_print,
|
||||||
is_private=False)
|
chain_code=child_chain_code,
|
||||||
|
is_private=False)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user