QMessageBox.about(self,_translate("MainWindow","Sending to your address"),_translate(
"MainWindow","Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress))
QMessageBox.about(self,_translate("MainWindow","Address version number"),_translate(
"MainWindow","Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber)))
# If we are sending a message to ourselves or a chan then we won't need an entry in the pubkeys table; we can calculate the needed pubkey using the private keys in our keys.dat file.
ifshared.config.has_section(toaddress):
continue
queryreturn=sqlQuery(
'''SELECT hash FROM pubkeys WHERE hash=? ''',toRipe)
'''SELECT hash FROM pubkeys WHERE hash=? AND addressversion=?''',toRipe,toAddressVersion)
ifqueryreturn!=[]:# If we have the needed pubkey in the pubkey table already, set the status to doingmsgpow (we'll do it further down)
sqlExecute(
'''UPDATE sent SET status='doingmsgpow' WHERE toaddress=? AND status='msgqueued'''',
@ -523,130 +505,154 @@ class singleWorker(threading.Thread):
int(time.time())-2419200)
forrowinqueryreturn:# For each message we need to send..
# We no longer have the needed pubkey and we haven't requested
# it.
withshared.printLock:
sys.stderr.write(
'For some reason, the status of a message in our outbox is \'doingmsgpow\' even though we lack the pubkey. Here is the RIPE hash of the needed pubkey: %s\n'%toripe.encode('hex'))
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE toaddress=? AND status='doingmsgpow'''',toaddress)
# We no longer have the needed pubkey and we haven't requested
# it.
withshared.printLock:
sys.stderr.write(
'For some reason, the status of a message in our outbox is \'doingmsgpow\' even though we lack the pubkey. Here is the RIPE hash of the needed pubkey: %s\n'%toripe.encode('hex'))
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE toaddress=? AND status='doingmsgpow'''',toaddress)
# Mobile users may ask us to include their address's RIPE hash on a message
# unencrypted. Before we actually do it the sending human must check a box
# in the settings menu to allow it.
ifshared.isBitSetWithinBitfield(behaviorBitfield,30):# if receiver is a mobile device who expects that their address RIPE is included unencrypted on the front of the message..
ifnotshared.safeConfigGetBoolean('bitmessagesettings','willinglysendtomobile'):# if we are Not willing to include the receiver's RIPE hash on the message..
logger.info('The receiver is a mobile user but the sender (you) has not selected that you are willing to send to mobiles. Aborting send.')
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow",'Problem: Destination is a mobile device who requests that the destination be included in the message but this is disallowed in your settings. %1').arg(unicode(strftime(shared.config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))),'utf-8')))))
# if the human changes their setting and then sends another message or restarts their client, this one will send at that time.
continue
readPosition+=4# to bypass the bitfield of behaviors
# pubSigningKeyBase256 =
# pubkeyPayload[readPosition:readPosition+64] #We don't use this
# key for anything here.
readPosition+=64
pubEncryptionKeyBase256=pubkeyPayload[
readPosition:readPosition+64]
readPosition+=64
# Let us fetch the amount of work required by the recipient.
# This section is used for the transition from 32 bit time to 64
# bit time in the protocol.
ifpubkeyEmbeddedTime==0:
pubkeyEmbeddedTime,=unpack(
'>Q',pubkeyPayload[readPosition:readPosition+8])
readPosition+=8
else:
readPosition+=4
readPosition+=1# to bypass the address version whose length is definitely 1
streamNumber,streamNumberLength=decodeVarint(
pubkeyPayload[readPosition:readPosition+10])
readPosition+=varintLength
ifrequiredAverageProofOfWorkNonceTrialsPerByte<shared.networkDefaultProofOfWorkNonceTrialsPerByte:# We still have to meet a minimum POW difficulty regardless of what they say is allowed in order to get our message to propagate through the network.
# Mobile users may ask us to include their address's RIPE hash on a message
# unencrypted. Before we actually do it the sending human must check a box
# in the settings menu to allow it.
ifshared.isBitSetWithinBitfield(behaviorBitfield,30):# if receiver is a mobile device who expects that their address RIPE is included unencrypted on the front of the message..
ifnotshared.safeConfigGetBoolean('bitmessagesettings','willinglysendtomobile'):# if we are Not willing to include the receiver's RIPE hash on the message..
logger.info('The receiver is a mobile user but the sender (you) has not selected that you are willing to send to mobiles. Aborting send.')
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow",'Problem: Destination is a mobile device who requests that the destination be included in the message but this is disallowed in your settings. %1').arg(unicode(strftime(shared.config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))),'utf-8')))))
# if the human changes their setting and then sends another message or restarts their client, this one will send at that time.
continue
readPosition+=4# to bypass the bitfield of behaviors
# pubSigningKeyBase256 =
# pubkeyPayload[readPosition:readPosition+64] #We don't use this
# key for anything here.
readPosition+=64
pubEncryptionKeyBase256=pubkeyPayload[
readPosition:readPosition+64]
readPosition+=64
# Let us fetch the amount of work required by the recipient.
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow","Doing work necessary to send message.\nReceiver\'s required difficulty: %1 and %2").arg(str(float(
# The demanded difficulty is more than we are willing
# to do.
sqlExecute(
'''UPDATE sent SET status='toodifficult' WHERE ackdata=? ''',
ackdata)
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow","Problem: The work demanded by the recipient (%1 and %2) is more difficult than you are willing to do.").arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte)/shared.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
ifrequiredAverageProofOfWorkNonceTrialsPerByte<shared.networkDefaultProofOfWorkNonceTrialsPerByte:# We still have to meet a minimum POW difficulty regardless of what they say is allowed in order to get our message to propagate through the network.
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow","Doing work necessary to send message.\nReceiver\'s required difficulty: %1 and %2").arg(str(float(
# The demanded difficulty is more than we are willing
# to do.
sqlExecute(
'''UPDATE sent SET status='toodifficult' WHERE ackdata=? ''',
ackdata)
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow","Problem: The work demanded by the recipient (%1 and %2) is more difficult than you are willing to do.").arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte)/shared.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
else:# if we are sending a message to ourselves or a chan..
withshared.printLock:
print'Sending a message. First 150 characters of message:',repr(message[:150])
behaviorBitfield='\x00\x00\x00\x01'
try:
privEncryptionKeyBase58=shared.config.get(
toaddress,'privencryptionkey')
exceptExceptionaserr:
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow",'Problem: You are trying to send a message to yourself or a chan but your encryption key could not be found in the keys.dat file. Could not encrypt message. %1').arg(unicode(strftime(shared.config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))),'utf-8')))))
withshared.printLock:
sys.stderr.write(
'Error within sendMsg. Could not read the keys from the keys.dat file for our own address. %s\n'%err)
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,tr.translateText("MainWindow","Message sent. Waiting on acknowledgement. Sent on %1").arg(unicode(