Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import sys
  2. import pycurl
  3. import struct
  4. from binascii import unhexlify, crc32
  5. import urllib2
  6.  
  7. # usage, python script.py transactionlist.txt > file
  8.  
  9. txlist = str(sys.argv[1])
  10.  
  11. def txdecode(transaction):
  12.  
  13. data = urllib2.urlopen("https://blockchain.info/tx/"+transaction+"?show_adv=true")
  14. dataout = b''
  15. atoutput = False
  16.  
  17. for line in data:
  18. if 'Output Scripts' in line:
  19. atoutput = True
  20.  
  21. if '</table>' in line:
  22. atoutput = False
  23.  
  24. if atoutput:
  25. if len(line) > 100:
  26. chunks = line.split(' ')
  27. for c in chunks:
  28. if 'O' not in c and '\n' not in c and '>' not in c and '<' not in c:
  29. dataout += unhexlify(c.encode('utf8'))
  30.  
  31.  
  32. length = struct.unpack('<L', dataout[0:4])[0]
  33. checksum = struct.unpack('<L', dataout[4:8])[0]
  34. dataout = dataout[8:8+length]
  35.  
  36. return dataout
  37.  
  38. f = open(txlist, 'r')
  39. alldata = b''
  40. for l in f.readlines():
  41. l = l.rstrip('\n')
  42. alldata += txdecode(str(l))
  43.  
  44. print alldata
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement