Bitcoin-Cli
為什麼 bitcoin-cli 不知道 bitcoind 的工作目錄?
我有
/ect/systemd/system/bitcoin.service
以下內容,我想知道,為什麼bitcoin-cli getinfo
告訴我其他地方的配置文件:error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (/home/pi/.bitcoin/bitcoin.conf)
的內容
bitcoin.service
,尤其是-conf=/home/bitcoin/.bitcoin/bitcoin.conf
:[Unit] Description=Bitcoin daemon After=network.target [Service] ExecStart=/usr/local/bin/bitcoind -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid # Creates /run/bitcoind owned by bitcoin RuntimeDirectory=bitcoind User=bitcoin Type=forking PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid Restart=on-failure # Hardening measures #################### # Provide a private /tmp and /var/tmp. PrivateTmp=true # Mount /usr, /boot/ and /etc read-only for the process. ProtectSystem=full # Disallow the process and all of its children to gain # new privileges through execve(). NoNewPrivileges=true # Use a new /dev namespace only populated with API pseudo devices # such as /dev/null, /dev/zero and /dev/random. PrivateDevices=true # Deny the creation of writable and executable memory mappings. MemoryDenyWriteExecute=true [Install] WantedBy=multi-user.target
bitcoin-cli
必須以與 相同的方式user
執行bitcoind
。否則它將檢查錯誤目錄中的配置文件,因為預設目錄是
home
執行該程序的使用者的目錄。
bitcoin-cli使用bitcoin-rpc,所以對於使用bitcoin-cli,你必須執行bitcoind的配置,如果沒問題,你可以使用bitcoin-cli獲取命令
一個簡單的文件配置可能是它
## ## bitcoin.conf configuration file. Lines beginning with # are comments. ## # On client-side, you add the normal user/password pair to send commands: rpcuser=alice rpcpassword=bob
或者你可以執行
bitcoind with this command bitcoind -rpcuser=alice -rpcpassword=bob