From 083fac3e51a174ad398549c5e47de3f170a2d9e4 Mon Sep 17 00:00:00 2001 From: Alexey Karyabkin Date: Tue, 19 Jun 2018 18:53:36 +0400 Subject: [PATCH] added check for extended public key (HDWallet) --- pybtc/tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pybtc/tools.py b/pybtc/tools.py index 459b890..0609ab7 100644 --- a/pybtc/tools.py +++ b/pybtc/tools.py @@ -104,11 +104,14 @@ def private_to_public_key(private_key, compressed=True, hex=False): def is_valid_public_key(key): if len(key) < 33: return False - if key[0] == 0x04 and len(key) != 65: + elif key[0] == 0x04 and len(key) != 65: return False elif key[0] == 0x02 or key[0] == 0x03: if len(key) != 33: return False + elif isinstance(key, str): + if not key[:4] in ['xpub', 'tpub']: + return False return True