Changeset 274
- Timestamp:
- 04/23/09 16:25:24 (3 years ago)
- Location:
- trunk/sandbox/jhb/oc2
- Files:
-
- 2 modified
-
messages.py (modified) (1 diff)
-
mint.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sandbox/jhb/oc2/messages.py
r272 r274 68 68 Field('transactionId'), 69 69 Field('reason'), 70 Field('blinds'), 71 Field('coins'), 70 72 ] 71 73 -
trunk/sandbox/jhb/oc2/mint.py
r272 r274 62 62 blinds = message.blinds 63 63 return self._mintBlinds(message) 64 65 66 def validateCoins(self,coins): 67 problems = [] 68 69 for coin in coins: 70 if self.inDSDB(coin): 71 problems.append('double spent') 72 continue 73 74 priv,pub,denomination,version = self.getMintKeyById(coin.keyId) 75 76 if not pub.verifyContainerSignature(coin): 77 problems.append('no valid signature') 78 continue 79 80 if not denomination == coin.denomination: 81 problems.append('wrong denomination') 82 continue 83 84 if [p for p in problems if p]: #there are problems 85 return problems 86 else: 87 return True 88 89 90 91 64 92 65 93 def handleExchangeRequest(self,message): 66 #import pdb; pdb.set_trace()67 94 coins = message.coins 68 95 blinds = message.blinds 96 97 #check coins 98 99 result = self.validateCoins(coins) 100 if result != True: 101 reject = messages.TransferReject() 102 reject.reason = 'coins' 103 reject.coins = result 104 return reject 105 69 106 payed = sum([int(coin.denomination) for coin in coins]) 70 71 107 amount = 0 72 108 for keyid,blind in blinds: … … 78 114 reject.reason = 'mismatch' 79 115 return reject 116 80 117 81 118 return self._mintBlinds(message) … … 103 140 def addToTransactions(self,transactionId,result): 104 141 self.storage.setdefault('transactions',{})[transactionId]=result 142 143 144 def addToDSDB(self,coin): 145 dsdb = self.storage.setdefault('dsdb',[]) 146 if coin.serial in dsdb: 147 return False 148 else: 149 dsdb.append(coin.serial) 150 return True 151 152 def inDSDB(self,coin): 153 return coin.serial in self.storage.setdefault('dsdb',[])
