fix some bugs related to the migration to Python3

Now getpubkey and one-to-one messaging works.
This commit is contained in:
Kashiko Koibumi 2024-05-16 02:56:36 +09:00
parent ba9734e979
commit 6a090e802e
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4
4 changed files with 13 additions and 14 deletions

View File

@ -153,8 +153,8 @@ class objectProcessor(threading.Thread):
data[readPosition:],
_translate(
"MainWindow",
"Acknowledgement of the message received %1"
).arg(l10n.formatTimestamp()))
"Acknowledgement of the message received {}"
).format(l10n.formatTimestamp()))
))
else:
logger.debug('This object is not an acknowledgement bound for me.')
@ -214,11 +214,11 @@ class objectProcessor(threading.Thread):
return logger.debug(
'The length of the requested hash is not 20 bytes.'
' Something is wrong. Ignoring.')
hex_hash = hexlify(requestedHash).decode('ascii')
logger.info(
'the hash requested in this getpubkey request is: %s',
hexlify(requestedHash))
hex_hash)
# if this address hash is one of mine
hex_hash = hexlify(requestedHash).decode('ascii')
if hex_hash in shared.myAddressesByHash:
myAddress = shared.myAddressesByHash[hex_hash]
elif requestedAddressVersionNumber >= 4:
@ -317,7 +317,7 @@ class objectProcessor(threading.Thread):
dataToStore = data[20:readPosition]
sha = hashlib.new('sha512')
sha.update(
'\x04' + publicSigningKey + '\x04' + publicEncryptionKey)
b'\x04' + publicSigningKey + b'\x04' + publicEncryptionKey)
ripe = RIPEMD160Hash(sha.digest()).digest()
if logger.isEnabledFor(logging.DEBUG):
@ -808,9 +808,9 @@ class objectProcessor(threading.Thread):
logger.info(
'EC decryption successful using key associated'
' with ripe hash: %s', key)
except Exception:
except Exception as ex:
logger.debug(
'cryptorObject.decrypt Exception:', exc_info=True)
'cryptorObject.decrypt Exception: {}'.format(ex))
if not initialDecryptionSuccessful:
# This is not a broadcast I am interested in.
return logger.debug(
@ -1062,8 +1062,8 @@ class objectProcessor(threading.Thread):
if checksum != hashlib.sha512(payload).digest()[0:4]:
logger.info('ackdata checksum wrong. Not sending ackdata.')
return False
command = command.rstrip('\x00')
if command != 'object':
command = command.rstrip(b'\x00')
if command != b'object':
return False
return True

View File

@ -74,13 +74,12 @@ class Dandelion: # pylint: disable=old-style-class
def removeHash(self, hashId, reason="no reason specified"):
"""Switch inventory vector from stem to fluff mode"""
hex_hash = hexlify(hashId).decode('ascii')
if logger.isEnabledFor(logging.DEBUG):
logger.debug(
'%s entering fluff mode due to %s.',
''.join('%02x' % ord(i) for i in hashId), reason)
'%s entering fluff mode due to %s.', hex_hash, reason)
with self.lock:
try:
hex_hash = hexlify(hashId).decode('ascii')
del self.hashMap[hex_hash]
except KeyError:
pass

View File

@ -483,7 +483,7 @@ def decryptAndCheckPubkeyPayload(data, address):
readPosition += 32
# the time through the tag. More data is appended onto
# signedData below after the decryption.
signedData = data[8:readPosition]
signedData = bytes(data[8:readPosition])
encryptedData = data[readPosition:]
# Let us try to decrypt the pubkey

View File

@ -65,7 +65,7 @@ class SqliteInventory(InventoryStorage):
def __iter__(self):
with self.lock:
hashes = map(unhexlify, self._inventory.keys()[:])
hashes += (unhexlify(x) for x, in sqlQuery('SELECT hash FROM inventory'))
hashes += (x for x, in sqlQuery('SELECT hash FROM inventory'))
return hashes.__iter__()
def __len__(self):