def login(self, retries=0): credentials = self.showLoginDlg() if not credentials: return self.username, self.passphrase = credentials hash = hashlib.sha256(self.passphrase).hexdigest() pkbytes = scrypt.hash(hash, self.username, N=2**18, buflen=32) self.pkstr = pycoin.serialize.b2h(pkbytes) se = long(self.pkstr, 16) pk = pycoin.key.Key(secret_exponent=se, netcode=self.netcode) self.wif = pk.wif() self.btcaddr = pk.address() try: self.bmaddr = MM_util.bm.getDeterministicAddress( base64.b64encode(self.pkstr), 4, 1) wp = self.input( "Please enter your Bitcoin Core wallet encryption passphrase:", password=True) if not wp: return MM_util.unlockwallet(wp) addrismine = MM_util.btcd.validateaddress(self.btcaddr)['ismine'] except bitcoinrpc.authproxy.JSONRPCException as jre: if jre.error['code'] == -14: self.info( "The passphrase was not correct. Please try logging in again." ) return except socket.error: self.sockErr() except httplib.BadStatusLine: MM_util.reconnect_btcd(retries) return self.login(retries + 1) if MM_util.bm.createDeterministicAddresses(base64.b64encode(self.pkstr)) == [] \ or not addrismine: if not self.importkeys(): return myidstr = MM_util.createidentmsgstr(self.btcaddr, self.bmaddr, self.username) self.myid = MM_util.MM_loads(self.btcaddr, myidstr) identlist = self.listDict['ident'] = MM_util.loadlist('ident') if not MM_util.searchlistbyhash(identlist, self.myid.hash): if not self.register(myidstr): return self.info("You are now logged in as: %s" % self.username) self.loggedIn = True self.updateUi()
def loadListIfModified(self, index): MM_util.loadindex(index) mtime = os.path.getmtime("%s.dat" % index) lastTime = self.listLastLoaded[index] if mtime > lastTime: self.listLastLoaded[index] = time.time() list = MM_util.loadlist(index) if index == "ident": MM_util.idList = list return list