Merge branch 'master' of https://github.com/Bitmessage/PyBitmessage into single_line_subject
This commit is contained in:
commit
71f3a480da
4
arch.sh
4
arch.sh
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.3.4
|
||||
VERSION=0.3.4
|
||||
PREV_VERSION=0.3.5
|
||||
VERSION=0.3.5
|
||||
RELEASE=1
|
||||
ARCH_TYPE=`uname -m`
|
||||
CURRDIR=`pwd`
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Maintainer: Bob Mottram (4096 bits) <bob@robotics.uk.to>
|
||||
pkgname=pybitmessage
|
||||
pkgver=0.3.4
|
||||
pkgver=0.3.5
|
||||
pkgrel=1
|
||||
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."
|
||||
arch=('i686' 'x86_64')
|
||||
|
|
2
debian.sh
Normal file → Executable file
2
debian.sh
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
|||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.3.4
|
||||
VERSION=0.3.4
|
||||
VERSION=0.3.5
|
||||
RELEASE=1
|
||||
ARCH_TYPE=`uname -m`
|
||||
DIR=${APP}-${VERSION}
|
||||
|
|
28
debian/changelog
vendored
28
debian/changelog
vendored
|
@ -1,3 +1,31 @@
|
|||
pybitmessage (0.3.5-1) raring; urgency=low
|
||||
|
||||
* Inbox message retrieval API functions now also returns read status
|
||||
* Added right-click option to mark a message as unread
|
||||
* Prompt user to connect at first startup
|
||||
* Install into /usr/local by default
|
||||
* Add a missing rm -f to the uninstall task.
|
||||
* Use system text color for enabled addresses instead of black
|
||||
* Added support for Chans
|
||||
* Start storing msgid in sent table
|
||||
* Optionally play sounds on connection/disconnection or when messages arrive
|
||||
* Adding configuration option to listen for connections when using SOCKS
|
||||
* Added packaging for multiple distros (Arch, Puppy, Slack, etc.)
|
||||
* Added Russian translation
|
||||
* Added search support in the UI
|
||||
* Added 'make uninstall'
|
||||
* To improve OSX support, use PKCS5_PBKDF2_HMAC_SHA1 if PKCS5_PBKDF2_HMAC is unavailable
|
||||
* Added better warnings for OSX users who are using old versions of Python
|
||||
* Repaired debian packaging
|
||||
* Altered Makefile to avoid needing to chase changes
|
||||
* Added logger module
|
||||
* Added bgWorker class for background tasks
|
||||
* Added use of gevent module
|
||||
* On not-Windows: Fix insecure keyfile permissions
|
||||
* Fix 100% CPU usage issue
|
||||
|
||||
-- Bob Mottram (4096 bits) <bob@robotics.uk.to> Mon, 29 July 2013 22:11:00 +0100
|
||||
|
||||
pybitmessage (0.3.4-1) raring; urgency=low
|
||||
|
||||
* Switched addr, msg, broadcast, and getpubkey message types
|
||||
|
|
0
debian/rules
vendored
Normal file → Executable file
0
debian/rules
vendored
Normal file → Executable file
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.3.4
|
||||
VERSION=0.3.4
|
||||
PREV_VERSION=0.3.5
|
||||
VERSION=0.3.5
|
||||
RELEASE=1
|
||||
SOURCEDIR=.
|
||||
ARCH_TYPE=`uname -m`
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
rm -f Makefile rpmpackage/*.spec
|
||||
|
||||
packagemonkey -n "PyBitmessage" --version "0.3.4" --dir "." -l "mit" -e "Bob Mottram (4096 bits) <bob@robotics.uk.to>" --brief "Send encrypted messages" --desc "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." --homepage "https://github.com/Bitmessage/PyBitmessage" --section "mail" --categories "Office/Email" --dependsdeb "python (>= 2.7.0), openssl, python-qt4, libqt4-dev (>= 4.8.0), python-qt4-dev, sqlite3, libsqlite3-dev, gst123" --dependsrpm "python, PyQt4, openssl-compat-bitcoin-libs, gst123" --mainscript "bitmessagemain.py" --librarypath "/opt/openssl-compat-bitcoin/lib/" --suggestsdeb "libmessaging-menu-dev" --dependspuppy "openssl, python-qt4, sqlite3, sqlite3-dev, python-openssl, python-sip, gst123" --dependsarch "python2, qt4, python2-pyqt4, sqlite, openssl, gst123" --suggestsarch "python2-gevent" --pythonversion 2 --dependsebuild "dev-libs/openssl, dev-python/PyQt4[${PYTHON_USEDEP}]" --buildebuild "\${PYTHON_DEPS}" --pythonreq "sqlite" --repository "https://github.com/Bitmessage/PyBitmessage.git"
|
||||
packagemonkey -n "PyBitmessage" --version "0.3.5" --dir "." -l "mit" -e "Bob Mottram (4096 bits) <bob@robotics.uk.to>" --brief "Send encrypted messages" --desc "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." --homepage "https://github.com/Bitmessage/PyBitmessage" --section "mail" --categories "Office/Email" --dependsdeb "python (>= 2.7.0), openssl, python-qt4, libqt4-dev (>= 4.8.0), python-qt4-dev, sqlite3, libsqlite3-dev, gst123" --dependsrpm "python, PyQt4, openssl-compat-bitcoin-libs, gst123" --mainscript "bitmessagemain.py" --librarypath "/opt/openssl-compat-bitcoin/lib/" --suggestsdeb "libmessaging-menu-dev" --dependspuppy "openssl, python-qt4, sqlite3, sqlite3-dev, python-openssl, python-sip, gst123" --dependsarch "python2, qt4, python2-pyqt4, sqlite, openssl, gst123" --suggestsarch "python2-gevent" --pythonversion 2 --dependsebuild "dev-libs/openssl, dev-python/PyQt4[${PYTHON_USEDEP}]" --buildebuild "\${PYTHON_DEPS}" --pythonreq "sqlite" --repository "https://github.com/Bitmessage/PyBitmessage.git"
|
||||
|
|
4
puppy.sh
4
puppy.sh
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.3.4
|
||||
VERSION=0.3.4
|
||||
PREV_VERSION=0.3.5
|
||||
VERSION=0.3.5
|
||||
RELEASE=1
|
||||
BUILDDIR=~/petbuild
|
||||
CURRDIR=`pwd`
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
pybitmessage-0.3.4-1|PyBitmessage|0.3.4|1|Internet;mailnews;|5.8M||pybitmessage-0.3.4-1.pet|+openssl,+python-qt4,+sqlite3,+sqlite3-dev,+python-openssl,+python-sip,+gst123|Send encrypted messages|ubuntu|precise|5|
|
1
puppypackage/pybitmessage-0.3.5.pet.specs
Normal file
1
puppypackage/pybitmessage-0.3.5.pet.specs
Normal file
|
@ -0,0 +1 @@
|
|||
pybitmessage-0.3.5-1|PyBitmessage|0.3.5|1|Internet;mailnews;|7.2M||pybitmessage-0.3.5-1.pet|+openssl,+python-qt4,+sqlite3,+sqlite3-dev,+python-openssl,+python-sip,+gst123|Send encrypted messages|ubuntu|precise|5|
|
4
rpm.sh
4
rpm.sh
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.3.4
|
||||
VERSION=0.3.4
|
||||
PREV_VERSION=0.3.5
|
||||
VERSION=0.3.5
|
||||
RELEASE=1
|
||||
SOURCEDIR=.
|
||||
ARCH_TYPE=`uname -m`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Name: pybitmessage
|
||||
Version: 0.3.4
|
||||
Version: 0.3.5
|
||||
Release: 1%{?dist}
|
||||
Summary: Send encrypted messages
|
||||
License: MIT
|
||||
|
@ -68,6 +68,31 @@ make install -B DESTDIR=%{buildroot} PREFIX=/usr
|
|||
%attr(644,root,root) /usr/share/icons/hicolor/24x24/apps/%{name}.png
|
||||
|
||||
%changelog
|
||||
* Mon Jul 29 2013 Bob Mottram (4096 bits) <bob@robotics.uk.to> - 0.3.5-1
|
||||
- Inbox message retrieval API functions now also returns read status
|
||||
- Added right-click option to mark a message as unread
|
||||
- Prompt user to connect at first startup
|
||||
- Install into /usr/local by default
|
||||
- Add a missing rm -f to the uninstall task.
|
||||
- Use system text color for enabled addresses instead of black
|
||||
- Added support for Chans
|
||||
- Start storing msgid in sent table
|
||||
- Optionally play sounds on connection/disconnection or when messages arrive
|
||||
- Adding configuration option to listen for connections when using SOCKS
|
||||
- Added packaging for multiple distros (Arch, Puppy, Slack, etc.)
|
||||
- Added Russian translation
|
||||
- Added search support in the UI
|
||||
- Added 'make uninstall'
|
||||
- To improve OSX support, use PKCS5_PBKDF2_HMAC_SHA1 if PKCS5_PBKDF2_HMAC is unavailable
|
||||
- Added better warnings for OSX users who are using old versions of Python
|
||||
- Repaired debian packaging
|
||||
- Altered Makefile to avoid needing to chase changes
|
||||
- Added logger module
|
||||
- Added bgWorker class for background tasks
|
||||
- Added use of gevent module
|
||||
- On not-Windows: Fix insecure keyfile permissions
|
||||
- Fix 100% CPU usage issue
|
||||
|
||||
* Sun Jun 30 2013 Bob Mottram (4096 bits) <bob@robotics.uk.to> - 0.3.4-1
|
||||
- Switched addr, msg, broadcast, and getpubkey message types
|
||||
to 8 byte time. Last remaining type is pubkey.
|
||||
|
|
4
slack.sh
4
slack.sh
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
APP=pybitmessage
|
||||
PREV_VERSION=0.3.4
|
||||
VERSION=0.3.4
|
||||
PREV_VERSION=0.3.5
|
||||
VERSION=0.3.5
|
||||
RELEASE=1
|
||||
ARCH_TYPE=`uname -m`
|
||||
BUILDDIR=~/slackbuild
|
||||
|
|
|
@ -341,8 +341,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'receivedTime':received, 'read': read}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getAllSentMessages':
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put('''SELECT msgid, toaddress, fromaddress, subject, lastactiontime, message, encodingtype, status, ackdata FROM sent where folder='sent' ORDER BY lastactiontime''')
|
||||
|
@ -395,8 +395,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
|
||||
message = shared.fixPotentiallyInvalidUTF8Data(message)
|
||||
data += json.dumps({'msgid':msgid.encode('hex'), 'toAddress':toAddress, 'fromAddress':fromAddress, 'subject':subject.encode('base64'), 'message':message.encode('base64'), 'encodingType':encodingtype, 'lastActionTime':lastactiontime, 'status':status, 'ackData':ackdata.encode('hex')}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'getSentMessagesByAddress' or method == 'getSentMessagesBySender':
|
||||
if len(params) == 0:
|
||||
return 'API Error 0000: I need parameters!'
|
||||
|
@ -677,10 +677,25 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
shared.UISignalQueue.put(('rerenderInboxFromLabels', ''))
|
||||
shared.UISignalQueue.put(('rerenderSubscriptions', ''))
|
||||
return 'Deleted subscription if it existed.'
|
||||
elif method == 'listSubscriptions':
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM subscriptions''')
|
||||
shared.sqlSubmitQueue.put('')
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlLock.release()
|
||||
data = '{"subscriptions":['
|
||||
for row in queryreturn:
|
||||
label, address, enabled = row
|
||||
label = shared.fixPotentiallyInvalidUTF8Data(label)
|
||||
if len(data) > 20:
|
||||
data += ','
|
||||
data += json.dumps({'label':label.encode('base64'), 'address': address, 'enabled': enabled == 1}, indent=4, separators=(',',': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'clientStatus':
|
||||
return '{ "networkConnections" : "%s" }' % str(len(shared.connectedHostsList))
|
||||
else:
|
||||
return 'Invalid Method: %s' % method
|
||||
return 'API Error 0020: Invalid method: %s' % method
|
||||
|
||||
# This thread, of which there is only one, runs the API.
|
||||
|
||||
|
|
|
@ -1,80 +1,16 @@
|
|||
"""
|
||||
py2app/py2exe build script for Bitmessage
|
||||
|
||||
Usage (Mac OS X):
|
||||
python setup.py py2app
|
||||
|
||||
Usage (Windows):
|
||||
python setup.py py2exe
|
||||
"""
|
||||
|
||||
import sys, os, shutil, re
|
||||
from setuptools import setup # @UnresolvedImport
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
name = "Bitmessage"
|
||||
mainscript = 'bitmessagemain.py'
|
||||
version = "0.3.5"
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
extra_options = dict(
|
||||
setup_requires=['py2app'],
|
||||
app=[mainscript],
|
||||
options=dict(py2app=dict(argv_emulation=True,
|
||||
includes = ['PyQt4.QtCore','PyQt4.QtGui', 'sip', 'sqlite3'],
|
||||
packages = ['bitmessageqt'],
|
||||
frameworks = ['/usr/local/opt/openssl/lib/libcrypto.dylib'],
|
||||
iconfile='images/bitmessage.icns',
|
||||
resources=["images"])),
|
||||
)
|
||||
elif sys.platform == 'win32':
|
||||
extra_options = dict(
|
||||
setup_requires=['py2exe'],
|
||||
app=[mainscript],
|
||||
)
|
||||
else:
|
||||
extra_options = dict(
|
||||
# Normally unix-like platforms will use "setup.py install"
|
||||
# and install the main script as such
|
||||
scripts=[mainscript],
|
||||
)
|
||||
version = "0.3.4"
|
||||
mainscript = ["bitmessagemain.py"]
|
||||
|
||||
setup(
|
||||
name = name,
|
||||
version = version,
|
||||
**extra_options
|
||||
name = name,
|
||||
version = version,
|
||||
app = mainscript,
|
||||
setup_requires = ["py2app"],
|
||||
options = dict(py2app=dict(
|
||||
resources = ["images"],
|
||||
iconfile = "images/bitmessage.icns"
|
||||
))
|
||||
)
|
||||
from distutils import dir_util
|
||||
import glob
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
resource = "dist/" + name + ".app/Contents/Resources/"
|
||||
framework = "dist/" + name + ".app/Contents/Frameworks/"
|
||||
|
||||
# The pyElliptive module only works with hardcoded libcrypto paths so rename it so it can actually find it.
|
||||
libs = glob.glob(framework + "libcrypto*.dylib")
|
||||
for lib in libs:
|
||||
os.rename(lib, framework + "libcrypto.dylib")
|
||||
break
|
||||
|
||||
# Try to locate qt_menu
|
||||
# Let's try the port version first!
|
||||
if os.path.isfile("/opt/local/lib/Resources/qt_menu.nib"):
|
||||
qt_menu_location = "/opt/local/lib/Resources/qt_menu.nib"
|
||||
else:
|
||||
# No dice? Then let's try the brew version
|
||||
qt_menu_location = os.popen("find /usr/local/Cellar -name qt_menu.nib | tail -n 1").read()
|
||||
qt_menu_location = re.sub('\n','', qt_menu_location)
|
||||
|
||||
if(len(qt_menu_location) == 0):
|
||||
print "Sorry couldn't find your qt_menu.nib this probably won't work"
|
||||
else:
|
||||
print "Found your qib: " + qt_menu_location
|
||||
|
||||
# Need to include a copy of qt_menu.nib
|
||||
shutil.copytree(qt_menu_location, resource + "qt_menu.nib")
|
||||
# Need to touch qt.conf to avoid loading 2 sets of Qt libraries
|
||||
fname = resource + "qt.conf"
|
||||
with file(fname, 'a'):
|
||||
os.utime(fname, None)
|
||||
|
||||
|
|
|
@ -271,172 +271,99 @@ class singleWorker(threading.Thread):
|
|||
fromaddress, subject, body, ackdata = row
|
||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||
fromaddress)
|
||||
"""if addressVersionNumber == 2 and int(time.time()) < shared.encryptedBroadcastSwitchoverTime:
|
||||
# We need to convert our private keys to public keys in order
|
||||
# to include them.
|
||||
try:
|
||||
privSigningKeyBase58 = shared.config.get(
|
||||
fromaddress, 'privsigningkey')
|
||||
privEncryptionKeyBase58 = shared.config.get(
|
||||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
privSigningKeyBase58).encode('hex')
|
||||
privEncryptionKeyHex = shared.decodeWalletImportFormat(
|
||||
privEncryptionKeyBase58).encode('hex')
|
||||
|
||||
pubSigningKey = highlevelcrypto.privToPub(privSigningKeyHex).decode(
|
||||
'hex') # At this time these pubkeys are 65 bytes long because they include the encoding byte which we won't be sending in the broadcast message.
|
||||
pubEncryptionKey = highlevelcrypto.privToPub(
|
||||
privEncryptionKeyHex).decode('hex')
|
||||
|
||||
payload = pack('>Q', (int(time.time()) + random.randrange(
|
||||
-300, 300))) # the current time plus or minus five minutes
|
||||
payload += encodeVarint(1) # broadcast version
|
||||
payload += encodeVarint(addressVersionNumber)
|
||||
payload += encodeVarint(streamNumber)
|
||||
payload += '\x00\x00\x00\x01' # behavior bitfield
|
||||
payload += pubSigningKey[1:]
|
||||
payload += pubEncryptionKey[1:]
|
||||
payload += ripe
|
||||
payload += '\x02' # message encoding type
|
||||
payload += encodeVarint(len(
|
||||
'Subject:' + subject + '\n' + 'Body:' + body)) # Type 2 is simple UTF-8 message encoding.
|
||||
payload += 'Subject:' + subject + '\n' + 'Body:' + body
|
||||
|
||||
signature = highlevelcrypto.sign(payload, privSigningKeyHex)
|
||||
payload += encodeVarint(len(signature))
|
||||
payload += signature
|
||||
|
||||
target = 2 ** 64 / ((len(
|
||||
payload) + shared.networkDefaultPayloadLengthExtraBytes + 8) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)
|
||||
print '(For broadcast message) Doing proof of work...'
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Doing work necessary to send broadcast..."))))
|
||||
initialHash = hashlib.sha512(payload).digest()
|
||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||
print '(For broadcast message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q', nonce) + payload
|
||||
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'broadcast'
|
||||
shared.inventory[inventoryHash] = (
|
||||
objectType, streamNumber, payload, int(time.time()))
|
||||
print 'Broadcasting inv for my broadcast (within sendBroadcast function):', inventoryHash.encode('hex')
|
||||
shared.broadcastToSendDataQueues((
|
||||
streamNumber, 'sendinv', inventoryHash))
|
||||
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr.translateText("MainWindow", "Broadcast sent on %1").arg(unicode(
|
||||
strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8')))))
|
||||
|
||||
# Update the status of the message in the 'sent' table to have
|
||||
# a 'broadcastsent' status
|
||||
shared.sqlLock.acquire()
|
||||
t = ('broadcastsent', int(
|
||||
time.time()), fromaddress, subject, body, 'broadcastqueued')
|
||||
shared.sqlSubmitQueue.put(
|
||||
'UPDATE sent SET status=?, lastactiontime=? WHERE fromaddress=? AND subject=? AND message=? AND status=?')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()"""
|
||||
if addressVersionNumber == 2 or addressVersionNumber == 3:
|
||||
# We need to convert our private keys to public keys in order
|
||||
# to include them.
|
||||
try:
|
||||
privSigningKeyBase58 = shared.config.get(
|
||||
fromaddress, 'privsigningkey')
|
||||
privEncryptionKeyBase58 = shared.config.get(
|
||||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
privSigningKeyBase58).encode('hex')
|
||||
privEncryptionKeyHex = shared.decodeWalletImportFormat(
|
||||
privEncryptionKeyBase58).encode('hex')
|
||||
|
||||
pubSigningKey = highlevelcrypto.privToPub(privSigningKeyHex).decode(
|
||||
'hex') # At this time these pubkeys are 65 bytes long because they include the encoding byte which we won't be sending in the broadcast message.
|
||||
pubEncryptionKey = highlevelcrypto.privToPub(
|
||||
privEncryptionKeyHex).decode('hex')
|
||||
|
||||
payload = pack('>Q', (int(time.time()) + random.randrange(
|
||||
-300, 300))) # the current time plus or minus five minutes
|
||||
payload += encodeVarint(2) # broadcast version
|
||||
payload += encodeVarint(streamNumber)
|
||||
|
||||
dataToEncrypt = encodeVarint(2) # broadcast version
|
||||
dataToEncrypt += encodeVarint(addressVersionNumber)
|
||||
dataToEncrypt += encodeVarint(streamNumber)
|
||||
dataToEncrypt += '\x00\x00\x00\x01' # behavior bitfield
|
||||
dataToEncrypt += pubSigningKey[1:]
|
||||
dataToEncrypt += pubEncryptionKey[1:]
|
||||
if addressVersionNumber >= 3:
|
||||
dataToEncrypt += encodeVarint(shared.config.getint(fromaddress,'noncetrialsperbyte'))
|
||||
dataToEncrypt += encodeVarint(shared.config.getint(fromaddress,'payloadlengthextrabytes'))
|
||||
dataToEncrypt += '\x02' # message encoding type
|
||||
dataToEncrypt += encodeVarint(len('Subject:' + subject + '\n' + 'Body:' + body)) #Type 2 is simple UTF-8 message encoding per the documentation on the wiki.
|
||||
dataToEncrypt += 'Subject:' + subject + '\n' + 'Body:' + body
|
||||
signature = highlevelcrypto.sign(
|
||||
dataToEncrypt, privSigningKeyHex)
|
||||
dataToEncrypt += encodeVarint(len(signature))
|
||||
dataToEncrypt += signature
|
||||
|
||||
# Encrypt the broadcast with the information contained in the broadcaster's address. Anyone who knows the address can generate
|
||||
# the private encryption key to decrypt the broadcast. This provides virtually no privacy; its purpose is to keep questionable
|
||||
# and illegal content from flowing through the Internet connections and being stored on the disk of 3rd parties.
|
||||
privEncryptionKey = hashlib.sha512(encodeVarint(
|
||||
addressVersionNumber) + encodeVarint(streamNumber) + ripe).digest()[:32]
|
||||
pubEncryptionKey = pointMult(privEncryptionKey)
|
||||
payload += highlevelcrypto.encrypt(
|
||||
dataToEncrypt, pubEncryptionKey.encode('hex'))
|
||||
|
||||
target = 2 ** 64 / ((len(
|
||||
payload) + shared.networkDefaultPayloadLengthExtraBytes + 8) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)
|
||||
print '(For broadcast message) Doing proof of work...'
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Doing work necessary to send broadcast..."))))
|
||||
initialHash = hashlib.sha512(payload).digest()
|
||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||
print '(For broadcast message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q', nonce) + payload
|
||||
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'broadcast'
|
||||
shared.inventory[inventoryHash] = (
|
||||
objectType, streamNumber, payload, int(time.time()))
|
||||
print 'sending inv (within sendBroadcast function)'
|
||||
shared.broadcastToSendDataQueues((
|
||||
streamNumber, 'sendinv', inventoryHash))
|
||||
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr.translateText("MainWindow", "Broadcast sent on %1").arg(unicode(
|
||||
strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8')))))
|
||||
|
||||
# Update the status of the message in the 'sent' table to have
|
||||
# a 'broadcastsent' status
|
||||
shared.sqlLock.acquire()
|
||||
t = (inventoryHash,'broadcastsent', int(
|
||||
time.time()), fromaddress, subject, body, 'broadcastqueued')
|
||||
shared.sqlSubmitQueue.put(
|
||||
'UPDATE sent SET msgid=?, status=?, lastactiontime=? WHERE fromaddress=? AND subject=? AND message=? AND status=?')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
else:
|
||||
if addressVersionNumber <= 1:
|
||||
with shared.printLock:
|
||||
sys.stderr.write(
|
||||
'Error: In the singleWorker thread, the sendBroadcast function doesn\'t understand the address version.\n')
|
||||
return
|
||||
# We need to convert our private keys to public keys in order
|
||||
# to include them.
|
||||
try:
|
||||
privSigningKeyBase58 = shared.config.get(
|
||||
fromaddress, 'privsigningkey')
|
||||
privEncryptionKeyBase58 = shared.config.get(
|
||||
fromaddress, 'privencryptionkey')
|
||||
except:
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Error! Could not find sender address (your address) in the keys.dat file."))))
|
||||
continue
|
||||
|
||||
privSigningKeyHex = shared.decodeWalletImportFormat(
|
||||
privSigningKeyBase58).encode('hex')
|
||||
privEncryptionKeyHex = shared.decodeWalletImportFormat(
|
||||
privEncryptionKeyBase58).encode('hex')
|
||||
|
||||
pubSigningKey = highlevelcrypto.privToPub(privSigningKeyHex).decode(
|
||||
'hex') # At this time these pubkeys are 65 bytes long because they include the encoding byte which we won't be sending in the broadcast message.
|
||||
pubEncryptionKey = highlevelcrypto.privToPub(
|
||||
privEncryptionKeyHex).decode('hex')
|
||||
|
||||
payload = pack('>Q', (int(time.time()) + random.randrange(
|
||||
-300, 300))) # the current time plus or minus five minutes
|
||||
payload += encodeVarint(2) # broadcast version
|
||||
payload += encodeVarint(streamNumber)
|
||||
|
||||
dataToEncrypt = encodeVarint(2) # broadcast version
|
||||
dataToEncrypt += encodeVarint(addressVersionNumber)
|
||||
dataToEncrypt += encodeVarint(streamNumber)
|
||||
dataToEncrypt += '\x00\x00\x00\x01' # behavior bitfield
|
||||
dataToEncrypt += pubSigningKey[1:]
|
||||
dataToEncrypt += pubEncryptionKey[1:]
|
||||
if addressVersionNumber >= 3:
|
||||
dataToEncrypt += encodeVarint(shared.config.getint(fromaddress,'noncetrialsperbyte'))
|
||||
dataToEncrypt += encodeVarint(shared.config.getint(fromaddress,'payloadlengthextrabytes'))
|
||||
dataToEncrypt += '\x02' # message encoding type
|
||||
dataToEncrypt += encodeVarint(len('Subject:' + subject + '\n' + 'Body:' + body)) #Type 2 is simple UTF-8 message encoding per the documentation on the wiki.
|
||||
dataToEncrypt += 'Subject:' + subject + '\n' + 'Body:' + body
|
||||
signature = highlevelcrypto.sign(
|
||||
dataToEncrypt, privSigningKeyHex)
|
||||
dataToEncrypt += encodeVarint(len(signature))
|
||||
dataToEncrypt += signature
|
||||
|
||||
# Encrypt the broadcast with the information contained in the broadcaster's address. Anyone who knows the address can generate
|
||||
# the private encryption key to decrypt the broadcast. This provides virtually no privacy; its purpose is to keep questionable
|
||||
# and illegal content from flowing through the Internet connections and being stored on the disk of 3rd parties.
|
||||
privEncryptionKey = hashlib.sha512(encodeVarint(
|
||||
addressVersionNumber) + encodeVarint(streamNumber) + ripe).digest()[:32]
|
||||
pubEncryptionKey = pointMult(privEncryptionKey)
|
||||
payload += highlevelcrypto.encrypt(
|
||||
dataToEncrypt, pubEncryptionKey.encode('hex'))
|
||||
|
||||
target = 2 ** 64 / ((len(
|
||||
payload) + shared.networkDefaultPayloadLengthExtraBytes + 8) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)
|
||||
print '(For broadcast message) Doing proof of work...'
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (
|
||||
ackdata, tr.translateText("MainWindow", "Doing work necessary to send broadcast..."))))
|
||||
initialHash = hashlib.sha512(payload).digest()
|
||||
trialValue, nonce = proofofwork.run(target, initialHash)
|
||||
print '(For broadcast message) Found proof of work', trialValue, 'Nonce:', nonce
|
||||
|
||||
payload = pack('>Q', nonce) + payload
|
||||
|
||||
inventoryHash = calculateInventoryHash(payload)
|
||||
objectType = 'broadcast'
|
||||
shared.inventory[inventoryHash] = (
|
||||
objectType, streamNumber, payload, int(time.time()))
|
||||
with shared.printLock:
|
||||
print 'sending inv (within sendBroadcast function) for object:', inventoryHash.encode('hex')
|
||||
shared.broadcastToSendDataQueues((
|
||||
streamNumber, 'sendinv', inventoryHash))
|
||||
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr.translateText("MainWindow", "Broadcast sent on %1").arg(unicode(
|
||||
strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8')))))
|
||||
|
||||
# Update the status of the message in the 'sent' table to have
|
||||
# a 'broadcastsent' status
|
||||
shared.sqlLock.acquire()
|
||||
t = (inventoryHash,'broadcastsent', int(
|
||||
time.time()), ackdata)
|
||||
shared.sqlSubmitQueue.put(
|
||||
'UPDATE sent SET msgid=?, status=?, lastactiontime=? WHERE ackdata=?')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
|
||||
|
||||
def sendMsg(self):
|
||||
# Check to see if there are any messages queued to be sent
|
||||
|
|
Reference in New Issue
Block a user