Author

Topic: HELP ! im going crazy (Read 621 times)

newbie
Activity: 3
Merit: 0
December 04, 2015, 06:08:14 AM
#5
If i wanted to use the command line i wouldn't ask for php code. stop spamming
legendary
Activity: 1344
Merit: 1024
Mine at Jonny's Pool
December 03, 2015, 10:25:33 PM
#4
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"
newbie
Activity: 3
Merit: 0
December 03, 2015, 12:07:00 PM
#3
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.
hero member
Activity: 910
Merit: 1000
December 03, 2015, 11:59:55 AM
#2
(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?
newbie
Activity: 3
Merit: 0
December 03, 2015, 11:31:26 AM
#1
So im trying to import an private key to bitcoin using php... no luck in couple of hours

here is the script


/* 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://[email protected]: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:[email protected]: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-
Jump to: