Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from json import dumps, loads
- from requests import post
- with open('/home/raven/.rpcurl','r') as secret_file:
- rpc_url = secret_file.read().strip()
- def rpc(method, *params):
- return loads(post(rpc_url, data=dumps({"method":method, "params":params}), timeout=20).text)['result']
- def hex(number, padding=1, reverse=False):
- padded_hex = '%0*x' % (padding*2, number)
- if reverse:
- return ''.join(reversed([padded_hex[char:char+2] for char in range(0, len(padded_hex), 2)]))
- else:
- return padded_hex
- def cb_data(height):
- data = hex(3) + hex(height,3) + hex(0, 32)
- size = hex(len(data)/2)
- return size+data+hex(2**32-1)
- gbt = rpc('getblocktemplate')
- pk_hash = '485f8d241cc00f86854885a9baa74e066141cf39'
- 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)
- print cb
- print rpc('decoderawtransaction',cb)
- #print '{"id":null,"method":"mining.notify","params":["01","'+gbt['previousblockhash']+'"]}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement