Merge pull request #45 from jaicis/py3convert

Solved python2 to python3 message receiving issue and removed unrequi…
This commit is contained in:
jaicis 2020-02-20 13:40:19 +05:30 committed by GitHub
commit 0e8a230156
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -144,11 +144,11 @@ class objectProcessor(threading.Thread):
sqlExecute( sqlExecute(
'UPDATE sent SET status=?, lastactiontime=?' 'UPDATE sent SET status=?, lastactiontime=?'
' WHERE ackdata=?', ' WHERE ackdata=?',
'ackreceived', int(time.time()), data[readPosition:]) 'ackreceived', int(time.time()), bytes(data[readPosition:]))
queues.UISignalQueue.put(( queues.UISignalQueue.put((
'updateSentItemStatusByAckdata', 'updateSentItemStatusByAckdata',
( (
data[readPosition:], bytes(data[readPosition:]),
tr._translate( tr._translate(
"MainWindow", "MainWindow",
"Acknowledgement of the message received %1" "Acknowledgement of the message received %1"

View File

@ -687,9 +687,14 @@ def _unpack_binary(code, fp, options):
length = struct.unpack(">I", _read_except(fp, 4))[0] length = struct.unpack(">I", _read_except(fp, 4))[0]
else: else:
raise Exception("logic error, not binary: 0x%02x" % ord(code)) raise Exception("logic error, not binary: 0x%02x" % ord(code))
#Added Decode method for python3
return _read_except(fp, length) data = _read_except(fp, length)
try:
return bytes.decode(data, 'utf-8')
except UnicodeDecodeError:
if options.get("allow_invalid_utf8"):
return InvalidString(data)
raise InvalidStringException("unpacked string is invalid utf-8")
def _unpack_ext(code, fp, options): def _unpack_ext(code, fp, options):
if code == b'\xd4': if code == b'\xd4':

View File

@ -54,7 +54,6 @@ def encrypt(msg, hexPubkey):
def decrypt(msg, hexPrivkey): def decrypt(msg, hexPrivkey):
print("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS#################################################")
"""Decrypts message with hex private key""" """Decrypts message with hex private key"""
return makeCryptor(hexPrivkey).decrypt(msg) return makeCryptor(hexPrivkey).decrypt(msg)

View File

@ -444,7 +444,6 @@ def decryptAndCheckPubkeyPayload(data, address):
# That sort of address-malleability should have been caught # That sort of address-malleability should have been caught
# by the UI or API and an error given to the user. # by the UI or API and an error given to the user.
return 'failed' return 'failed'
print("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW#################################################")
try: try:
decryptedData = cryptorObject.decrypt(encryptedData) decryptedData = cryptorObject.decrypt(encryptedData)
except: except:
@ -455,7 +454,6 @@ def decryptAndCheckPubkeyPayload(data, address):
readPosition = 0 readPosition = 0
# bitfieldBehaviors = decryptedData[readPosition:readPosition + 4] # bitfieldBehaviors = decryptedData[readPosition:readPosition + 4]
readPosition += 4 readPosition += 4
print("working fine till here#################################################################")
publicSigningKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64] publicSigningKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64]
readPosition += 64 readPosition += 64
publicEncryptionKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64] publicEncryptionKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64]
@ -503,7 +501,6 @@ def decryptAndCheckPubkeyPayload(data, address):
) )
t = (address, addressVersion, storedData, int(time.time()), 'yes') t = (address, addressVersion, storedData, int(time.time()), 'yes')
sqlExecute('''INSERT INTO pubkeys VALUES (?,?,?,?,?)''', *t) sqlExecute('''INSERT INTO pubkeys VALUES (?,?,?,?,?)''', *t)
print("successful Insertion of pubkey hurray#################################################")
return 'successful' return 'successful'
except varintDecodeError: except varintDecodeError:
logger.info( logger.info(

View File

@ -91,7 +91,6 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
hashes += (payload for payload, in sqlQuery( hashes += (payload for payload, in sqlQuery(
'SELECT hash FROM inventory WHERE streamnumber=?' 'SELECT hash FROM inventory WHERE streamnumber=?'
' AND expirestime>?', stream, t)) ' AND expirestime>?', stream, t))
# print('sqlllllllllllllllllllllllllllllllllll',hashes)
return hashes return hashes
def flush(self): def flush(self):