测试网络curl rpc无结果
发布于 14 天前 作者 路人-戊 99 次浏览 来自 比特币

本地起了一个测试节点

bitcoind -testnet -daemon

配置文件如下

rpcuser=btc
rpcpassword=123456
rpcallowip=127.0.0.1
txindex=1
daemon=1
server=1

通过bitcoin-cli访问,返回结果均正常

block@block:~$ bitcoin-cli -testnet getblockchaininfo
{
  "chain": "test",
  "blocks": 1249170,
  "headers": 1249170,
  "bestblockhash": "000000000000937393d86b8e9977bd0c5fe8b5178c0416845fd2cb3564f67523",
  "difficulty": 65536,
......

通过rpc访问,无结果

block@block:~$ curl  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [""]}' -H 'content-type: text/plain;' http://127.0.0.1:18332/
没有任何响应
6 回复

账号密码都不带,能访问么,你也可以先浏览器里打开http://127.0.0.1:18332看看

@maiiz 应该不是这个问题 按上述方式,不带-u的信息没有任何返回,debug里面也没有任何打印信息 带上-u

curl -u "btc:123456" -d '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [""]}' -H 'content-type: text/plain;' http://127.0.0.1:18332/

每访问一次就会有一条debug日志

2017-11-28 08:17:02 ThreadRPCServer incorrect password attempt from 127.0.0.1:48216

开始也试过了,一直是这样,我是配置有问题吗?

这个日志提示就是密码不对哇

@maiiz 但是密码就是这个…

curl -u 111:222 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:18332/ {"result":{"deprecation-warning":"WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16","version":150001,"protocolversion":70015,"walletversion":139900,"balance":0.00000000,"blocks":8408,"timeoffset":0,"connections":8,"proxy":"","difficulty":4,"testnet":true,"keypoololdest":1511924622,"keypoolsize":2000,"paytxfee":0.00000000,"relayfee":0.00001000,"errors":""},"error":null,"id":"curltest"} 我本地测试,没什么毛病

@maiiz 我在regtest模式下搞的,OK了

回到顶部