Author

Topic: JSON error, help please (Read 1370 times)

full member
Activity: 154
Merit: 100
April 25, 2011, 02:22:06 PM
#7
Wow, problem solved after only 4 hours.

Code:
$bitcoin->sendfrom('My Site','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',0.04);  //works with literals
$bitcoin->sendfrom(SITE_NAME,'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',0.04); //works with constant and 2 literals
$bitcoin->sendfrom(SITE_NAME,$ref_details['pay_out_address'],0.04); //works with constant, var and 1 literal
$bitcoin->sendfrom(SITE_NAME,$ref_details['pay_out_address'],$sendamt); //COMPLETELY FUBAR TOOK 4 HOURS OF MY LIFE AWAY SON OF A BITCH I HATE PROGRAMMING
$bitcoin->sendfrom(SITE_NAME,$ref_details['pay_out_address'],(float)$sendamt); //works with constant and 2 vars if 3rd is type cast

I really do love programming though, honestly.

Tags: PHP, JSON, RPC, Unable to connect, float, string, amount, type cast, error, fubar
full member
Activity: 154
Merit: 100
April 25, 2011, 01:40:59 PM
#6
Well, I just tested that... exactly the same server, same daemon, same wallet, different domain name and it was able to send 100% fine.

Code:
	define('INC','../inc/');
require_once(INC.'jsonRPCClient.php');
 
$bitcoin = new jsonRPCClient('http://xxxxxxxxxxxx:[email protected]:8332/');


$bitcoin->sendfrom('My Site','xxxxxxxxxxxxxxxxxxxxxxx',1);

 
echo "
\n";
print_r($bitcoin->getinfo());

$listaccounts=$bitcoin->listaccounts();
print_r($listaccounts);

(Username and password are exactly the same in both scripts).

I'll try putting this stupido script onto this other domain...
legendary
Activity: 1658
Merit: 1001
April 25, 2011, 01:31:20 PM
#5
My experience with the jsonRPCClient was that it was as buggy as hell. I would look into that (not your code).
full member
Activity: 154
Merit: 100
April 25, 2011, 01:28:21 PM
#4
Code:
Array
(
    [isvalid] => 1
    [address] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [ismine] =>
)

exception 'Exception' with message 'Unable to connect to http://xxxxxxxxxxxxx:[email protected]:8332/' in /web/sites/me/_shared/jsonRPCClient.php:140 Stack trace: #0 [internal function]: jsonRPCClient->__call('sendfrom', Array) #1 /web/sites/me/mydomain.com/public_html/_run_test9.php(109): jsonRPCClient->sendfrom('My Site', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', '0.46') #2 {main}

Server error! Please contact the admin.

NFI.

I might need to order a new monitor soon coz I'm about to punch this one after 3 hours.

full member
Activity: 154
Merit: 100
April 25, 2011, 12:54:21 PM
#3
The weird thing is I can easily do $bitcoin->validateaddress('biwoejfiwjefiwojeifow');  with no problem; it connects to the wallet and returns valid info.

Code:
Array
(
    [isvalid] => 1
    [address] => biwoejfiwjefiwojeifow
    [ismine] =>
)

However just a couple of lines after that when I try to do the send it says it can't connect.

Code:
try {
$pay_out_address_details=$bitcoin->validateaddress($new_user['pay_out_address']);
echo '
';
print_r($pay_out_address_details);
echo '
';
}
catch (Exception $e) {
echo $e.'
';
die("

Server error! Please contact the admin.

");
}
It gets past that bit, but immediately after it is this, which it breaks on:

Code:
if ($pay_out_address_details['isvalid']==1) {
//add_to_log('Valid address... sending '.$new_user['pay_out_amount'].' BTC...');
$sendamt=number_format($new_user['pay_out_amount'],2,'.','');
if ($sendamt<=1000) {

try {
$bitcoin->sendfrom(PROGRAM_NAME,$new_user['pay_out_address'],$sendamt);
}
catch (Exception $e) {
echo $e.'
';
die("

Server error! Please contact the admin.

");
}

//add_to_log('...sent successfully.');
}
}

Note the add_to_log statements have been commented out.
sr. member
Activity: 322
Merit: 250
Do The Evolution
April 25, 2011, 12:43:53 PM
#2
Can you please give the full raw error?
Also, a little bit more of your code would help to see how you connected.
full member
Activity: 154
Merit: 100
April 25, 2011, 12:31:55 PM
#1
Hi,

I've been trying to debug something for 2 hours now, so frustrating.

exception 'Exception' with message 'Unable to connect to http://myusername:[email protected]:8332/'

Any reason why it wouldn't be able to connect even though my username and password are correct?

It throws this error when I try to do
Code:
$bitcoin -> sendfrom(PROGRAM_NAME,$pay_out_address,0.01);

Also I've double-checked the logs and the 3 args I'm sending to this function are completely valid.

Thanks
Jump to: