From 16e9319d5fb39ba66188281a7dba8028d3a7f4f6 Mon Sep 17 00:00:00 2001 From: navjot Date: Fri, 8 Jan 2021 17:40:38 +0530 Subject: [PATCH] add helper_addressGenerator module --- src/helper_addressGenerator.py | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/helper_addressGenerator.py diff --git a/src/helper_addressGenerator.py b/src/helper_addressGenerator.py new file mode 100644 index 00000000..e38c83d6 --- /dev/null +++ b/src/helper_addressGenerator.py @@ -0,0 +1,37 @@ +""" +Create random address +""" + +import time + +import defaults +import queues +import state + +from bitmessageqt import account +from bitmessageqt.foldertree import AccountMixin +from bmconfigparser import BMConfigParser + + +def checkHasNormalAddress(): + """method for checking address""" + for address in account.getSortedAccounts(): + acct = account.accountClass(address) + if acct.type == AccountMixin.NORMAL and BMConfigParser().safeGetBoolean(address, 'enabled'): + return address + return False + + +def createAddressIfNeeded(label_text, streamNumberForAddress=1): + """method for creating random address""" + if not checkHasNormalAddress(): + queues.addressGeneratorQueue.put(( + 'createRandomAddress', 4, streamNumberForAddress, + label_text, + 1, "", False, + defaults.networkDefaultProofOfWorkNonceTrialsPerByte, + defaults.networkDefaultPayloadLengthExtraBytes + )) + while state.shutdown == 0 and not checkHasNormalAddress(): + time.sleep(.2) + return checkHasNormalAddress()