def newCC(request): if request.user.is_authenticated: if request.method == 'POST': data = dict(request.POST) print data cc = CryptoCurrency(currencyName=data['currencyName'][0], pszTimestamp=data['pszTimestamp'][0], maxMoney=data['maxMoney'][0], halvingInterval=data['halvingInterval'][0], nDefaultPort=data['nDefaultPort'][0], nTime=data['nTime'][0], nBits=data['nBits'][0], nSubsidy=data['nSubsidy'][0], coinBase=data['coinBase'][0], pubKey=data['pubKey'][0], githubUser=data['githubUser'][0], githubPass=data['githubPass'][0], currencyUnit=data['currencyUnit'][0], description=constants.PROCESSING_GENESIS_BLOCK, status=constants.COIN_STATUS_PROCESSING, owner=request.user, downloadPassword=makePassword()) cc.hashGenesisParams = make_hash( [cc.nBits, cc.pszTimestamp, cc.pubKey, cc.nTime, cc.coinBase]) errors = [] try: g = Github(data['githubUser'][0], data['githubPass'][0]).get_user() g.get_emails()[0] except: error = "github cannot login!" errors.append(error) pass if CryptoCurrency.objects.filter( hashGenesisParams=cc.hashGenesisParams).count(): error = "genesis will not be unique!" errors.append(error) #if get_bcaddress_version(cc.pubKey) is None : #error = "invalid pubKey!" #errors.append(error) if len(errors): return render(request, "../templates/admin/newCC.html", {"errors": errors}) cc.save() Platform(name="windows", aliasName="core", haveBuild=True, cryptoCurrency=cc).save() Platform(name="linux", aliasName="core", haveBuild=True, cryptoCurrency=cc).save() Platform(name="bitcore", aliasName="core+", haveBuild=True, cryptoCurrency=cc).save() Platform(name="android", aliasName="android", haveBuild=True, cryptoCurrency=cc).save() Platform(name="seeder", cryptoCurrency=cc).save() #Platform(name="ios", cryptoCurrency=cc).save() for key, value in data.items(): if key.startswith("domain"): subDomain = data["subDomain" + key[6:]][0] print subDomain DnsSeed(domain=value[0], subDomain=subDomain, cryptoCurrency=cc).save() elif key.startswith("address"): FullNode(address=value[0], cryptoCurrency=cc).save() f = open("./ansibleserver/jsonfiles/%s.json" % cc.id, "w") f.write( '{"id": %s, "nbits":"%s", "psztimestamp":"%s", "pubkey":"%s", "ntime":"%s", "coinbase":"%s" }' % (cc.id, cc.nBits[2:], cc.pszTimestamp, cc.pubKey, format(int(cc.nTime), 'x'), int(cc.coinBase) * (100000000))) f.close() t = threading.Thread(target=ansibleGenesisRunner, args=[cc.id]) t.daemon = True t.start() return HttpResponseRedirect('/dashboard/list') else: return render(request, "../templates/admin/newCC.html") else: return HttpResponseRedirect('/')