def is_xprv(text): if text[0:4] != 'xprv': return False try: deserialize_xkey(text) return True except: return False
def is_xprv(text): if text[0:4] not in ('xprv', 'Ltpv'): return False try: deserialize_xkey(text) return True except: return False
def derive_pubkey(self, for_change, n): xpub = self.xpub_change if for_change else self.xpub_receive if xpub is None: xpub = bip32_public_derivation(self.xpub, "", "/%d" % for_change) if for_change: self.xpub_change = xpub else: self.xpub_receive = xpub _, _, _, c, cK = deserialize_xkey(xpub) cK, c = CKD_pub(cK, c, n) result = cK.encode('hex') return result
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 check_password(self, password): xprv = pw_decode(self.xprv, password) if deserialize_xkey(xprv)[3] != deserialize_xkey(self.xpub)[3]: raise InvalidPassword()
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')