commit
905d9888d0
|
@ -678,8 +678,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
shared.UISignalQueue.put(('rerenderSubscriptions', ''))
|
shared.UISignalQueue.put(('rerenderSubscriptions', ''))
|
||||||
return 'Deleted subscription if it existed.'
|
return 'Deleted subscription if it existed.'
|
||||||
elif method == 'listSubscriptions':
|
elif method == 'listSubscriptions':
|
||||||
if len(params) != 0:
|
|
||||||
return "API Error 0000: I don't accept parameters!"
|
|
||||||
shared.sqlLock.acquire()
|
shared.sqlLock.acquire()
|
||||||
shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM subscriptions''')
|
shared.sqlSubmitQueue.put('''SELECT label, address, enabled FROM subscriptions''')
|
||||||
shared.sqlSubmitQueue.put('')
|
shared.sqlSubmitQueue.put('')
|
||||||
|
|
|
@ -271,81 +271,11 @@ class singleWorker(threading.Thread):
|
||||||
fromaddress, subject, body, ackdata = row
|
fromaddress, subject, body, ackdata = row
|
||||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||||
fromaddress)
|
fromaddress)
|
||||||
"""if addressVersionNumber == 2 and int(time.time()) < shared.encryptedBroadcastSwitchoverTime:
|
if addressVersionNumber <= 1:
|
||||||
# We need to convert our private keys to public keys in order
|
with shared.printLock:
|
||||||
# to include them.
|
sys.stderr.write(
|
||||||
try:
|
'Error: In the singleWorker thread, the sendBroadcast function doesn\'t understand the address version.\n')
|
||||||
privSigningKeyBase58 = shared.config.get(
|
return
|
||||||
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
|
# We need to convert our private keys to public keys in order
|
||||||
# to include them.
|
# to include them.
|
||||||
try:
|
try:
|
||||||
|
@ -414,7 +344,8 @@ class singleWorker(threading.Thread):
|
||||||
objectType = 'broadcast'
|
objectType = 'broadcast'
|
||||||
shared.inventory[inventoryHash] = (
|
shared.inventory[inventoryHash] = (
|
||||||
objectType, streamNumber, payload, int(time.time()))
|
objectType, streamNumber, payload, int(time.time()))
|
||||||
print 'sending inv (within sendBroadcast function)'
|
with shared.printLock:
|
||||||
|
print 'sending inv (within sendBroadcast function) for object:', inventoryHash.encode('hex')
|
||||||
shared.broadcastToSendDataQueues((
|
shared.broadcastToSendDataQueues((
|
||||||
streamNumber, 'sendinv', inventoryHash))
|
streamNumber, 'sendinv', inventoryHash))
|
||||||
|
|
||||||
|
@ -425,17 +356,13 @@ class singleWorker(threading.Thread):
|
||||||
# a 'broadcastsent' status
|
# a 'broadcastsent' status
|
||||||
shared.sqlLock.acquire()
|
shared.sqlLock.acquire()
|
||||||
t = (inventoryHash,'broadcastsent', int(
|
t = (inventoryHash,'broadcastsent', int(
|
||||||
time.time()), fromaddress, subject, body, 'broadcastqueued')
|
time.time()), ackdata)
|
||||||
shared.sqlSubmitQueue.put(
|
shared.sqlSubmitQueue.put(
|
||||||
'UPDATE sent SET msgid=?, status=?, lastactiontime=? WHERE fromaddress=? AND subject=? AND message=? AND status=?')
|
'UPDATE sent SET msgid=?, status=?, lastactiontime=? WHERE ackdata=?')
|
||||||
shared.sqlSubmitQueue.put(t)
|
shared.sqlSubmitQueue.put(t)
|
||||||
queryreturn = shared.sqlReturnQueue.get()
|
queryreturn = shared.sqlReturnQueue.get()
|
||||||
shared.sqlSubmitQueue.put('commit')
|
shared.sqlSubmitQueue.put('commit')
|
||||||
shared.sqlLock.release()
|
shared.sqlLock.release()
|
||||||
else:
|
|
||||||
with shared.printLock:
|
|
||||||
sys.stderr.write(
|
|
||||||
'Error: In the singleWorker thread, the sendBroadcast function doesn\'t understand the address version.\n')
|
|
||||||
|
|
||||||
|
|
||||||
def sendMsg(self):
|
def sendMsg(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user