fix tests
This commit is contained in:
parent
fed76bfffc
commit
c73819a3d4
|
@ -522,15 +522,14 @@ def is_compressed(sec):
|
||||||
|
|
||||||
|
|
||||||
def public_key_from_private_key(pk, compressed):
|
def public_key_from_private_key(pk, compressed):
|
||||||
# rebuild public key from private key, compressed or uncompressed
|
|
||||||
pkey = regenerate_key(pk)
|
pkey = regenerate_key(pk)
|
||||||
public_key = GetPubKey(pkey.pubkey, compressed)
|
public_key = GetPubKey(pkey.pubkey, compressed)
|
||||||
return bh2u(public_key)
|
return bh2u(public_key)
|
||||||
|
|
||||||
|
|
||||||
def address_from_private_key(sec):
|
def address_from_private_key(sec):
|
||||||
public_key = public_key_from_private_key(sec)
|
txin_type, privkey, compressed = deserialize_privkey(sec)
|
||||||
address = public_key_to_p2pkh(bfh(public_key))
|
public_key = public_key_from_private_key(privkey, compressed)
|
||||||
|
address = pubkey_to_address(txin_type, public_key)
|
||||||
return address
|
return address
|
||||||
|
|
||||||
def is_segwit_address(addr):
|
def is_segwit_address(addr):
|
||||||
|
@ -612,8 +611,8 @@ def verify_message(address, sig, message):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def sign_message_with_wif_privkey(sec, message):
|
def sign_message_with_wif_privkey(sec, message):
|
||||||
key = regenerate_key(sec)
|
txin_type, privkey, compressed = deserialize_privkey(sec)
|
||||||
compressed = is_compressed(sec)
|
key = regenerate_key(privkey)
|
||||||
return key.sign_message(message, compressed)
|
return key.sign_message(message, compressed)
|
||||||
|
|
||||||
def encrypt_message(message, pubkey):
|
def encrypt_message(message, pubkey):
|
||||||
|
|
|
@ -15,7 +15,7 @@ from lib.bitcoin import (
|
||||||
pw_decode, Hash, public_key_from_private_key, address_from_private_key,
|
pw_decode, Hash, public_key_from_private_key, address_from_private_key,
|
||||||
is_address, is_private_key, xpub_from_xprv, is_new_seed, is_old_seed,
|
is_address, is_private_key, xpub_from_xprv, is_new_seed, is_old_seed,
|
||||||
var_int, op_push, address_to_script, sign_message_with_wif_privkey,
|
var_int, op_push, address_to_script, sign_message_with_wif_privkey,
|
||||||
verify_message)
|
verify_message, deserialize_privkey)
|
||||||
from lib.util import bfh
|
from lib.util import bfh
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -202,7 +202,8 @@ class Test_keyImport(unittest.TestCase):
|
||||||
main_address = "15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma"
|
main_address = "15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma"
|
||||||
|
|
||||||
def test_public_key_from_private_key(self):
|
def test_public_key_from_private_key(self):
|
||||||
result = public_key_from_private_key(self.private_key)
|
txin_type, privkey, compressed = deserialize_privkey(self.private_key)
|
||||||
|
result = public_key_from_private_key(privkey, compressed)
|
||||||
self.assertEqual(self.public_key_hex, result)
|
self.assertEqual(self.public_key_hex, result)
|
||||||
|
|
||||||
def test_address_from_private_key(self):
|
def test_address_from_private_key(self):
|
||||||
|
|
Loading…
Reference in New Issue