def is_xprv(text): if text[0:4] not in ('xpriv'): return False try: deserialize_xkey(text) return True except: return False
def is_xpub(text): if text[0:4] not in ('xpub', 'xq5h'): return False try: deserialize_xkey(text) return True except: return False
def check_password(self, password): xprv = pw_decode(self.xprv, password) if deserialize_xkey(xprv)[3] != deserialize_xkey(self.xpub)[3]: raise InvalidPassword()
def get_private_key(self, sequence, password): xprv = self.get_master_private_key(password) _, _, _, c, k = deserialize_xkey(xprv) pk = bip32_private_key(sequence, k, c) return pk
def get_pubkey_from_xpub(self, xpub, sequence): _, _, _, c, cK = deserialize_xkey(xpub) for i in sequence: cK, c = CKD_pub(cK, c, i) return cK.encode('hex')