Solved message not receiving issue and solved address generation pubkey related issue
This commit is contained in:
parent
915fb4d371
commit
2da3ab9a3a
|
@ -153,10 +153,12 @@ class Inbox(Screen):
|
||||||
self.set_inboxCount(state.inbox_count)
|
self.set_inboxCount(state.inbox_count)
|
||||||
for mail in self.queryreturn:
|
for mail in self.queryreturn:
|
||||||
# third_text = mail[3].replace('\n', ' ')
|
# third_text = mail[3].replace('\n', ' ')
|
||||||
|
subject = mail[3].decode() if isinstance(mail[3],bytes) else mail[3]
|
||||||
|
body = mail[5].decode() if isinstance(mail[5],bytes) else mail[5]
|
||||||
data.append({
|
data.append({
|
||||||
'text': mail[4].strip(),
|
'text': mail[4].strip(),
|
||||||
'secondary_text': mail[5][:50] + '........' if len(
|
'secondary_text': body[:50] + '........' if len(
|
||||||
mail[5]) >= 50 else (mail[5] + ',' + mail[3].replace(
|
body) >= 50 else (body + ',' + subject.replace(
|
||||||
'\n', ''))[0:50] + '........',
|
'\n', ''))[0:50] + '........',
|
||||||
'msgid': mail[1], 'received': mail[6]})
|
'msgid': mail[1], 'received': mail[6]})
|
||||||
self.has_refreshed = True
|
self.has_refreshed = True
|
||||||
|
@ -239,10 +241,12 @@ class Inbox(Screen):
|
||||||
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
||||||
for mail in self.queryreturn:
|
for mail in self.queryreturn:
|
||||||
# third_text = mail[3].replace('\n', ' ')
|
# third_text = mail[3].replace('\n', ' ')
|
||||||
|
subject = mail[3].decode() if isinstance(mail[3],bytes) else mail[3]
|
||||||
|
body = mail[5].decode() if isinstance(mail[5],bytes) else mail[5]
|
||||||
data.append({
|
data.append({
|
||||||
'text': mail[4].strip(),
|
'text': mail[4].strip(),
|
||||||
'secondary_text': mail[5][:50] + '........' if len(
|
'secondary_text': body[:50] + '........' if len(
|
||||||
mail[5]) >= 50 else (mail[5] + ',' + mail[3].replace(
|
body) >= 50 else (body + ',' +subject.replace(
|
||||||
'\n', ''))[0:50] + '........',
|
'\n', ''))[0:50] + '........',
|
||||||
'msgid': mail[1]})
|
'msgid': mail[1]})
|
||||||
self.set_mdList(data)
|
self.set_mdList(data)
|
||||||
|
@ -1233,16 +1237,17 @@ class Trash(Screen):
|
||||||
"""This method is used to create the mdlist"""
|
"""This method is used to create the mdlist"""
|
||||||
total_trash_msg = len(self.ids.ml.children)
|
total_trash_msg = len(self.ids.ml.children)
|
||||||
for item in self.trash_messages:
|
for item in self.trash_messages:
|
||||||
|
subject = item[2].decode() if isinstance(item[2],bytes) else item[2]
|
||||||
|
body = item[3].decode() if isinstance(item[3],bytes) else item[3]
|
||||||
meny = TwoLineAvatarIconListItem(
|
meny = TwoLineAvatarIconListItem(
|
||||||
text=item[1],
|
text=item[1],
|
||||||
secondary_text=item[2][:50] + '........' if len(
|
secondary_text=item[2][:50] + '........' if len(
|
||||||
item[2]) >= 50 else (item[2] + ',' + item[3].replace(
|
subject) >= 50 else (subject + ',' + body.replace(
|
||||||
'\n', ''))[0:50] + '........',
|
'\n', ''))[0:50] + '........',
|
||||||
theme_text_color='Custom',
|
theme_text_color='Custom',
|
||||||
text_color=NavigateApp().theme_cls.primary_color)
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
img_latter = './images/text_images/{}.png'.format(
|
img_latter = './images/text_images/{}.png'.format(
|
||||||
item[2][0].upper() if (item[2][0].upper() >= 'A' and item[
|
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
|
||||||
2][0].upper() <= 'Z') else '!')
|
|
||||||
meny.add_widget(AvatarSampleWidget(source=img_latter))
|
meny.add_widget(AvatarSampleWidget(source=img_latter))
|
||||||
meny.add_widget(AddTimeWidget(item[7]))
|
meny.add_widget(AddTimeWidget(item[7]))
|
||||||
carousel = Carousel(direction='right')
|
carousel = Carousel(direction='right')
|
||||||
|
@ -2021,11 +2026,14 @@ class MailDetail(Screen):
|
||||||
|
|
||||||
def assign_mail_details(self, data):
|
def assign_mail_details(self, data):
|
||||||
"""Assigning mail details"""
|
"""Assigning mail details"""
|
||||||
|
subject = data[0][2].decode() if isinstance(data[0][2],bytes) else data[0][2]
|
||||||
|
body = data[0][3].decode() if isinstance(data[0][2],bytes) else data[0][3]
|
||||||
self.to_addr = data[0][0]
|
self.to_addr = data[0][0]
|
||||||
self.from_addr = data[0][1]
|
self.from_addr = data[0][1]
|
||||||
self.subject = data[0][2].upper(
|
|
||||||
) if data[0][2].upper() else '(no subject)'
|
self.subject = subject.upper(
|
||||||
self.message = data[0][3]
|
) if subject.upper() else '(no subject)'
|
||||||
|
self.message = body
|
||||||
if len(data[0]) == 7:
|
if len(data[0]) == 7:
|
||||||
self.status = data[0][4]
|
self.status = data[0][4]
|
||||||
self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6])
|
self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6])
|
||||||
|
@ -2519,17 +2527,19 @@ class Allmails(Screen):
|
||||||
"""This method is used to create mdList for allmaills"""
|
"""This method is used to create mdList for allmaills"""
|
||||||
data_exist = len(self.ids.ml.children)
|
data_exist = len(self.ids.ml.children)
|
||||||
for item in self.all_mails:
|
for item in self.all_mails:
|
||||||
|
body = item[3].decode() if isinstance(item[3],bytes) else item[3]
|
||||||
|
subject = item[2].decode() if isinstance(item[2],bytes) else item[2]
|
||||||
meny = TwoLineAvatarIconListItem(
|
meny = TwoLineAvatarIconListItem(
|
||||||
text=item[1],
|
text=item[1],
|
||||||
secondary_text=item[2][:50] + '........' if len(
|
secondary_text=body[:50] + '........' if len(
|
||||||
item[2]) >= 50 else (
|
body) >= 50 else (
|
||||||
item[2] + ',' + item[3].replace(
|
body + ',' + subject.replace(
|
||||||
'\n', ''))[0:50] + '........',
|
'\n', ''))[0:50] + '........',
|
||||||
theme_text_color='Custom',
|
theme_text_color='Custom',
|
||||||
text_color=NavigateApp().theme_cls.primary_color)
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
meny.add_widget(AvatarSampleWidget(
|
meny.add_widget(AvatarSampleWidget(
|
||||||
source='./images/text_images/{}.png'.format(
|
source='./images/text_images/{}.png'.format(
|
||||||
avatarImageFirstLetter(item[2].strip()))))
|
avatarImageFirstLetter(body.strip()))))
|
||||||
meny.bind(on_press=partial(
|
meny.bind(on_press=partial(
|
||||||
self.mail_detail, item[5], item[4]))
|
self.mail_detail, item[5], item[4]))
|
||||||
meny.add_widget(AddTimeWidget(item[7]))
|
meny.add_widget(AddTimeWidget(item[7]))
|
||||||
|
|
|
@ -479,16 +479,15 @@ class objectProcessor(threading.Thread):
|
||||||
|
|
||||||
# This is not an acknowledgement bound for me. See if it is a message
|
# This is not an acknowledgement bound for me. See if it is a message
|
||||||
# bound for me by trying to decrypt it with my private keys.
|
# bound for me by trying to decrypt it with my private keys.
|
||||||
|
|
||||||
for key, cryptorObject in sorted(
|
for key, cryptorObject in sorted(
|
||||||
shared.myECCryptorObjects.items(),
|
shared.myECCryptorObjects.items(),
|
||||||
key=lambda x: random.random()):
|
key=lambda x: random.random()):
|
||||||
try:
|
try:
|
||||||
# continue decryption attempts to avoid timing attacks
|
# continue decryption attempts to avoid timing attacks
|
||||||
if initialDecryptionSuccessful:
|
if initialDecryptionSuccessful:
|
||||||
cryptorObject.decrypt(data[readPosition:])
|
cryptorObject.decrypt(bytes(data[readPosition:]))
|
||||||
else:
|
else:
|
||||||
decryptedData = cryptorObject.decrypt(data[readPosition:])
|
decryptedData = cryptorObject.decrypt(bytes(data[readPosition:]))
|
||||||
# This is the RIPE hash of my pubkeys. We need this
|
# This is the RIPE hash of my pubkeys. We need this
|
||||||
# below to compare to the destination_ripe included
|
# below to compare to the destination_ripe included
|
||||||
# in the encrypted data.
|
# in the encrypted data.
|
||||||
|
@ -536,9 +535,9 @@ class objectProcessor(threading.Thread):
|
||||||
return
|
return
|
||||||
readPosition += sendersStreamNumberLength
|
readPosition += sendersStreamNumberLength
|
||||||
readPosition += 4
|
readPosition += 4
|
||||||
pubSigningKey = '\x04' + decryptedData[readPosition:readPosition + 64]
|
pubSigningKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64]
|
||||||
readPosition += 64
|
readPosition += 64
|
||||||
pubEncryptionKey = '\x04' + decryptedData[readPosition:readPosition + 64]
|
pubEncryptionKey = '\x04'.encode() + decryptedData[readPosition:readPosition + 64]
|
||||||
readPosition += 64
|
readPosition += 64
|
||||||
if sendersAddressVersionNumber >= 3:
|
if sendersAddressVersionNumber >= 3:
|
||||||
requiredAverageProofOfWorkNonceTrialsPerByte, varintLength = \
|
requiredAverageProofOfWorkNonceTrialsPerByte, varintLength = \
|
||||||
|
@ -589,7 +588,7 @@ class objectProcessor(threading.Thread):
|
||||||
readPosition += signatureLengthLength
|
readPosition += signatureLengthLength
|
||||||
signature = decryptedData[
|
signature = decryptedData[
|
||||||
readPosition:readPosition + signatureLength]
|
readPosition:readPosition + signatureLength]
|
||||||
signedData = data[8:20] + encodeVarint(1) + encodeVarint(
|
signedData = bytes(data[8:20]) + encodeVarint(1) + encodeVarint(
|
||||||
streamNumberAsClaimedByMsg
|
streamNumberAsClaimedByMsg
|
||||||
) + decryptedData[:positionOfBottomOfAckData]
|
) + decryptedData[:positionOfBottomOfAckData]
|
||||||
|
|
||||||
|
@ -635,7 +634,6 @@ class objectProcessor(threading.Thread):
|
||||||
# pubkey in order to send a message. If we are, it will do the POW
|
# pubkey in order to send a message. If we are, it will do the POW
|
||||||
# and send it.
|
# and send it.
|
||||||
self.possibleNewPubkey(fromAddress)
|
self.possibleNewPubkey(fromAddress)
|
||||||
|
|
||||||
# If this message is bound for one of my version 3 addresses (or
|
# If this message is bound for one of my version 3 addresses (or
|
||||||
# higher), then we must check to make sure it meets our demanded
|
# higher), then we must check to make sure it meets our demanded
|
||||||
# proof of work requirement. If this is bound for one of my chan
|
# proof of work requirement. If this is bound for one of my chan
|
||||||
|
@ -648,10 +646,10 @@ class objectProcessor(threading.Thread):
|
||||||
# If I'm not friendly with this person:
|
# If I'm not friendly with this person:
|
||||||
if not shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(
|
if not shared.isAddressInMyAddressBookSubscriptionsListOrWhitelist(
|
||||||
fromAddress):
|
fromAddress):
|
||||||
requiredNonceTrialsPerByte = BMConfigParser().getint(
|
requiredNonceTrialsPerByte = int(BMConfigParser().get(
|
||||||
toAddress, 'noncetrialsperbyte')
|
toAddress, 'noncetrialsperbyte'))
|
||||||
requiredPayloadLengthExtraBytes = BMConfigParser().getint(
|
requiredPayloadLengthExtraBytes = int(BMConfigParser().get(
|
||||||
toAddress, 'payloadlengthextrabytes')
|
toAddress, 'payloadlengthextrabytes'))
|
||||||
if not protocol.isProofOfWorkSufficient(
|
if not protocol.isProofOfWorkSufficient(
|
||||||
data, requiredNonceTrialsPerByte,
|
data, requiredNonceTrialsPerByte,
|
||||||
requiredPayloadLengthExtraBytes):
|
requiredPayloadLengthExtraBytes):
|
||||||
|
@ -684,7 +682,6 @@ class objectProcessor(threading.Thread):
|
||||||
toLabel = BMConfigParser().get(toAddress, 'label')
|
toLabel = BMConfigParser().get(toAddress, 'label')
|
||||||
if toLabel == '':
|
if toLabel == '':
|
||||||
toLabel = toAddress
|
toLabel = toAddress
|
||||||
|
|
||||||
try:
|
try:
|
||||||
decodedMessage = helper_msgcoding.MsgDecode(
|
decodedMessage = helper_msgcoding.MsgDecode(
|
||||||
messageEncodingType, message)
|
messageEncodingType, message)
|
||||||
|
@ -1121,8 +1118,8 @@ class objectProcessor(threading.Thread):
|
||||||
if checksum != hashlib.sha512(payload).digest()[0:4]:
|
if checksum != hashlib.sha512(payload).digest()[0:4]:
|
||||||
logger.info('ackdata checksum wrong. Not sending ackdata.')
|
logger.info('ackdata checksum wrong. Not sending ackdata.')
|
||||||
return False
|
return False
|
||||||
command = command.rstrip('\x00')
|
command = command.rstrip('\x00'.encode())
|
||||||
if command != 'object':
|
if command != 'object'.encode():
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ class singleWorker(StoppableThread):
|
||||||
TTL = int(28 * 24 * 60 * 60 + helper_random.randomrandrange(-300, 300))
|
TTL = int(28 * 24 * 60 * 60 + helper_random.randomrandrange(-300, 300))
|
||||||
embeddedTime = int(time.time() + TTL)
|
embeddedTime = int(time.time() + TTL)
|
||||||
payload = pack('>Q', (embeddedTime))
|
payload = pack('>Q', (embeddedTime))
|
||||||
payload += '\x00\x00\x00\x01' # object type: pubkey
|
payload += '\x00\x00\x00\x01'.encode() # object type: pubkey
|
||||||
payload += encodeVarint(addressVersionNumber) # Address version number
|
payload += encodeVarint(addressVersionNumber) # Address version number
|
||||||
payload += encodeVarint(streamNumber)
|
payload += encodeVarint(streamNumber)
|
||||||
dataToEncrypt = protocol.getBitfield(myAddress)
|
dataToEncrypt = protocol.getBitfield(myAddress)
|
||||||
|
@ -415,10 +415,10 @@ class singleWorker(StoppableThread):
|
||||||
|
|
||||||
dataToEncrypt += pubSigningKey + pubEncryptionKey
|
dataToEncrypt += pubSigningKey + pubEncryptionKey
|
||||||
|
|
||||||
dataToEncrypt += encodeVarint(BMConfigParser().getint(
|
dataToEncrypt += encodeVarint(int(BMConfigParser().get(
|
||||||
myAddress, 'noncetrialsperbyte'))
|
myAddress, 'noncetrialsperbyte')))
|
||||||
dataToEncrypt += encodeVarint(BMConfigParser().getint(
|
dataToEncrypt += encodeVarint(int(BMConfigParser().get(
|
||||||
myAddress, 'payloadlengthextrabytes'))
|
myAddress, 'payloadlengthextrabytes')))
|
||||||
|
|
||||||
# When we encrypt, we'll use a hash of the data
|
# When we encrypt, we'll use a hash of the data
|
||||||
# contained in an address as a decryption key. This way
|
# contained in an address as a decryption key. This way
|
||||||
|
@ -449,7 +449,7 @@ class singleWorker(StoppableThread):
|
||||||
|
|
||||||
inventoryHash = calculateInventoryHash(payload)
|
inventoryHash = calculateInventoryHash(payload)
|
||||||
objectType = 1
|
objectType = 1
|
||||||
Inventory()[inventoryHash] = (
|
Inventory()._realInventory[inventoryHash] = (
|
||||||
objectType, streamNumber, payload, embeddedTime,
|
objectType, streamNumber, payload, embeddedTime,
|
||||||
doubleHashOfAddressData[32:]
|
doubleHashOfAddressData[32:]
|
||||||
)
|
)
|
||||||
|
|
|
@ -99,14 +99,14 @@ class MsgDecode(object):
|
||||||
def decodeExtended(self, data):
|
def decodeExtended(self, data):
|
||||||
"""Handle extended encoding"""
|
"""Handle extended encoding"""
|
||||||
dc = zlib.decompressobj()
|
dc = zlib.decompressobj()
|
||||||
tmp = ""
|
tmp = bytes()
|
||||||
while len(tmp) <= BMConfigParser().safeGetInt("zlib", "maxsize"):
|
while len(tmp) <= BMConfigParser().safeGetInt("zlib", "maxsize"):
|
||||||
try:
|
try:
|
||||||
got = dc.decompress(
|
got = dc.decompress(
|
||||||
data, BMConfigParser().safeGetInt("zlib", "maxsize") +
|
data, BMConfigParser().safeGetInt("zlib", "maxsize") +
|
||||||
1 - len(tmp))
|
1 - len(tmp))
|
||||||
# EOF
|
# EOF
|
||||||
if got == "":
|
if got == bytes():
|
||||||
break
|
break
|
||||||
tmp += got
|
tmp += got
|
||||||
data = dc.unconsumed_tail
|
data = dc.unconsumed_tail
|
||||||
|
@ -128,7 +128,6 @@ class MsgDecode(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.error("Message type missing")
|
logger.error("Message type missing")
|
||||||
raise MsgDecodeException("Message type missing")
|
raise MsgDecodeException("Message type missing")
|
||||||
|
|
||||||
msgObj = messagetypes.constructObject(tmp)
|
msgObj = messagetypes.constructObject(tmp)
|
||||||
if msgObj is None:
|
if msgObj is None:
|
||||||
raise MsgDecodeException("Malformed message")
|
raise MsgDecodeException("Malformed message")
|
||||||
|
@ -142,7 +141,7 @@ class MsgDecode(object):
|
||||||
|
|
||||||
def decodeSimple(self, data):
|
def decodeSimple(self, data):
|
||||||
"""Handle simple encoding"""
|
"""Handle simple encoding"""
|
||||||
bodyPositionIndex = string.find(data, '\nBody:')
|
bodyPositionIndex = bytes.find(data, '\nBody:'.encode())
|
||||||
if bodyPositionIndex > 1:
|
if bodyPositionIndex > 1:
|
||||||
subject = data[8:bodyPositionIndex]
|
subject = data[8:bodyPositionIndex]
|
||||||
# Only save and show the first 500 characters of the subject.
|
# Only save and show the first 500 characters of the subject.
|
||||||
|
|
|
@ -14,13 +14,17 @@ class Message(MsgBase):
|
||||||
"""Decode a message"""
|
"""Decode a message"""
|
||||||
# UTF-8 and variable type validator
|
# UTF-8 and variable type validator
|
||||||
if isinstance(data["subject"], str):
|
if isinstance(data["subject"], str):
|
||||||
self.subject = unicode(data["subject"], 'utf-8', 'replace')
|
# Unicode is depreciated
|
||||||
|
self.subject =data["subject"]
|
||||||
else:
|
else:
|
||||||
self.subject = unicode(str(data["subject"]), 'utf-8', 'replace')
|
# Unicode is depreciated
|
||||||
|
self.subject = str(data["subject"])
|
||||||
if isinstance(data["body"], str):
|
if isinstance(data["body"], str):
|
||||||
self.body = unicode(data["body"], 'utf-8', 'replace')
|
# Unicode is depreciated
|
||||||
|
self.body = data["body"]
|
||||||
else:
|
else:
|
||||||
self.body = unicode(str(data["body"]), 'utf-8', 'replace')
|
# Unicode is depreciated
|
||||||
|
self.body = str(data["body"])
|
||||||
|
|
||||||
def encode(self, data):
|
def encode(self, data):
|
||||||
"""Encode a message"""
|
"""Encode a message"""
|
||||||
|
|
|
@ -276,7 +276,7 @@ def isProofOfWorkSufficient(
|
||||||
if TTL < 300:
|
if TTL < 300:
|
||||||
TTL = 300
|
TTL = 300
|
||||||
POW, = unpack('>Q', hashlib.sha512(hashlib.sha512(
|
POW, = unpack('>Q', hashlib.sha512(hashlib.sha512(
|
||||||
data[:8] + hashlib.sha512(data[8:]).digest()
|
bytes(data[:8]) + hashlib.sha512(data[8:]).digest()
|
||||||
).digest()).digest()[0:8])
|
).digest()).digest()[0:8])
|
||||||
return POW <= 2 ** 64 / (
|
return POW <= 2 ** 64 / (
|
||||||
nonceTrialsPerByte * (
|
nonceTrialsPerByte * (
|
||||||
|
|
Reference in New Issue
Block a user