pkgdesc="Bitmessage is a P2P communications protocol used to send encrypted messages to another person or to many subscribers. It is decentralized and trustless, meaning that you need-not inherently trust any entities like root certificate authorities. It uses strong authentication which means that the sender of a message cannot be spoofed, and it aims to hide "non-content" data, like the sender and receiver of messages, from passive eavesdroppers like those running warrantless wiretapping programs."
return 'API Error 0001: The specified passphrase is blank.'
passphrase=passphrase.decode('base64')
raise APIError(1,'The specified passphrase is blank.')
passphrase=self._decode(passphrase,"base64")
ifaddressVersionNumber==0:# 0 means "just use the proper addressVersionNumber"
addressVersionNumber=3
ifaddressVersionNumber!=3:
return 'API Error 0002: The address version number currently must be 3 (or 0 which means auto-select). '+addressVersionNumber+' isn\'t supported.'
raise APIError(2,'The address version number currently must be 3 (or 0 which means auto-select). '+addressVersionNumber+' isn\'t supported.')
ifstreamNumber==0:# 0 means "just use the most available stream"
streamNumber=1
ifstreamNumber!=1:
return 'API Error 0003: The stream number must be 1 (or 0 which means auto-select). Others aren\'t supported.'
raise APIError(3,'The stream number must be 1 (or 0 which means auto-select). Others aren\'t supported.')
ifnumberOfAddresses==0:
return 'API Error 0004: Why would you ask me to generate 0 addresses for you?'
raise APIError(4,'Why would you ask me to generate 0 addresses for you?')
ifnumberOfAddresses>999:
return 'API Error 0005: You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.'
raise APIError(5,'You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.')
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent WHERE msgid=?''')
@ -429,7 +435,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
@ -449,8 +455,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
returndata
elifmethod=='getSentMessageByAckData':
iflen(params)==0:
return 'API Error 0000: I need parameters!'
ackData=params[0].decode('hex')
raise APIError(0,'I need parameters!')
ackData=self._decode(params[0],"hex")
v=(ackData,)
shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent WHERE ackdata=?''')
@ -467,8 +473,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
returndata
elifmethod=='trashMessage':
iflen(params)==0:
return 'API Error 0000: I need parameters!'
msgid=params[0].decode('hex')
raise APIError(0,'I need parameters!')
msgid=self._decode(params[0],"hex")
# Trash if in inbox table
helper_inbox.trash(msgid)
@ -484,14 +490,14 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
readPosition,data)# When this function returns, we will have either successfully processed this broadcast because we are interested in it, ignored it because we aren't interested in it, or found problem with the broadcast that warranted ignoring it.
@ -760,8 +762,9 @@ class receiveDataThread(threading.Thread):
objectType,self.streamNumber,data,embeddedTime)
shared.inventoryLock.release()
self.broadcastinv(self.inventoryHash)
shared.numberOfMessagesProcessed+=1
shared.UISignalQueue.put((
'incrementNumberOfMessagesProcessed','no data'))
'updateNumberOfMessagesProcessed','no data'))
self.processmsg(
readPosition,data)# When this function returns, we will have either successfully processed the message bound for us, ignored it because it isn't bound for us, or found problem with the message that warranted ignoring it.
@ -1178,8 +1181,9 @@ class receiveDataThread(threading.Thread):
objectType,self.streamNumber,data,embeddedTime)
shared.inventoryLock.release()
self.broadcastinv(inventoryHash)
shared.numberOfPubkeysProcessed+=1
shared.UISignalQueue.put((
'incrementNumberOfPubkeysProcessed','no data'))
'updateNumberOfPubkeysProcessed','no data'))
self.processpubkey(data)
@ -1216,7 +1220,7 @@ class receiveDataThread(threading.Thread):
ifaddressVersion==0:
print'(Within processpubkey) addressVersion of 0 doesn\'t make sense.'
return
ifaddressVersion>=4oraddressVersion==1:
ifaddressVersion>3oraddressVersion==1:
withshared.printLock:
print'This version of Bitmessage cannot handle version',addressVersion,'addresses.'
print'Deleting all pubkeys from inventory. They will be redownloaded and then saved with the correct times.'
logger.debug('Deleting all pubkeys from inventory. They will be redownloaded and then saved with the correct times.')
self.cur.execute(
'''delete from inventory where objecttype = 'pubkey';''')
print'replacing Bitmessage announcements mailing list with a new one.'
logger.debug('replacing Bitmessage announcements mailing list with a new one.')
self.cur.execute(
'''delete from subscriptions where address='BM-BbkPSZbzPwpVcYZpU4yHwf9ZPEapN5Zx'''')
self.cur.execute(
'''INSERT INTO subscriptions VALUES('Bitmessage new releases/announcements','BM-GtovgYdgs7qXPkoYaRgrLFuFKz1SFpsw',1)''')
print'Commiting.'
logger.debug('Commiting.')
self.conn.commit()
print'Vacuuming message.dat. You might notice that the file size gets much smaller.'
logger.debug('Vacuuming message.dat. You might notice that the file size gets much smaller.')
self.cur.execute(''' VACUUM ''')
# After code refactoring, the possible status values for sent messages
@ -219,11 +218,11 @@ class sqlThread(threading.Thread):
self.cur.execute('''DELETE FROM pubkeys WHERE hash='1234'''')
self.conn.commit()
iftransmitdata=='':
sys.stderr.write('Problem: The version of SQLite you have cannot store Null values. Please download and install the latest revision of your version of Python (for example, the latest Python 2.7 revision) and try again.\n')
sys.stderr.write('PyBitmessage will now exit very abruptly. You may now see threading errors related to this abrupt exit but the problem you need to solve is related to SQLite.\n\n')
logger.fatal('Problem: The version of SQLite you have cannot store Null values. Please download and install the latest revision of your version of Python (for example, the latest Python 2.7 revision) and try again.\n')
logger.fatal('PyBitmessage will now exit very abruptly. You may now see threading errors related to this abrupt exit but the problem you need to solve is related to SQLite.\n\n')
os._exit(0)
exceptExceptionaserr:
printerr
logger.error(err)
# Let us check to see the last time we vaccumed the messages.dat file.
# If it has been more than a month let's do it now.
@ -234,7 +233,7 @@ class sqlThread(threading.Thread):
forrowinqueryreturn:
value,=row
ifint(value)<int(time.time())-2592000:
print'It has been a long time since the messages.dat file has been vacuumed. Vacuuming now...'
logger.info('It has been a long time since the messages.dat file has been vacuumed. Vacuuming now...')
self.cur.execute(''' VACUUM ''')
item='''update settings set value=? WHERE key='lastvacuumtime';'''
parameters=(int(time.time()),)
@ -246,13 +245,11 @@ class sqlThread(threading.Thread):
self.conn.commit()
elifitem=='exit':
self.conn.close()
withshared.printLock:
print'sqlThread exiting gracefully.'
logger.info('sqlThread exiting gracefully.')
return
elifitem=='movemessagstoprog':
withshared.printLock:
print'the sqlThread is moving the messages.dat file to the local program directory.'
logger.debug('the sqlThread is moving the messages.dat file to the local program directory.')