add helper_addressGenerator module
This commit is contained in:
parent
a0e1c0041f
commit
16e9319d5f
37
src/helper_addressGenerator.py
Normal file
37
src/helper_addressGenerator.py
Normal file
|
@ -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()
|
Loading…
Reference in New Issue
Block a user