Solved python2 to python3 message receiving issue and removed unrequired prints

This commit is contained in:
jai.s 2020-02-20 13:36:47 +05:30
parent 1278342d8e
commit eb4af1cc2a
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
5 changed files with 10 additions and 10 deletions

View File

@ -144,11 +144,11 @@ class objectProcessor(threading.Thread):
sqlExecute(
'UPDATE sent SET status=?, lastactiontime=?'
' WHERE ackdata=?',
'ackreceived', int(time.time()), data[readPosition:])
'ackreceived', int(time.time()), bytes(data[readPosition:]))
queues.UISignalQueue.put((
'updateSentItemStatusByAckdata',
(
data[readPosition:],
bytes(data[readPosition:]),
tr._translate(
"MainWindow",
"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]
else:
raise Exception("logic error, not binary: 0x%02x" % ord(code))
return _read_except(fp, length)
#Added Decode method for python3
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):
if code == b'\xd4':

View File

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

View File

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

View File

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