从另一台服务器访问比特币守护进程

时间:2014-01-02 21:46:55

标签: php bind bitcoin bitcoind

我已经构建了Catcoind(比特币/项目的一个分支),我可以从root用户访问终端中的命令:

cd catcoin/src 
./catcoind -daemon

这将启动Catcoind,打开端口,并允许我键入'./catcoind getdifficulty'之类的命令,但我想从另一台服务器上运行的PHP JSON-RPC客户端访问它们。我目前的代码是:

<?php

require_once 'jsonRPCClient.php'; 

$catcoin = new jsonRPCClient('http://RPCUSER:RPCPASS@IP:PORT'); 

print_r($catcoin->getinfo()); 
echo $catcoin->getdifficulty();

我在Ubuntu上构建Catcoind的配置文件是:

server=1

rpcuser=USER

rpcpassword=PASS

rpcssl=0

rpcallowip=*

bind=IP:PORT

externalip=IP

proxy=IP:PORT

port=PORT

rpcconnect=IP

当我运行代码时,它表示无法打开流/连接被拒绝。 Catcoind的配置位于〜/ .catcoin / catcoin.conf。有任何想法吗?我知道这很令人困惑,但我已经完成了一切,但允许外部IP访问API。谢谢! :d

2 个答案:

答案 0 :(得分:1)

您不需要将所有这些内容写入conf文件中,只需使用以下

即可
server=1
daemon=1
rpcuser=<user_namer>
rpcpassword=<password>
rpctimeout=30

如果从远程主机连接,请添加以下行

rpcallowip=<remote_ip_address>

保存并退出conf文件并重新启动守护程序,首先停止它catecoind stop然后catcoind start

答案 1 :(得分:0)

是否允许使用外部IP?如果不确保允许IP,以便它可以调用api。错误failed to open the stream / connection refused通常意味着ip和一切都是正确的但是服务器拒绝了连接。

相关问题