root / trunk / sandbox / jhb / oc2 / demoissuer.py

Revision 342, 1.9 kB (checked in by ocjhb, 5 months ago)

trying to prevent some evil posts

  • Property svn:mime-type set to text/plain
  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1"""run this file to run an issuer. If required, it will setup a currency"""
2
3### minmal config ###
4
5#where can this server be reached?
6baseurl = 'http://10.42.43.1'
7#what port to run on?
8port = 9090
9
10### nothing to config below this ###
11
12import BaseHTTPServer
13import issuer, mint,authorizer,storage
14from testutils import Handler
15
16issuerstorage = storage.Storage().setFilename('data/issuerstorage.bin').restore()
17mintstorage = storage.Storage().setFilename('data/mintstorage.bin').restore()
18authorizerstorage = storage.Storage().setFilename('data/authorizerstorage.bin').restore()
19
20issuer = issuer.Issuer(issuerstorage)
21mint = mint.Mint(mintstorage)
22authorizer = authorizer.Authorizer(authorizerstorage)
23
24if not issuerstorage.has_key('masterPrivKey'):
25    print 'Issuer: setting up master keys'
26    issuer.createMasterKeys()
27
28    print 'issuer: setup currency discription'
29    denominations=[1,2,5,10,20,50,100,200,500,1000,2000,5000,10000,20000,50000,100000,200000,500000]
30    cdd = issuer.makeCDD('TestCent','tc',[str(d) for d in denominations],'%s:%s/' % (baseurl,port),'')
31    mint.setCDD(cdd)
32   
33    print 'mint: setting up mintkeys'
34    keys = mint.newMintKeys()
35   
36    print 'issuer: signing mintkeys'
37    mkcs = issuer.signMintKeys(keys=keys,cdd = cdd)
38
39
40    print 'authorizer: creating keys'
41    authpub = authorizer.createKeys()
42
43    print 'mint: add authorizer key'
44    mint.addAuthKey(authpub)
45    print 'authorizer: set mkcs'
46    authorizer.setMKCs(mkcs.values()) #FIXME - signMintKeys and fetchMintKeys return different
47
48    print 'saving everything'
49    issuerstorage.save()
50    mintstorage.save()
51    authorizerstorage.save()
52
53
54def address_string(self):
55    host, port = self.client_address[:2]
56    return host
57
58print 'Starting up server on port %s ' % port
59Handler.issuer = issuer
60Handler.mint = mint
61Handler.authorizer = authorizer
62httpd = BaseHTTPServer.HTTPServer(("", port), Handler)
63httpd.address_string = address_string
64httpd.serve_forever()
Note: See TracBrowser for help on using the browser.