Author

Topic: Bitcoind sendmany: json parsing error? (Read 4306 times)

full member
Activity: 220
Merit: 100
December 18, 2012, 04:50:21 PM
#11
I wonder if there is maybe some setting in bitcoin.conf, or even the rpcClient.php that would enable better error reporting? Seems very weird to me that it just says connection refused when something goes wrong..

I mean how much better do you want it to be? The connection was refused plain and simple and straightforward, check your firewall, your ports, your username, your password, make sure your rpcallowip is right, check everything.

I have double checked all those and none of that is the issue. I can do the following no problem:

Code:
$bitcoin->listtransactions();
$bitcoin->getbalance();
$bitcoin->move();
$bitcoin->listaccounts();
$bitcoin->getnewaddress();
$bitcoin->validateaddress();
$bitcoin->listreceivedbyaddress();
$bitcoin->listreceivedbyaccount();

All of those commands work fine for me, no errors or anything. There is no passphrase or anything currently on my wallet, and I can use both the sendtoaddress and sendmany command via command line, but using them via the jsonRPCClient, all I get is the connection refused. And its all on the localhost, no external server involved.
full member
Activity: 220
Merit: 100
December 18, 2012, 04:32:25 PM
#10
I wonder if there is maybe some setting in bitcoin.conf, or even the rpcClient.php that would enable better error reporting? Seems very weird to me that it just says connection refused when something goes wrong..
kjj
legendary
Activity: 1302
Merit: 1026
December 18, 2012, 02:03:03 AM
#9
Heres what im getting:

Code:
exception 'Exception' with message 'Unable to connect to http://mybituser:[email protected]:8332/' in jsonRPCClient.php:140
Stack trace:
#0 [internal function]: Slick_jsonRPCClient->__call('sendmany', Array)
#1 Model.php(427): Slick_jsonRPCClient->sendmany('Main Account', Array)
#2 Controller.php(20): Slick_BTC_Visit_Model->sendPayouts()
#3 index.php(46): Slick_BTC_Visit_Controller->visitSite()
#4 {main}

it seems like any time any command to the bitcoin client fails it just gives me the 'unable to connect to..' error rather then giving me any actual error info.. seems kind of odd

Hmm.  That doesn't seem right.  I'm almost positive that I've seen useful error messages from RPC calls from PHP before.  I'll fire up your code on my box tomorrow if I get time, just to see.
full member
Activity: 220
Merit: 100
December 17, 2012, 10:34:36 PM
#8
Heres what im getting:

Code:
exception 'Exception' with message 'Unable to connect to http://mybituser:[email protected]:8332/' in jsonRPCClient.php:140
Stack trace:
#0 [internal function]: Slick_jsonRPCClient->__call('sendmany', Array)
#1 Model.php(427): Slick_jsonRPCClient->sendmany('Main Account', Array)
#2 Controller.php(20): Slick_BTC_Visit_Model->sendPayouts()
#3 index.php(46): Slick_BTC_Visit_Controller->visitSite()
#4 {main}

it seems like any time any command to the bitcoin client fails it just gives me the 'unable to connect to..' error rather then giving me any actual error info.. seems kind of odd
kjj
legendary
Activity: 1302
Merit: 1026
December 17, 2012, 11:35:30 AM
#7
Put print_r($senders); before the try block so that you can see exactly what is getting passed to bitcoin.

Code:
Array
(
    [1GawMPab9B7Bbt5FXPVDbHt6T2NrfH2EgC] => 0.0016
    [1MvX1RB5ERDx1xMaWQeH4zWZgCBB5i8BxD] => 0.00072
)

should be the correct format right?

That looks right to me.  In your exception block, instead of just returning false, echo $e; first to see if you can get any useful information that way.
full member
Activity: 220
Merit: 100
December 17, 2012, 10:28:31 AM
#6
Put print_r($senders); before the try block so that you can see exactly what is getting passed to bitcoin.

Code:
Array
(
    [1GawMPab9B7Bbt5FXPVDbHt6T2NrfH2EgC] => 0.0016
    [1MvX1RB5ERDx1xMaWQeH4zWZgCBB5i8BxD] => 0.00072
)

should be the correct format right?
kjj
legendary
Activity: 1302
Merit: 1026
December 17, 2012, 07:14:11 AM
#5
Put print_r($senders); before the try block so that you can see exactly what is getting passed to bitcoin.
full member
Activity: 220
Merit: 100
December 17, 2012, 12:08:42 AM
#4
if it helps, here is what is showing up in debug.log after I try the sendmany command via PHP


Code:
ThreadRPCServer method=sendmany
CTxMemPool::accept() : accepted 1c5ee41fa5 (poolsz 604)
Added 1 addresses from 141.238.223.79: 27 tried, 10658 new
Added 1 addresses from 91.225.164.20: 27 tried, 10658 new
CTxMemPool::accept() : accepted c2b6d38360 (poolsz 605)
received getdata for: tx afab87781697bdca4e4d
CTxMemPool::accept() : accepted 1b83ea1411 (poolsz 606)
received getdata for: tx 1b83ea1411605920b8de
received getdata for: tx 1b83ea1411605920b8de
received getdata for: tx 1b83ea1411605920b8de
received getdata for: tx 1b83ea1411605920b8de
received getdata for: tx 1b83ea1411605920b8de
received getdata for: tx 1b83ea1411605920b8de
CTxMemPool::accept() : accepted e5738700ee (poolsz 607)
received getdata (10 invsz)
received getdata for: tx a4c3433c44aced87923d
CTxMemPool::accept() : accepted 3bb646a5a9 (poolsz 608)
full member
Activity: 220
Merit: 100
December 17, 2012, 12:04:20 AM
#3
cool, that worked for the command line issue! however I tried taking the json_decode() out of the PHP, still fails everytime I try the command. commands like getinfo, listaccounts, getbalance etc. work fine though
kjj
legendary
Activity: 1302
Merit: 1026
December 16, 2012, 11:51:07 PM
#2
Unix shell quoting can be confusing if you aren't used to it.  Try:

Code:
bitcoind sendmany "Main Account" '{"1GawMPab9B7Bbt5FXPVDbHt6T2NrfH2EgC":0.0001}'

As for the PHP one, just hand the $senders array to $bitcoin->sendmany() directly, no need to pre-encode it.
full member
Activity: 220
Merit: 100
December 16, 2012, 10:42:08 PM
#1
Hey guys, so im trying to use the sendmany command via the jsonRPCClient.php script, however it keeps failing. Iv tried running the same command through the command line, but I keep getting a JSON parsing error:

Code:
# bitcoind sendmany "Main Account" {"1GawMPab9B7Bbt5FXPVDbHt6T2NrfH2EgC":0.0001}
error: Error parsing JSON:{1GawMPab9B7Bbt5FXPVDbHt6T2NrfH2EgC:0.0001}

iv tried wrapping the command in tripple quotes as well (read it on some other posts with similar problems), but it seems to change nothing.

As for the PHP end, here is the code I have:

Code:
$senders = array();
foreach($getPayouts as $payout){

if(!isset($senders[$payout['address']])){
$senders[$payout['address']] = floatval($payout['amount']);
}
else{
$senders[$payout['address']] += floatval($payout['amount']);
}

}


try{
$payoutMoney = $bitcoin->sendmany("Main Account", json_encode($senders));
}
catch(Exception $e){
return false;
}

this section of code also fails, and gives me a bunch of failed http request errors.

Anyone have any ideas? Im pretty sure im formatting the queries correctly.. but I feel like theres something simple im missing here
Jump to: