Cre*_*ter 5 authentication rpc json bitcoin bitcoind
我目前正在开发一个比特币应用程序,其中涉及运行完整的比特币节点。
当我测试我的源代码时,我决定使用比特币注册测试模式。
这就是我启动比特币节点的方式:
./bitcoind -regtest -rpcuser=a -rpcpassword=b -server -bind=0.0.0.0
Run Code Online (Sandbox Code Playgroud)
这就是我与 regtest 节点交互的方式:
./bitcoin-cli -regtest -rpcuser=a -rpcpassword=b getnewaddress
Run Code Online (Sandbox Code Playgroud)
输出:
2N152jpoD9u52cpswsN7ih8RZ3P4DszaUGg
Run Code Online (Sandbox Code Playgroud)
这个例子按预期工作......但是!
一旦我尝试不使用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/
Run Code Online (Sandbox Code Playgroud)
我被要求输入密码 => 我输入b
然后它说:
curl: (52) Empty reply from server
Run Code Online (Sandbox Code Playgroud)
同样适用于:
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/
Run Code Online (Sandbox Code Playgroud)
和:
curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://a:b@192.168.178.200:18444/
Run Code Online (Sandbox Code Playgroud)
我还找了一个cookie文件来用cookie进行身份验证,但是没有。
我已经研究过这个问题,例如
和其他各种网站,但没有一个有帮助......
我正在运行版本0.18.0
好吧,我详细描述了我的问题,并提到了我两天已经尝试过的方法。
有什么建议么?
谢谢并问候!
如果版本 >= 0.16.0到18443 ,我们应该更新 regtest RPC 端口。所以,我只是将端口从18444更改为18443,它起作用了。
例子:
curl --user username:password --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockhash","params":[0]}' -H 'content-type:text/plain;' http://127.0.0.1:18443
参考:https: //github.com/ruimarinho/bitcoin-core/issues/60
| 归档时间: |
|
| 查看次数: |
1612 次 |
| 最近记录: |