From 6e236680cdcd4ed5394bc2a5a9f8341d85fda7cf 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()