Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. #!/usr/bin/python
  2. from json import dumps, loads
  3. from requests import post
  4.  
  5. with open('/home/raven/.rpcurl','r') as secret_file:
  6.   rpc_url = secret_file.read().strip()
  7.  
  8. def rpc(method, *params):
  9.   return loads(post(rpc_url, data=dumps({"method":method, "params":params}), timeout=20).text)['result']
  10.  
  11. def hex(number, padding=1, reverse=False):
  12.   padded_hex = '%0*x' % (padding*2, number)
  13.   if reverse:
  14.     return ''.join(reversed([padded_hex[char:char+2] for char in range(0, len(padded_hex), 2)]))
  15.   else:
  16.     return padded_hex
  17.  
  18. def cb_data(height):
  19.   data = hex(3) + hex(height,3) + hex(0, 32)
  20.   size = hex(len(data)/2)
  21.   return size+data+hex(2**32-1)
  22.  
  23. gbt = rpc('getblocktemplate')
  24. pk_hash = '485f8d241cc00f86854885a9baa74e066141cf39'
  25. cb = hex(2,4,1)+hex(1)+hex(0,32)+hex(2**32-1)+cb_data(gbt['height'])+hex(1)+hex(gbt['coinbasevalue'],8,1)+'1976a914'+pk_hash+'88ac'+hex(0,4)
  26. print cb
  27. print rpc('decoderawtransaction',cb)
  28. #print '{"id":null,"method":"mining.notify","params":["01","'+gbt['previousblockhash']+'"]}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement