A simple json-rpc case for bitcoin blockchains

#!/usr/bin/env python                                                           
                                                                                
import json                                                                     
import jsonrpc                                                                  
import requests                                                                 
                                                                                
#url = "http://user:password@ip:port/                                           
#you can find user and password in multichain.conf file in path ~/.multichain/chain2
url = "http://multichainrpc:H4MvpnyZix9ynkJ3T8om8PtKziF7CtVtAH7WkZ3eRK1u@localhost:4352/"
headers = {'content-type': 'application/json'}                                  
                                                                                
helpload = {                                                                    
    "jsonrpc":"1.0",                                                            
    "method": "getinfo",                                                        
}                                                                               
                                                                                
print "------ test begin --------"                                              
response = requests.post(url, data=json.dumps(helpload), headers=headers).json()
print response

  

posted @ 2016-03-04 14:42  betachen  阅读(314)  评论(0编辑  收藏  举报