Merge branch 'master' of github.com:Atheros1/PyBitmessage
This commit is contained in:
commit
9230e40e29
|
@ -706,11 +706,6 @@ if __name__ == "__main__":
|
||||||
signal.signal(signal.SIGINT, helper_generic.signal_handler)
|
signal.signal(signal.SIGINT, helper_generic.signal_handler)
|
||||||
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|
||||||
# Check the Major version, the first element in the array
|
|
||||||
if sqlite3.sqlite_version_info[0] < 3:
|
|
||||||
print 'This program requires sqlite version 3 or higher because 2 and lower cannot store NULL values. I see version:', sqlite3.sqlite_version_info
|
|
||||||
os._exit(0)
|
|
||||||
|
|
||||||
helper_startup.loadConfig()
|
helper_startup.loadConfig()
|
||||||
|
|
||||||
helper_bootstrap.knownNodes()
|
helper_bootstrap.knownNodes()
|
||||||
|
|
|
@ -21,7 +21,15 @@ class addressGenerator(threading.Thread):
|
||||||
queueValue = shared.addressGeneratorQueue.get()
|
queueValue = shared.addressGeneratorQueue.get()
|
||||||
nonceTrialsPerByte = 0
|
nonceTrialsPerByte = 0
|
||||||
payloadLengthExtraBytes = 0
|
payloadLengthExtraBytes = 0
|
||||||
if len(queueValue) == 7:
|
if queueValue[0] == 'createChan':
|
||||||
|
command, addressVersionNumber, streamNumber, label, deterministicPassphrase = queueValue
|
||||||
|
eighteenByteRipe = False
|
||||||
|
numberOfAddressesToMake = 1
|
||||||
|
elif queueValue[0] == 'joinChan':
|
||||||
|
command, chanAddress, label, deterministicPassphrase = queueValue
|
||||||
|
eighteenByteRipe = False
|
||||||
|
numberOfAddressesToMake = 1
|
||||||
|
elif len(queueValue) == 7:
|
||||||
command, addressVersionNumber, streamNumber, label, numberOfAddressesToMake, deterministicPassphrase, eighteenByteRipe = queueValue
|
command, addressVersionNumber, streamNumber, label, numberOfAddressesToMake, deterministicPassphrase, eighteenByteRipe = queueValue
|
||||||
elif len(queueValue) == 9:
|
elif len(queueValue) == 9:
|
||||||
command, addressVersionNumber, streamNumber, label, numberOfAddressesToMake, deterministicPassphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes = queueValue
|
command, addressVersionNumber, streamNumber, label, numberOfAddressesToMake, deterministicPassphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes = queueValue
|
||||||
|
@ -122,7 +130,7 @@ class addressGenerator(threading.Thread):
|
||||||
shared.workerQueue.put((
|
shared.workerQueue.put((
|
||||||
'doPOWForMyV3Pubkey', ripe.digest()))
|
'doPOWForMyV3Pubkey', ripe.digest()))
|
||||||
|
|
||||||
elif command == 'createDeterministicAddresses' or command == 'getDeterministicAddress':
|
elif command == 'createDeterministicAddresses' or command == 'getDeterministicAddress' or command == 'createChan' or command == 'joinChan':
|
||||||
if len(deterministicPassphrase) == 0:
|
if len(deterministicPassphrase) == 0:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
'WARNING: You are creating deterministic address(es) using a blank passphrase. Bitmessage will do it but it is rather stupid.')
|
'WARNING: You are creating deterministic address(es) using a blank passphrase. Bitmessage will do it but it is rather stupid.')
|
||||||
|
@ -176,7 +184,17 @@ class addressGenerator(threading.Thread):
|
||||||
print 'Address generator calculated', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, 'addresses at', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix / (time.time() - startTime), 'keys per second.'
|
print 'Address generator calculated', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix, 'addresses at', numberOfAddressesWeHadToMakeBeforeWeFoundOneWithTheCorrectRipePrefix / (time.time() - startTime), 'keys per second.'
|
||||||
address = encodeAddress(3, streamNumber, ripe.digest())
|
address = encodeAddress(3, streamNumber, ripe.digest())
|
||||||
|
|
||||||
if command == 'createDeterministicAddresses':
|
saveAddressToDisk = True
|
||||||
|
# If we are joining an existing chan, let us check to make sure it matches the provided Bitmessage address
|
||||||
|
if command == 'joinChan':
|
||||||
|
if address != chanAddress:
|
||||||
|
#todo: show an error message in the UI
|
||||||
|
shared.apiAddressGeneratorReturnQueue.put('API Error 0018: Chan name does not match address.')
|
||||||
|
saveAddressToDisk = False
|
||||||
|
if command == 'getDeterministicAddress':
|
||||||
|
saveAddressToDisk = False
|
||||||
|
|
||||||
|
if saveAddressToDisk:
|
||||||
# An excellent way for us to store our keys is in Wallet Import Format. Let us convert now.
|
# An excellent way for us to store our keys is in Wallet Import Format. Let us convert now.
|
||||||
# https://en.bitcoin.it/wiki/Wallet_import_format
|
# https://en.bitcoin.it/wiki/Wallet_import_format
|
||||||
privSigningKey = '\x80' + potentialPrivSigningKey
|
privSigningKey = '\x80' + potentialPrivSigningKey
|
||||||
|
@ -198,6 +216,8 @@ class addressGenerator(threading.Thread):
|
||||||
shared.config.set(address, 'label', label)
|
shared.config.set(address, 'label', label)
|
||||||
shared.config.set(address, 'enabled', 'true')
|
shared.config.set(address, 'enabled', 'true')
|
||||||
shared.config.set(address, 'decoy', 'false')
|
shared.config.set(address, 'decoy', 'false')
|
||||||
|
if command == 'joinChan' or command == 'createChan':
|
||||||
|
shared.config.set(address, 'chan', 'true')
|
||||||
shared.config.set(address, 'noncetrialsperbyte', str(
|
shared.config.set(address, 'noncetrialsperbyte', str(
|
||||||
nonceTrialsPerByte))
|
nonceTrialsPerByte))
|
||||||
shared.config.set(address, 'payloadlengthextrabytes', str(
|
shared.config.set(address, 'payloadlengthextrabytes', str(
|
||||||
|
@ -213,18 +233,11 @@ class addressGenerator(threading.Thread):
|
||||||
label, address, str(streamNumber))))
|
label, address, str(streamNumber))))
|
||||||
listOfNewAddressesToSendOutThroughTheAPI.append(
|
listOfNewAddressesToSendOutThroughTheAPI.append(
|
||||||
address)
|
address)
|
||||||
# if eighteenByteRipe:
|
|
||||||
# shared.reloadMyAddressHashes()#This is
|
|
||||||
# necessary here (rather than just at the end)
|
|
||||||
# because otherwise if the human generates a
|
|
||||||
# large number of new addresses and uses one
|
|
||||||
# before they are done generating, the program
|
|
||||||
# will receive a getpubkey message and will
|
|
||||||
# ignore it.
|
|
||||||
shared.myECCryptorObjects[ripe.digest()] = highlevelcrypto.makeCryptor(
|
shared.myECCryptorObjects[ripe.digest()] = highlevelcrypto.makeCryptor(
|
||||||
potentialPrivEncryptionKey.encode('hex'))
|
potentialPrivEncryptionKey.encode('hex'))
|
||||||
shared.myAddressesByHash[
|
shared.myAddressesByHash[
|
||||||
ripe.digest()] = address
|
ripe.digest()] = address
|
||||||
|
#todo: don't send out pubkey if dealing with a chan; save in pubkeys table instead.
|
||||||
shared.workerQueue.put((
|
shared.workerQueue.put((
|
||||||
'doPOWForMyV3Pubkey', ripe.digest()))
|
'doPOWForMyV3Pubkey', ripe.digest()))
|
||||||
except:
|
except:
|
||||||
|
@ -242,6 +255,7 @@ class addressGenerator(threading.Thread):
|
||||||
# shared.reloadMyAddressHashes()
|
# shared.reloadMyAddressHashes()
|
||||||
elif command == 'getDeterministicAddress':
|
elif command == 'getDeterministicAddress':
|
||||||
shared.apiAddressGeneratorReturnQueue.put(address)
|
shared.apiAddressGeneratorReturnQueue.put(address)
|
||||||
|
#todo: return things to the API if createChan or joinChan assuming saveAddressToDisk
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Error in the addressGenerator thread. Thread was given a command it could not understand: " + command)
|
"Error in the addressGenerator thread. Thread was given a command it could not understand: " + command)
|
||||||
|
|
|
@ -69,6 +69,22 @@ class sqlThread(threading.Thread):
|
||||||
'ERROR trying to create database file (message.dat). Error message: %s\n' % str(err))
|
'ERROR trying to create database file (message.dat). Error message: %s\n' % str(err))
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
|
if shared.config.getint('bitmessagesettings', 'settingsversion') == 1:
|
||||||
|
shared.config.set('bitmessagesettings', 'settingsversion', '2')
|
||||||
|
# If the settings version is equal to 2 or 3 then the
|
||||||
|
# sqlThread will modify the pubkeys table and change
|
||||||
|
# the settings version to 4.
|
||||||
|
shared.config.set('bitmessagesettings', 'socksproxytype', 'none')
|
||||||
|
shared.config.set('bitmessagesettings', 'sockshostname', 'localhost')
|
||||||
|
shared.config.set('bitmessagesettings', 'socksport', '9050')
|
||||||
|
shared.config.set('bitmessagesettings', 'socksauthentication', 'false')
|
||||||
|
shared.config.set('bitmessagesettings', 'socksusername', '')
|
||||||
|
shared.config.set('bitmessagesettings', 'sockspassword', '')
|
||||||
|
shared.config.set('bitmessagesettings', 'keysencrypted', 'false')
|
||||||
|
shared.config.set('bitmessagesettings', 'messagesencrypted', 'false')
|
||||||
|
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||||
|
shared.config.write(configfile)
|
||||||
|
|
||||||
# People running earlier versions of PyBitmessage do not have the
|
# People running earlier versions of PyBitmessage do not have the
|
||||||
# usedpersonally field in their pubkeys table. Let's add it.
|
# usedpersonally field in their pubkeys table. Let's add it.
|
||||||
if shared.config.getint('bitmessagesettings', 'settingsversion') == 2:
|
if shared.config.getint('bitmessagesettings', 'settingsversion') == 2:
|
||||||
|
@ -158,7 +174,7 @@ class sqlThread(threading.Thread):
|
||||||
self.cur.execute( ''' VACUUM ''')
|
self.cur.execute( ''' VACUUM ''')
|
||||||
|
|
||||||
# After code refactoring, the possible status values for sent messages
|
# After code refactoring, the possible status values for sent messages
|
||||||
# as changed.
|
# have changed.
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'''update sent set status='doingmsgpow' where status='doingpow' ''')
|
'''update sent set status='doingmsgpow' where status='doingpow' ''')
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
|
|
|
@ -76,19 +76,3 @@ def loadConfig():
|
||||||
os.makedirs(shared.appdata)
|
os.makedirs(shared.appdata)
|
||||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
||||||
shared.config.write(configfile)
|
shared.config.write(configfile)
|
||||||
|
|
||||||
if shared.config.getint('bitmessagesettings', 'settingsversion') == 1:
|
|
||||||
shared.config.set('bitmessagesettings', 'settingsversion', '4')
|
|
||||||
# If the settings version is equal to 2 or 3 then the
|
|
||||||
# sqlThread will modify the pubkeys table and change
|
|
||||||
# the settings version to 4.
|
|
||||||
shared.config.set('bitmessagesettings', 'socksproxytype', 'none')
|
|
||||||
shared.config.set('bitmessagesettings', 'sockshostname', 'localhost')
|
|
||||||
shared.config.set('bitmessagesettings', 'socksport', '9050')
|
|
||||||
shared.config.set('bitmessagesettings', 'socksauthentication', 'false')
|
|
||||||
shared.config.set('bitmessagesettings', 'socksusername', '')
|
|
||||||
shared.config.set('bitmessagesettings', 'sockspassword', '')
|
|
||||||
shared.config.set('bitmessagesettings', 'keysencrypted', 'false')
|
|
||||||
shared.config.set('bitmessagesettings', 'messagesencrypted', 'false')
|
|
||||||
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
|
|
||||||
shared.config.write(configfile)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user