This repository has been archived on 2024-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-10/src/fake_addressGenerator.py

77 lines
2.8 KiB
Python
Raw Normal View History

2021-04-08 14:09:05 +02:00
"""
A thread for creating addresses
"""
import queues
import state
from bmconfigparser import BMConfigParser
from network.threads import StoppableThread
2021-07-09 18:50:31 +02:00
fake_addresses = {
'BM-2cUgQGcTLWAkC6dNsv2Bc8XB3Y1GEesVLV': {
'privsigningkey': '5KWXwYq1oJMzghUSJaJoWPn8VdeBbhDN8zFot1cBd6ezKKReqBd',
'privencryptionkey': '5JaeFJs8iPcQT3N8676r3gHKvJ5mTWXy1VLhGCEDqRs4vpvpxV8'
},
'BM-2cUd2dm8MVMokruMTcGhhteTpyRZCAMhnA': {
'privsigningkey': '5JnJ79nkcwjo4Aj7iG8sFMkzYoQqWfpUjTcitTuFJZ1YKHZz98J',
'privencryptionkey': '5JXgNzTRouFLqSRFJvuHMDHCYPBvTeMPBiHt4Jeb6smNjhUNTYq'
},
'BM-2cWyvL54WytfALrJHZqbsDHca5QkrtByAW': {
'privsigningkey': '5KVE4gLmcfYVicLdgyD4GmnbBTFSnY7Yj2UCuytQqgBBsfwDhpi',
'privencryptionkey': '5JTw48CGm5CP8fyJUJQMq8HQANQMHDHp2ETUe1dgm6EFpT1egD7'
},
'BM-2cTE65PK9Y4AQEkCZbazV86pcQACocnRXd': {
'privsigningkey': '5KCuyReHx9MB4m5hhEyCWcLEXqc8rxhD1T2VWk8CicPFc8B6LaZ',
'privencryptionkey': '5KBRpwXdX3n2tP7f583SbFgfzgs6Jemx7qfYqhdH7B1Vhe2jqY6'
},
'BM-2cX5z1EgmJ87f2oKAwXdv4VQtEVwr2V3BG': {
'privsigningkey': '5K5UK7qED7F1uWCVsehudQrszLyMZxFVnP6vN2VDQAjtn5qnyRK',
'privencryptionkey': '5J5coocoJBX6hy5DFTWKtyEgPmADpSwfQTazMpU7QPeART6oMAu'
}
}
2021-04-08 14:09:05 +02:00
2021-05-19 10:27:10 +02:00
2021-04-08 14:09:05 +02:00
class FakeAddressGenerator(StoppableThread):
"""A thread for creating fake addresses"""
name = "addressGenerator"
address_list = list(fake_addresses.keys())
2021-04-08 14:09:05 +02:00
def stopThread(self):
try:
queues.addressGeneratorQueue.put(("stopThread", "data"))
except:
pass
2021-05-19 10:27:10 +02:00
super(FakeAddressGenerator, self).stopThread()
2021-04-08 14:09:05 +02:00
def run(self):
"""
Process the requests for addresses generation
from `.queues.addressGeneratorQueue`
"""
while state.shutdown == 0:
queueValue = queues.addressGeneratorQueue.get()
streamNumber = 1
try:
address = self.address_list.pop(0)
2021-04-08 14:09:05 +02:00
label = queueValue[3]
2021-07-09 18:50:31 +02:00
2021-04-08 14:09:05 +02:00
BMConfigParser().add_section(address)
BMConfigParser().set(address, 'label', label)
BMConfigParser().set(address, 'enabled', 'true')
BMConfigParser().set(
2021-07-09 18:50:31 +02:00
address, 'privsigningkey', fake_addresses[address]['privsigningkey'])
BMConfigParser().set(
address, 'privencryptionkey', fake_addresses[address]['privencryptionkey'])
2021-04-08 14:09:05 +02:00
BMConfigParser().save()
queues.UISignalQueue.put((
'updateStatusBar', ""
))
queues.UISignalQueue.put(('writeNewAddressToTable', (
label, address, streamNumber)))
queues.addressGeneratorQueue.task_done()
except IndexError:
self.logger.error(
'Program error: you can only create 5 fake addresses')