Title: HELP ! im going crazy Post by: imgoingcrazy on December 03, 2015, 04:31:26 PM So im trying to import an private key to bitcoin using php... no luck in couple of hours
here is the script <?php /* Configuration variables for the JSON-RPC server */ $rpc_host = '127.0.0.1'; $rpc_port = '8332'; $rpc_user = 'root'; $rpc_pass = 'root123'; set_time_limit(3600); require_once('jsonRPCClient.php'); $bc = new jsonRPCClient('http://' . $rpc_user . ':' . $rpc_pass . '@' . $rpc_host . ':' . $rpc_port); $bc->importprivkey("privatekey","root"); print_r($bc->getaddressesbyaccount($rpc_user)); $balance = $bc->getbalance()."\n"; echo $balance; ?> here is the output Warning: fopen(http://...@127.0.0.1:8332): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in C:\xampp\htdocs\jsonRPCClient.php on line 132 Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://root:root123@127.0.0.1:8332' in C:\xampp\htdocs\jsonRPCClient.php:140 Stack trace: #0 C:\xampp\htdocs\test.php(13): jsonRPCClient->__call('importprivkey', Array) #1 C:\xampp\htdocs\test.php(13): jsonRPCClient- Title: Re: HELP ! im going crazy Post by: coinpr0n on December 03, 2015, 04:59:55 PM (I haven't used the PHP client but) I suppose you're using the correct rpcuser and rpcpassword as set in your bitcoin.conf file. Can you execute other RPC commands? Is privatekey a valid private key? Maybe importprivkey takes an array?
Title: Re: HELP ! im going crazy Post by: imgoingcrazy on December 03, 2015, 05:07:00 PM Yes other commands such getbalance , getinfo works. the private key is dumped with pywallet from wallet.dat also tried one private key dumped from blockchain .. same error.
Title: Re: HELP ! im going crazy Post by: jonnybravo0311 on December 04, 2015, 03:25:33 AM Why are you trying to import a private key using php? Just use the command line. What possible use case is there for having a web page that can collect a private key and import it into your wallet (other than the obvious nefarious ones)?
Code: bitcoin-cli importprivkey "yourkey" Title: Re: HELP ! im going crazy Post by: imgoingcrazy on December 04, 2015, 11:08:14 AM If i wanted to use the command line i wouldn't ask for php code. stop spamming
|