MTGOX Redeem Code Bot


SUBMITTED BY: Guest

DATE: Feb. 20, 2013, 2:54 a.m.

FORMAT: Python

SIZE: 1.5 kB

HITS: 2070

  1. from urllib import urlencode
  2. import urllib2
  3. import time
  4. from hashlib import sha512
  5. from hmac import HMAC
  6. import base64
  7. import json
  8. def get_nonce():
  9. return int(time.time()*100000)
  10. def sign_data(secret, data):
  11. return base64.b64encode(str(HMAC(secret, data, sha512).digest()))
  12. class requester:
  13. def __init__(self, auth_key, auth_secret):
  14. self.auth_key = auth_key
  15. self.auth_secret = base64.b64decode(auth_secret)
  16. def build_query(self, req={}):
  17. req["nonce"] = get_nonce()
  18. post_data = urlencode(req)
  19. headers = {}
  20. headers["User-Agent"] = "GoxApi"
  21. headers["Rest-Key"] = self.auth_key
  22. headers["Rest-Sign"] = sign_data(self.auth_secret, post_data)
  23. return (post_data, headers)
  24. def perform(self, path, args):
  25. data, headers = self.build_query(args)
  26. req = urllib2.Request("https://mtgox.com/api/0/"+path, data, headers)
  27. res = urllib2.urlopen(req, data)
  28. return json.load(res)
  29. req = requester(auth_key='YOUR_KEY',auth_secret='YOUR_SECRET')
  30. fname = 'rcodes.txt'
  31. with open(fname) as f:
  32. Codes = f.readlines()
  33. for line in Codes:
  34. redeemCode = line.replace('\n','')
  35. print "Trying to redeem: %s" % redeemCode
  36. print req.perform(path='redeemCode.php',args={'code':redeemCode})

comments powered by Disqus