commit c73819a3d4f4990f4e91bafbd875c48a46a69fa8
parent fed76bfffcf1b0130f13393c565b27d946872dad
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 29 Sep 2017 17:49:29 +0200
fix tests
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
@@ -522,15 +522,14 @@ def is_compressed(sec):
def public_key_from_private_key(pk, compressed):
- # rebuild public key from private key, compressed or uncompressed
pkey = regenerate_key(pk)
public_key = GetPubKey(pkey.pubkey, compressed)
return bh2u(public_key)
-
def address_from_private_key(sec):
- public_key = public_key_from_private_key(sec)
- address = public_key_to_p2pkh(bfh(public_key))
+ txin_type, privkey, compressed = deserialize_privkey(sec)
+ public_key = public_key_from_private_key(privkey, compressed)
+ address = pubkey_to_address(txin_type, public_key)
return address
def is_segwit_address(addr):
@@ -612,8 +611,8 @@ def verify_message(address, sig, message):
return False
def sign_message_with_wif_privkey(sec, message):
- key = regenerate_key(sec)
- compressed = is_compressed(sec)
+ txin_type, privkey, compressed = deserialize_privkey(sec)
+ key = regenerate_key(privkey)
return key.sign_message(message, compressed)
def encrypt_message(message, pubkey):
diff --git a/lib/tests/test_bitcoin.py b/lib/tests/test_bitcoin.py
@@ -15,7 +15,7 @@ from lib.bitcoin import (
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,
var_int, op_push, address_to_script, sign_message_with_wif_privkey,
- verify_message)
+ verify_message, deserialize_privkey)
from lib.util import bfh
try:
@@ -202,7 +202,8 @@ class Test_keyImport(unittest.TestCase):
main_address = "15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma"
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)
def test_address_from_private_key(self):