首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于osx的比特币核心与位库套接字错误

基于osx的比特币核心与位库套接字错误
EN

Stack Overflow用户
提问于 2020-10-18 04:50:02
回答 1查看 333关注 0票数 1

我的学习有一些问题。

当我像这样制作python文件时

代码语言:javascript
复制
from bitcoin.rpc import RawProxy

p = RawProxy()

info = p.getblockchaininfo()

print(info['blocks'])

但它给我显示了一些错误

代码语言:javascript
复制
>> python3 rpc_example.py
Traceback (most recent call last):
  File "rpc_example.py", line 5, in <module>
    info = p.getblockchaininfo()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bitcoin/rpc.py", line 315, in <lambda>
    f = lambda *args: self._call(name, *args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bitcoin/rpc.py", line 231, in _call
    self.__conn.request('POST', self.__url.path, postdata, headers)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
from bitcoin.rpc import RawProxy
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

ConnectionRefusedError...这是我的bitcoin.conf文件

代码语言:javascript
复制
alertnotify=myemailscript.sh "Alert: %s"
server=1
rpcuser=bitcoinrpc
rpcpassword=any_long_random_password
txindex=1
testnet=1
daemon=1

当我启动-testnet时,我可以执行一些API,如getblockchaininfo或getblockhash散列,例如

代码语言:javascript
复制
bitcoin-cli getblockchaininfo
{
  "chain": "test",
  "blocks": 1863439,
  "headers": 1863439,
  "bestblockhash": "00000000133f751916630063f86f5b27cd6b5871ce70a5fcba7112a111941706",
  "difficulty": 1,
  "mediantime": 1602990284,
  "verificationprogress": 0.999998381271931,
  "initialblockdownload": false,
  "chainwork": "0000000000000000000000000000000000000000000001d9736dcfa64f3ea8bf",
  "size_on_disk": 28355982038,
  "pruned": false,
  "softforks": {
    "bip34": {
      "type": "buried",
      "active": true,
      "height": 21111
    },
    "bip66": {
      "type": "buried",
      "active": true,
      "height": 330776
    },
    "bip65": {
      "type": "buried",
      "active": true,
      "height": 581885
    },
    "csv": {
      "type": "buried",
      "active": true,
      "height": 770112
    },
    "segwit": {
      "type": "buried",
      "active": true,
      "height": 834624
    }
  },
  "warnings": "Warning: unknown new rules activated (versionbit 28)"
}

但我不能用蟒蛇执行死刑..。请帮我一下

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-18 05:35:17

我解决了!!

当我在我的bitcoin.conf中添加一些注释时,我没有检查关于testnet的bitcoin.conf。

代码语言:javascript
复制
alertnotify=myemailscript.sh "Alert: %s"
server=1
rpcuser=bitcoinrpc
rpcpassword=any_long_random_password
txindex=1
testnet=1
daemon=1

[testnet]
rpcallowip=*
rpcport=18332

测试网下面需要两行。当你喜欢我的时候,加入这一行!谢谢

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64409841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档