Bitcoind
json_rpc_call 失敗
軟體上線有點問題:https ://bitcointalk.org/index.php?topic=55038.0
我的區塊鏈已完全載入,並且 JSON-RPC 也可以工作,因為我在 PHP 腳本中使用它,其程式碼為:
<a href="?api=getblockcount">getblockcount</a> | <a href="?api=getdifficulty">getdifficulty</a> | <?php require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://user:xxxxx@127.0.0.1:8332/'); switch ($_GET['api']) { case 'getblockcount': echo "<pre>\n"; $homepage = file_get_contents('https://blockchain.info/q/getblockcount'); echo 'Blockchain: ' .$homepage; print_r('<br />Mybitcoin: '.$bitcoin->getblockcount()); echo "</pre>"; break; case 'getdifficulty': echo "<pre>\n"; print_r($bitcoin->getdifficulty()); echo "</pre>"; break; default: echo "<pre>\n"; print_r($bitcoin->getinfo()); echo "</pre>"; break; } ?>
結果:
所以,我已經安裝了 cpuminer,當我嘗試執行這個(基本)命令時:
./minerd --url=http://127.0.0.1:8332 --userpass=user:xxxxx
我收到此錯誤:
[2017-02-27 15:54:30] Binding thread 0 to cpu 0 [2017-02-27 15:54:30] 4 miner threads started, using 'scrypt' algorithm. [2017-02-27 15:54:30] Binding thread 3 to cpu 3 [2017-02-27 15:54:30] Binding thread 2 to cpu 2 [2017-02-27 15:54:30] Binding thread 1 to cpu 1 [2017-02-27 15:54:30] No payout address provided, switching to getwork [2017-02-27 15:54:30] HTTP request failed: The requested URL returned error: 404 Not Found [2017-02-27 15:54:30] json_rpc_call failed, retry after 30 seconds
我也試過這個:
./minerd --url=stratum+tcp://127.0.0.1:8332 --userpass=user:xxxxx
我收到此錯誤:
[2017-02-27 16:05:18] Starting Stratum on stratum+tcp://127.0.0.1:8332 [2017-02-27 16:05:18] 4 miner threads started, using 'scrypt' algorithm. [2017-02-27 16:05:18] Binding thread 2 to cpu 2 [2017-02-27 16:05:18] Binding thread 3 to cpu 3 [2017-02-27 16:05:18] Binding thread 1 to cpu 1 [2017-02-27 16:05:18] Binding thread 0 to cpu 0 [2017-02-27 16:05:18] JSON decode failed(1): '[' or '{' expected near 'HTTP' [2017-02-27 16:05:18] stratum_subscribe send failed [2017-02-27 16:05:18] ...retry after 30 seconds
然而,我的 JSON-RPC 埠已正確打開並執行!
我不明白。
編輯: 輸出
--protocol-dump
{ "txid": "d164587bb86b8bc512875234d9e9287a5c2b55132b1ac5cd17199e59fb3a7e15", "depends": [], "data": "0100000005763ec95f443d56ad1d6d6dc548ceef54b3337aa17f3ade0919ffe17e20ee049b000000006b483045022100c4dc98e9b602562fa1804866e2941059506d0d774aabd1c598d9316015fc091b02202d1866f029d5f4ca583e39e40ac37b6f3cda053d7f72021d3d208c7e2436bf61012102a6b445dad7a9786aedcbef422c43403a0ef456e07c93b20f73e8d3a645ce2df6ffffffff9db45cd39689cf3f0c963998d2c47ef46d8b02135cfeed6eba3d0925274e3c7f000000006a473044022056c3c0953f585a1d00e4898fba74be331c98df8fe4fd06b7d27b1671e1c08cf802207c173699816b91d0349412a835f3c0b6b1dc67cd233e405cd59bb0ca4fa1e738012102043891b2c24b09518aee54721276376e1a804972e6eab942bef6eb21ce47a3d3ffffffff20c626710f914e611a5153fc022ceb38a96039a7d480643cd707792043537bd4000000006b483045022100b161d4f4851f2cb6f3b3a2f28ade52eca51ae9927246ec0ee99f88986b2a3f4102203bdffc99bce188c50861e3d6719ce17118a06ac5653a506fd1cf8791cca964ef012103c4059c0171448f778dd80ab5ae94f73f7c939c2563a774eb922790b9414c872effffffff90e4efff277de68fe237bd97a63dbc3ffdb2b8bc7eeccbb05299ce8ebc27d1a7010000006a47304402200de759505eb62f672619b4747b68d4ac29d752a2f877ae1bff8f3f53cc9830a202203eeb5ff9b60590db2c5b68e75752a9a4cbf095cce2ea05acbd6c7b5174ff41480121020d36c0a1534fb2a98f8850d2df417ad2e797d32e300291a4889d6312f17710e3ffffffffe7ab3f1e1e2335fd99b85d4c76e23a67b08b217a3028e07fefaace55772d9693000000006a47304402200db21539819e7f78144a114d52f0ad7a6c2d83989f9d21f87e484cacf8aa9501022023e250bc6abf248fd954eb99438569c17f1c7b9140a3f9ed5acf1aec794b13b7012103f193e01a1a8489f88f0a3ea96e19c8e22d613beb654fca59fd4f5d4abbbec4feffffffff027fea0300000000001976a9144003f281c42fb1cc2d21a2be92212cf97b52b72188acb9b91000000000001976a9142a1665bf1affbac0503d4bf7481c505d96bb07ca88ac00000000", "hash": "d164587bb86b8bc512875234d9e9287a5c2b55132b1ac5cd17199e59fb3a7e15", "fee": 147240, "weight": 3260, "sigops": 2 }, { "txid": "0049b022864e0f27ca17177b768dfd990d2aed315b82cbf5c7e6574243223593", "depends": [], "data": "0100000001b68373162494d0409621feeb056e9d5133ae26245e1a44f839fd3c98bbe2e86a010000006b483045022100c0bd2aca622330e46b1fd58148420b1297754524ff820ac8845bf4dc17a842b40220372666ba44e9289f1fb1ac965486889d6ac365a46c61e0e85e81d6dff97aa38d012102409fafcff27fb07a8b1ce51898f081d4e84ce947a09bb4e5046cd4601ee239adffffffff010fe80200000000001976a9145d5925ac98510c6d331f1c4653332b391d79a00888ac00000000", "hash": "0049b022864e0f27ca17177b768dfd990d2aed315b82cbf5c7e6574243223593", "fee": 34683, "weight": 768, "sigops": 1 } ], "target": "0000000000000000027e93000000000000000000000000000000000000000000", "noncerange": "00000000ffffffff", "sigoplimit": 20000, "sizelimit": 4000000, "bits": "18027e93", "height": 454996 }, "id": 0 } [2017-02-27 16:25:17] No payout address provided, switching to getwork [2017-02-27 16:25:17] JSON protocol request: {"method": "getwork", "params": [], "id":0} * Rebuilt URL to: http://127.0.0.1:8332/ * Found bundle for host 127.0.0.1: 0x7f58a0013d60 [can pipeline] * Re-using existing connection! (#0) with host 127.0.0.1 * Connected to 127.0.0.1 (127.0.0.1) port 8332 (#0) * Server auth using Basic with user 'user' > POST / HTTP/1.1 Host: 127.0.0.1:8332 Authorization: Basic Y29pbmNvaW46YXplcnR5 Accept-Encoding: deflate, gzip Content-Type: application/json Content-Length: 45 User-Agent: cpuminer/2.4.5 X-Mining-Extensions: midstate * The requested URL returned error: 404 Not Found * Closing connection 0 [2017-02-27 16:25:17] HTTP request failed: The requested URL returned error: 404 Not Found [2017-02-27 16:25:17] json_rpc_call failed, retry after 30 seconds
的輸出
--no-getwork
root@localhost:~/cpuminer-2.4.5# ./minerd --url=http://127.0.0.1:8332 --userpass=user:***** --no-getwork [2017-02-27 16:51:50] Binding thread 0 to cpu 0 [2017-02-27 16:51:50] Binding thread 1 to cpu 1 [2017-02-27 16:51:50] Binding thread 2 to cpu 2 [2017-02-27 16:51:50] 4 miner threads started, using 'scrypt' algorithm. [2017-02-27 16:51:50] Binding thread 3 to cpu 3 [2017-02-27 16:51:50] No payout address provided [2017-02-27 16:51:50] json_rpc_call failed, retry after 30 seconds [2017-02-27 16:52:21] No payout address provided
RPC 命令不存在時返回 HTTP 404 錯誤。您嘗試使用的 RPC 命令是
getwork
,並且getwork
已在 Bitcoin Core 0.10.0 中刪除。如果你想使用getwork
,你需要降級到 0.10.0 之前的 Bitcoin Core 版本,但我建議你不要這樣做。相反,您應該getblocktemplate
通過使用該--no-getwork
選項來使用您所做的事情。當你這樣做時,你還必須指定,--coinbase-addr=ADDR
因為比特幣核心不會建立一個供礦工使用的 coinbase 交易。相反,礦工需要進行自己的 coinbase 交易,並且需要設置該選項。
如果你改變了你的
/etc/systemd/system/bitcoind.service
確保你執行sudo systemctl stop bitcoind sudo systemctl daemon-reload sudo systemctl start bitcoind
應用更改。