undid support for receiving v4 addresses until more chanages are implemented
This commit is contained in:
commit
1bb86794a8
|
@ -97,13 +97,18 @@ def calculateInventoryHash(data):
|
||||||
return sha2.digest()[0:32]
|
return sha2.digest()[0:32]
|
||||||
|
|
||||||
def encodeAddress(version,stream,ripe):
|
def encodeAddress(version,stream,ripe):
|
||||||
if version >= 2:
|
if version >= 2 and version < 4:
|
||||||
if len(ripe) != 20:
|
if len(ripe) != 20:
|
||||||
raise Exception("Programming error in encodeAddress: The length of a given ripe hash was not 20.")
|
raise Exception("Programming error in encodeAddress: The length of a given ripe hash was not 20.")
|
||||||
if ripe[:2] == '\x00\x00':
|
if ripe[:2] == '\x00\x00':
|
||||||
ripe = ripe[2:]
|
ripe = ripe[2:]
|
||||||
elif ripe[:1] == '\x00':
|
elif ripe[:1] == '\x00':
|
||||||
ripe = ripe[1:]
|
ripe = ripe[1:]
|
||||||
|
elif version == 4:
|
||||||
|
if len(ripe) != 20:
|
||||||
|
raise Exception("Programming error in encodeAddress: The length of a given ripe hash was not 20.")
|
||||||
|
ripe = ripe.lstrip('\x00')
|
||||||
|
|
||||||
a = encodeVarint(version) + encodeVarint(stream) + ripe
|
a = encodeVarint(version) + encodeVarint(stream) + ripe
|
||||||
sha = hashlib.new('sha512')
|
sha = hashlib.new('sha512')
|
||||||
sha.update(a)
|
sha.update(a)
|
||||||
|
@ -164,7 +169,7 @@ def decodeAddress(address):
|
||||||
#print 'addressVersionNumber', addressVersionNumber
|
#print 'addressVersionNumber', addressVersionNumber
|
||||||
#print 'bytesUsedByVersionNumber', bytesUsedByVersionNumber
|
#print 'bytesUsedByVersionNumber', bytesUsedByVersionNumber
|
||||||
|
|
||||||
if addressVersionNumber > 3:
|
if addressVersionNumber > 4:
|
||||||
print 'cannot decode address version numbers this high'
|
print 'cannot decode address version numbers this high'
|
||||||
status = 'versiontoohigh'
|
status = 'versiontoohigh'
|
||||||
return status,0,0,0
|
return status,0,0,0
|
||||||
|
@ -191,6 +196,15 @@ def decodeAddress(address):
|
||||||
return 'ripetoolong',0,0,0
|
return 'ripetoolong',0,0,0
|
||||||
else:
|
else:
|
||||||
return 'otherproblem',0,0,0
|
return 'otherproblem',0,0,0
|
||||||
|
elif addressVersionNumber == 4:
|
||||||
|
if len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]) > 20:
|
||||||
|
return 'ripetoolong',0,0,0
|
||||||
|
elif len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]) < 4:
|
||||||
|
return 'ripetooshort',0,0,0
|
||||||
|
else:
|
||||||
|
x00string = '\x00' * (20 - len(data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]))
|
||||||
|
return status,addressVersionNumber,streamNumber,x00string+data[bytesUsedByVersionNumber+bytesUsedByStreamNumber:-4]
|
||||||
|
|
||||||
|
|
||||||
def addBMIfNotPresent(address):
|
def addBMIfNotPresent(address):
|
||||||
address = str(address).strip()
|
address = str(address).strip()
|
||||||
|
|
|
@ -1220,7 +1220,7 @@ class receiveDataThread(threading.Thread):
|
||||||
if addressVersion == 0:
|
if addressVersion == 0:
|
||||||
print '(Within processpubkey) addressVersion of 0 doesn\'t make sense.'
|
print '(Within processpubkey) addressVersion of 0 doesn\'t make sense.'
|
||||||
return
|
return
|
||||||
if addressVersion >= 4 or addressVersion == 1:
|
if addressVersion > 3 or addressVersion == 1:
|
||||||
with shared.printLock:
|
with shared.printLock:
|
||||||
print 'This version of Bitmessage cannot handle version', addressVersion, 'addresses.'
|
print 'This version of Bitmessage cannot handle version', addressVersion, 'addresses.'
|
||||||
|
|
||||||
|
|
|
@ -535,6 +535,8 @@ class singleWorker(threading.Thread):
|
||||||
pubEncryptionKeyBase256 = pubkeyPayload[
|
pubEncryptionKeyBase256 = pubkeyPayload[
|
||||||
readPosition:readPosition + 64]
|
readPosition:readPosition + 64]
|
||||||
readPosition += 64
|
readPosition += 64
|
||||||
|
|
||||||
|
# Let us fetch the amount of work required by the recipient.
|
||||||
if toAddressVersionNumber == 2:
|
if toAddressVersionNumber == 2:
|
||||||
requiredAverageProofOfWorkNonceTrialsPerByte = shared.networkDefaultProofOfWorkNonceTrialsPerByte
|
requiredAverageProofOfWorkNonceTrialsPerByte = shared.networkDefaultProofOfWorkNonceTrialsPerByte
|
||||||
requiredPayloadLengthExtraBytes = shared.networkDefaultPayloadLengthExtraBytes
|
requiredPayloadLengthExtraBytes = shared.networkDefaultPayloadLengthExtraBytes
|
||||||
|
@ -569,6 +571,7 @@ class singleWorker(threading.Thread):
|
||||||
requiredPayloadLengthExtraBytes) / shared.networkDefaultPayloadLengthExtraBytes)).arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8')))))
|
requiredPayloadLengthExtraBytes) / shared.networkDefaultPayloadLengthExtraBytes)).arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8')))))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
embeddedTime = pack('>Q', (int(time.time()) + random.randrange(
|
embeddedTime = pack('>Q', (int(time.time()) + random.randrange(
|
||||||
-300, 300))) # the current time plus or minus five minutes. We will use this time both for our message and for the ackdata packed within our message.
|
-300, 300))) # the current time plus or minus five minutes. We will use this time both for our message and for the ackdata packed within our message.
|
||||||
if fromAddressVersionNumber == 2:
|
if fromAddressVersionNumber == 2:
|
||||||
|
|
|
@ -20,6 +20,7 @@ import sys
|
||||||
import stat
|
import stat
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
from os import path, environ
|
||||||
|
|
||||||
# Project imports.
|
# Project imports.
|
||||||
from addresses import *
|
from addresses import *
|
||||||
|
@ -125,7 +126,6 @@ def assembleVersionMessage(remoteHost, remotePort, myStreamNumber):
|
||||||
|
|
||||||
def lookupAppdataFolder():
|
def lookupAppdataFolder():
|
||||||
APPNAME = "PyBitmessage"
|
APPNAME = "PyBitmessage"
|
||||||
from os import path, environ
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
if "HOME" in environ:
|
if "HOME" in environ:
|
||||||
dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/'
|
dataFolder = path.join(os.environ["HOME"], "Library/Application Support/", APPNAME) + '/'
|
||||||
|
@ -239,7 +239,7 @@ def reloadMyAddressHashes():
|
||||||
if isEnabled:
|
if isEnabled:
|
||||||
hasEnabledKeys = True
|
hasEnabledKeys = True
|
||||||
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile)
|
status,addressVersionNumber,streamNumber,hash = decodeAddress(addressInKeysFile)
|
||||||
if addressVersionNumber == 2 or addressVersionNumber == 3:
|
if addressVersionNumber == 2 or addressVersionNumber == 3 or addressVersionNumber == 4:
|
||||||
# Returns a simple 32 bytes of information encoded in 64 Hex characters,
|
# Returns a simple 32 bytes of information encoded in 64 Hex characters,
|
||||||
# or null if there was an error.
|
# or null if there was an error.
|
||||||
privEncryptionKey = decodeWalletImportFormat(
|
privEncryptionKey = decodeWalletImportFormat(
|
||||||
|
@ -250,7 +250,7 @@ def reloadMyAddressHashes():
|
||||||
myAddressesByHash[hash] = addressInKeysFile
|
myAddressesByHash[hash] = addressInKeysFile
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.error('Error in reloadMyAddressHashes: Can\'t handle address versions other than 2 or 3.\n')
|
logger.error('Error in reloadMyAddressHashes: Can\'t handle address versions other than 2, 3, or 4.\n')
|
||||||
|
|
||||||
if not keyfileSecure:
|
if not keyfileSecure:
|
||||||
fixSensitiveFilePermissions(appdata + 'keys.dat', hasEnabledKeys)
|
fixSensitiveFilePermissions(appdata + 'keys.dat', hasEnabledKeys)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user