【发布时间】:2019-12-18 13:55:19
【问题描述】:
我目前正在开发一个涉及运行完整比特币节点的比特币应用程序。
在测试我的源代码时,我决定使用比特币注册测试模式。
这就是我启动我的比特币节点的方式:
./bitcoind -regtest -rpcuser=a -rpcpassword=b -server -bind=0.0.0.0
这就是我与我的 regtest 节点交互的方式:
./bitcoin-cli -regtest -rpcuser=a -rpcpassword=b getnewaddress
输出:
2N152jpoD9u52cpswsN7ih8RZ3P4DszaUGg
此示例按预期工作...但是!
当我尝试不使用 bitcoin-cli 而是使用 curl 或 python 与比特币节点交互时,我会卡住:
curl --user a --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://192.168.178.200:18444/
我被要求输入密码 => 我输入 b
然后它说:
curl: (52) Empty reply from server
同样适用于:
curl --user a:b --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://192.168.178.200:18444/
和:
curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://a:b@192.168.178.200:18444/
我还寻找了一个 cookie 文件来使用 cookie 进行身份验证,但没有。
我已经研究过这个问题,例如
和其他各种网站,但没有一个帮助...
我正在运行 0.18.0 版
好吧,我详细描述了我的问题,并提到了我已经尝试了两天的事情..
有什么建议吗?
谢谢和问候!
【问题讨论】:
-
试试 -rpcallowip=127.0.0.1
标签: json authentication rpc bitcoin bitcoind