- Timestamp:
- 04/22/09 18:46:54 (3 years ago)
- Location:
- trunk/sandbox/jhb/oc2
- Files:
-
- 3 modified
- 2 copied
-
documentation.py (modified) (3 diffs)
-
issuerservice.py (copied) (copied from trunk/sandbox/jhb/oc2/testserver.py)
-
mint.py (modified) (3 diffs)
-
protocols.py (modified) (3 diffs)
-
testclient.py (copied) (copied from trunk/sandbox/jhb/oc2/testserver.py)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sandbox/jhb/oc2/documentation.py
r270 r271 651 651 >>> bob = protocols.SpendListen(bobwallet) 652 652 >>> transport = transports.YieldTransport(bob.run,[]) 653 >>> alice = protocols.SpendRequest( transport, wallet, 'foobar', [coin])653 >>> alice = protocols.SpendRequest(bob.run, wallet, 'foobar', [coin]) 654 654 >>> alice.run() 655 655 Traceback (most recent call last): … … 657 657 SpendReject: unknown transactionId 658 658 659 >>> alice = protocols.SpendRequest( transport, wallet, alicetid, [])659 >>> alice = protocols.SpendRequest(bob.run, wallet, alicetid, []) 660 660 >>> alice.run() 661 661 Traceback (most recent call last): … … 663 663 SpendReject: amount of coins does not match announced one 664 664 665 >>> alice = protocols.SpendRequest( transport, wallet, alicetid, [coin])665 >>> alice = protocols.SpendRequest(bob.run, wallet, alicetid, [coin]) 666 666 >>> alice.run() 667 667 True -
trunk/sandbox/jhb/oc2/mint.py
r266 r271 1 1 from entity import * 2 import messages 2 3 3 4 class Mint(Entity): … … 53 54 return key.verifyContainerSignature(message) 54 55 55 def handle TransferRequest(self,authorizedMessage):56 def handleMintingRequest(self,authorizedMessage): 56 57 57 58 if not self.validateAuthorization(authorizedMessage): 58 return ('nonvalid','')59 else:60 message = authorizedMessage.message59 return messages.TransferReject() 60 61 message = authorizedMessage.message 61 62 blinds = message.blinds 62 63 result = [] … … 67 68 68 69 if self.delay: 69 70 70 self.addToTransactions(message.transactionId,result) 71 return('delayed','mint asked to delay') 71 answer = messages.TransferDelay() 72 answer.transactionId = message.transactionId 73 answer.reason = 'mint asked to delay' 72 74 else: 73 return ('minted',result) 75 answer = messages.TransferAccept() 76 answer.signatures = result 77 78 return answer 79 80 def handleExchangeRequest(self,message): 81 coins = message.coins 82 blinds = message.blinds 83 84 74 85 75 86 def addToTransactions(self,transactionId,result): -
trunk/sandbox/jhb/oc2/protocols.py
r270 r271 118 118 options = dict(message.options) 119 119 requesttype = options['type'] 120 120 121 if requesttype == 'mint': 121 122 authorizedMessage = self.authorizer.authorize(message) 122 123 if type(authorizedMessage) == messages.Error: 123 124 return messages.TransferReject() 124 125 response = self.mint.handleTransferRequest(authorizedMessage) 126 if type(response) == messages.Error: 127 return messages.TransferReject() 128 129 text,value = response 130 if text=='minted': 131 answer = messages.TransferAccept() 132 answer.signatures = value 133 elif text =='delayed': 134 answer = messages.TransferDelay() 135 answer.transactionId = message.transactionId 136 answer.reason = value 137 else: 138 raise 'something went wrong' 139 return answer 125 return self.mint.handleMintingRequest(authorizedMessage) 126 127 elif requesttype == 'exchange': 128 return self.mint.handleExchangeRequest(message) 129 130 140 131 141 132 class TransferResume(Protocol): … … 234 225 return True 235 226 227 236 228 class SpendListen(Protocol): 237 229 … … 247 239 answer = messages.SpendReject() 248 240 answer.reason = 'unknown transactionId' 249 yield answer 250 return 241 return answer 251 242 #check sum 252 243 if amount != int(orig.amount): 253 244 answer = messages.SpendReject() 254 245 answer.reason = 'amount of coins does not match announced one' 255 yield answer 256 return 257 yield 'trying to exchange' 258 #try to exchange. To yield or not to yield? 259 import pdb; pdb.set_trace() 260 #return answer 246 return answer 247 #do exchange 248 249 261 250 answer = messages.SpendAccept() 262 251 answer.transactionId = tid 263 yield answer 252 return answer 253 254 264 255 265 256 class CoinsSpendSender(Protocol):
