def check_password(self): self.xpub = self.master_public_keys[self.root_name] self.decoded_xprv = pw_decode(self.master_private_keys[self.root_name], self._password) if deserialize_xkey(self.decoded_xprv)[3] == deserialize_xkey( self.xpub)[3]: return True raise ParamsError('51001')
def get_private_key(self, sequence, wallet, password): for_change, i = sequence assert for_change == 0 address = self.get_addresses(0)[i] pk = pw_decode(self.keypairs[address][1], password) # this checks the password if address != address_from_private_key(pk): raise ParamsError('51001') return [pk]
def update_password(self, new_password): if not new_password: raise ParamsError('51002') try: str(new_password) except: raise ParamsError('51001', "the password can't conversion into str") self.get_decode_seed() seed = pw_encode(self.decoded_seed, new_password) master_private_keys = {} for k, v in self.master_private_keys.items(): b = pw_decode(v, self._password) c = pw_encode(b, new_password) master_private_keys[k] = c # save to mongodb self.seed = seed self.master_private_keys = master_private_keys self._password = new_password
def get_decode_seed(self): self.decoded_seed = pw_decode(self.seed, self._password)
def update_password(self, old_password, new_password): for k, v in self.keypairs.items(): pubkey, a = v b = pw_decode(a, old_password) c = pw_encode(b, new_password) self.keypairs[k] = (pubkey, c)