do not encode prev if its already bytes

This commit is contained in:
Kevin Froman 2018-04-26 15:39:02 -05:00
parent c9b7528db4
commit 9f4aef7465
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 10 additions and 5 deletions

View File

@ -23,15 +23,16 @@ def sendMessage():
global sendEntry global sendEntry
messageToAdd = '-txt-' + sendEntry.get() messageToAdd = '-txt-' + sendEntry.get()
addedHash = pluginapi.get_core().setData(messageToAdd) #addedHash = pluginapi.get_core().setData(messageToAdd)
pluginapi.get_core().addToBlockDB(addedHash, selfInsert=True) #pluginapi.get_core().addToBlockDB(addedHash, selfInsert=True)
pluginapi.get_core().setBlockType(addedHash, 'txt') #pluginapi.get_core().setBlockType(addedHash, 'txt')
pluginapi.get_core().insertBlock(messageToAdd, header='txt', sign=True)
sendEntry.delete(0, END) sendEntry.delete(0, END)
def update(): def update():
global listedBlocks, listbox, runningCheckDelayCount, runningCheckDelay, root, daemonStatus global listedBlocks, listbox, runningCheckDelayCount, runningCheckDelay, root, daemonStatus
# TO DO: migrate to new header format
for i in pluginapi.get_core().getBlocksByType('txt'): for i in pluginapi.get_core().getBlocksByType('txt'):
if i.strip() == '' or i in listedBlocks: if i.strip() == '' or i in listedBlocks:
continue continue

View File

@ -193,8 +193,12 @@ class OnionrCrypto:
prev = '' prev = ''
pubkey = pubkey.encode() pubkey = pubkey.encode()
for i in range(self.HASH_ID_ROUNDS): for i in range(self.HASH_ID_ROUNDS):
try:
prev = prev.encode()
except AttributeError:
pass
hasher = hashlib.sha3_256() hasher = hashlib.sha3_256()
hasher.update(pubkey + prev.encode()) hasher.update(pubkey + prev)
prev = hasher.hexdigest() prev = hasher.hexdigest()
result = prev result = prev
return result return result