From 9f4aef7465fddcadc4d58d55793a0e2000674188 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 26 Apr 2018 15:39:02 -0500 Subject: [PATCH] do not encode prev if its already bytes --- onionr/default-plugins/gui/main.py | 9 +++++---- onionr/onionrcrypto.py | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/onionr/default-plugins/gui/main.py b/onionr/default-plugins/gui/main.py index 589a10ca..cc865dbe 100644 --- a/onionr/default-plugins/gui/main.py +++ b/onionr/default-plugins/gui/main.py @@ -23,15 +23,16 @@ def sendMessage(): global sendEntry messageToAdd = '-txt-' + sendEntry.get() - addedHash = pluginapi.get_core().setData(messageToAdd) - pluginapi.get_core().addToBlockDB(addedHash, selfInsert=True) - pluginapi.get_core().setBlockType(addedHash, 'txt') + #addedHash = pluginapi.get_core().setData(messageToAdd) + #pluginapi.get_core().addToBlockDB(addedHash, selfInsert=True) + #pluginapi.get_core().setBlockType(addedHash, 'txt') + pluginapi.get_core().insertBlock(messageToAdd, header='txt', sign=True) sendEntry.delete(0, END) def update(): global listedBlocks, listbox, runningCheckDelayCount, runningCheckDelay, root, daemonStatus - + # TO DO: migrate to new header format for i in pluginapi.get_core().getBlocksByType('txt'): if i.strip() == '' or i in listedBlocks: continue diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index c6fc0089..8d0aed8a 100644 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -193,8 +193,12 @@ class OnionrCrypto: prev = '' pubkey = pubkey.encode() for i in range(self.HASH_ID_ROUNDS): + try: + prev = prev.encode() + except AttributeError: + pass hasher = hashlib.sha3_256() - hasher.update(pubkey + prev.encode()) + hasher.update(pubkey + prev) prev = hasher.hexdigest() result = prev return result \ No newline at end of file