Some initial coding work for chans
This commit is contained in:
parent
8bd00dc730
commit
0b08fe6bad
|
@ -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)
|
||||||
|
|
Reference in New Issue
Block a user