美文网首页
交子RPC服务

交子RPC服务

作者: taobao | 来源:发表于2018-04-14 17:18 被阅读0次

    钱包配置文件添加配置:重启
    listen=1
    server=1
    daemon=1
    rpcuser=lxh
    rpcpassword=123456
    rpcport=30000
    rpcallowip=127.0.0.1

    测试请求代码
    curl = curl_init(); //设置抓取的url curl_setopt(curl, CURLOPT_URL, 'http://127.0.0.1:30000/');
    //设置头文件的信息作为数据流输出
    curl_setopt(curl, CURLOPT_HEADER, 1); //认证 curl_setopt(curl, CURLOPT_USERPWD, "lxh:123456");
    //设置获取的信息以文件流的形式返回,而不是直接输出。
    curl_setopt(curl, CURLOPT_RETURNTRANSFER, 1); //设置post方式提交 curl_setopt(curl, CURLOPT_POST, 1);
    //设置post数据
    post_data = array( "id" => 1, "method" => 'getmininginfo', "params" => array(), ); curl_setopt(curl, CURLOPT_POSTFIELDS, json_encode(post_data)); //执行命令data = curl_exec(curl); //关闭URL请求 curl_close(curl);
    //显示获得的数据
    print_r($data);

    返回:
    {"result":{"blocks":226550,"currentblocksize":0,"currentblocktx":0,"difficulty":3.39278799,"errors":"","genproclimit":-1,"networkhashps":246009815,"pooledtx":1,"testnet":false,"chain":"main","generate":false,"hashespersec":0},"error":null,"id":1}

    相关文章

      网友评论

          本文标题:交子RPC服务

          本文链接:https://www.haomeiwen.com/subject/lbblkftx.html