比特币regtest网络下用curl显示Connection refused
发布于 1 个月前 作者 nut 414 次浏览 来自 比特币

用命令bitcoind -regtest -daemon启动节点 直接 bitcoin-cli -regtest getnetworkinfo 结果:

{
  "version": 170000,
  "subversion": "/Satoshi:0.17.0/",
  "protocolversion": 70015,
  "localservices": "000000000000040d",
  "localrelay": true,
  "timeoffset": 0,
  "networkactive": true,
  "connections": 0,
  "networks": [
    {
      "name": "ipv4",
      "limited": false,
      "reachable": true,
      "proxy": "",
      "proxy_randomize_credentials": false
    }
	.......

用curl查询 curl --data-binary ‘{“jsonrpc”:“1.0”,“id”:“curltext”,“method”:“getinfo”,“params”:[]}’ -H ‘content-type:text/plain;’ http://bitcoinrpc:bitcoinrpc@localhost:18332 结果:

curl: (7) Failed to connect to localhost port 18332: Connection refused

而且同样的命令,在testnet网络中是正常的 bitcoin.conf配置如下

# Generated by https://jlopp.github.io/bitcoin-core-config-generator/

# This config should be placed in following path:
# ~/.bitcoin/bitcoin.conf

# [rpc]
# Accept command line and JSON-RPC commands.
server=1

# Username for JSON-RPC connections
rpcuser=bitcoinrpc

# Password for JSON-RPC connections
rpcpassword=bitcoinrpc

# Listen for JSON-RPC connections on this port
rpcport=18332



# Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4),
# a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option
# can be specified multiple times.
rpcallowip=192.168.1.168
rpcallowip=192.168.1.161
#Run this node on its own independent test network.
regtest=1
# Run this node on the Bitcoin Test Network.
#testnet=1

求大神们指导

回到顶部