我该如何在Mac上运行该比特币python模型(通过PlanB)?

时间:2019-04-24 18:43:01

标签: python excel bitcoin bitcoind

PlanB上传了他的model re: pricing Bitcoin to github的代码。我想尝试运行它。

我克隆了repo并设置了python,但是后来我被卡住了(我知道,不是很远)

但是当我运行python rpc\ \(copy\).py时,我收到:

Traceback (most recent call last):
  File "rpc (copy).py", line 6, in <module>
    bbh = rpc_connection.getblockhash(i)
  File "/Library/Python/2.7/site-packages/bitcoinrpc/authproxy.py", line 136, in __call__
    'Content-type': 'application/json'})
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1053, in request
    self._send_request(method, url, body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1093, in _send_request
    self.endheaders(body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 893, in _send_output
    self.send(msg)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 855, in send
    self.connect()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 832, in connect
    self.timeout, self.source_address)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.error: [Errno 61] Connection refused

我正试图一次迈出这一步。

我需要下载Bitcoin Core / bitcoind比特币守护进程吗?

我相信我需要让某种类型的服务器运行才能与此python脚本进行交互。

我找到了the bitcoin python RPC by Garzik,但看不到如何设置/使用它。

如果失败,下一步我需要做什么?

谢谢。

1 个答案:

答案 0 :(得分:0)

提到这是一个老问题,但值得解决。

PlanB的源代码使用RPC从“比特币已满”节点提取数据。您需要运行一个节点才能运行代码。

如果您查看rpc (copy).py文件:

rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%('username', 'password'), timeout = 500)

上面的代码在IP 127.0.0.1上使用'username'和'password'使用RPC端口8332。

安装节点后,可以在bitcoin.conf文件上更改所有这些变量。