Title: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 17, 2012, 03:42:08 AM 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} 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(); 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 Title: Re: Bitcoind sendmany: json parsing error? Post by: kjj on December 17, 2012, 04:51:07 AM 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. Title: Re: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 17, 2012, 05:04:20 AM 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
Title: Re: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 17, 2012, 05:08:42 AM if it helps, here is what is showing up in debug.log after I try the sendmany command via PHP
Code: ThreadRPCServer method=sendmany Title: Re: Bitcoind sendmany: json parsing error? Post by: kjj on December 17, 2012, 12:14:11 PM Put print_r($senders); before the try block so that you can see exactly what is getting passed to bitcoin.
Title: Re: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 17, 2012, 03:28:31 PM Put print_r($senders); before the try block so that you can see exactly what is getting passed to bitcoin. Code: Array should be the correct format right? Title: Re: Bitcoind sendmany: json parsing error? Post by: kjj on December 17, 2012, 04:35:30 PM Put print_r($senders); before the try block so that you can see exactly what is getting passed to bitcoin. Code: Array 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. Title: Re: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 18, 2012, 03:34:36 AM Heres what im getting:
Code: exception 'Exception' with message 'Unable to connect to http://mybituser:mybitpass@127.0.0.1:8332/' in jsonRPCClient.php:140 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 Title: Re: Bitcoind sendmany: json parsing error? Post by: kjj on December 18, 2012, 07:03:03 AM Heres what im getting: Code: exception 'Exception' with message 'Unable to connect to http://mybituser:mybitpass@127.0.0.1:8332/' in jsonRPCClient.php:140 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. Title: Re: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 18, 2012, 09:32:25 PM 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..
Title: Re: Bitcoind sendmany: json parsing error? Post by: SlickTheNick on December 18, 2012, 09:50:21 PM 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(); 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. |