1
0

version notifications: sig check would always fail on testnet

This commit is contained in:
SomberNight
2019-01-26 15:30:30 +01:00
parent b085d7cc59
commit 53310690a5
3 changed files with 30 additions and 25 deletions

View File

@@ -37,6 +37,7 @@ from .util import bfh, bh2u, assert_bytes, print_error, to_bytes, InvalidPasswor
from .crypto import (sha256d, aes_encrypt_with_iv, aes_decrypt_with_iv, hmac_oneshot)
from .ecc_fast import do_monkey_patching_of_python_ecdsa_internals_with_libsecp256k1
from . import msqr
from . import constants
do_monkey_patching_of_python_ecdsa_internals_with_libsecp256k1()
@@ -309,16 +310,17 @@ def msg_magic(message: bytes) -> bytes:
return b"\x18Bitcoin Signed Message:\n" + length + message
def verify_message_with_address(address: str, sig65: bytes, message: bytes):
def verify_message_with_address(address: str, sig65: bytes, message: bytes, *, net=None):
from .bitcoin import pubkey_to_address
assert_bytes(sig65, message)
if net is None: net = constants.net
try:
h = sha256d(msg_magic(message))
public_key, compressed = ECPubkey.from_signature65(sig65, h)
# check public key using the address
pubkey_hex = public_key.get_public_key_hex(compressed)
for txin_type in ['p2pkh','p2wpkh','p2wpkh-p2sh']:
addr = pubkey_to_address(txin_type, pubkey_hex)
addr = pubkey_to_address(txin_type, pubkey_hex, net=net)
if address == addr:
break
else: