Author

Topic: PHP jsonRPPClient sendmany --- trouble it is not working. bitcoind [Solved] (Read 2078 times)

full member
Activity: 235
Merit: 100
Solved

Thanks
Yes, do NOT json_encode and just build the key=> value array, it is working.

Thanks a lot
sr. member
Activity: 426
Merit: 250
You are specifying your value as a string.

This. And don't json-encode your array.
sr. member
Activity: 412
Merit: 287
Code:
$amount = floatval("0.00100000");
$array = json_encode(array(
   "12w5Ffu8cc8kRwULGBsxAzeo5UCU9QCcqE" => "$amount",
   "1KpZPdyeXVX8JMGdENhJxqF9g3NG5XxhG3"=> "$amount")
);

As gmaxwell pointed out, your casting the amount as a string (second line is the problem). I tend to leave casting the value as a float until the bitcoin library, as otherwise you'll be repeating yourself a lot. This should work:
Code:
$array = json_encode(array(
   "12w5Ffu8cc8kRwULGBsxAzeo5UCU9QCcqE" => (float)$amount,
   "1KpZPdyeXVX8JMGdENhJxqF9g3NG5XxhG3"=> (float)$amount)
);
staff
Activity: 4284
Merit: 8808
You are specifying your value as a string.
full member
Activity: 235
Merit: 100
what RPC-library are you using?

The One from http://jsonrpcphp.org/   (full version)

bitcoind and source running on linux

This is the code:
$bitcoin = new jsonRPCClient('http://bitcoinrpc:7sXyVsD7YWPKEp91jH9T73YucZutALnLp4AjwmS5n3xz@localhost:8332/');
      
$amount = floatval("0.00100000");


 Log::info("*******Paymentbook Bitcoind ***************");
$array = json_encode(array("12w5Ffu8cc8kRwULGBsxAzeo5UCU9QCcqE" => "$amount", "1KpZPdyeXVX8JMGdENhJxqF9g3NG5XxhG3"=> "$amount"));

$bitcoin->sendmany("rpcuser" , $array, 1);

And I am getting this in the Logs: (when using an Array)

[2013-10-14 15:12:14] log.INFO: *******Paymentbook Bitcoind *************** [] []
[2013-10-14 15:12:14] log.ERROR: exception 'ErrorException' with message 'fopen(http://...@localhost:8332/): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
' in /var/www/sites/laevolucionsocialvip/app/libraries/jsonRPCClient.php:138
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'fopen(http://.....', '/var/www/sites/...', 138, Array)
#1 /var/www/sites/laevolucionsocialvip/app/libraries/jsonRPCClient.php(138): fopen('http://bitcoinr...', 'r', false, Resource id #126)
#2 /var/www/sites/laevolucionsocialvip/app/routes.php(583): jsonRPCClient->__call('sendmany', Array)
#3 /var/www/sites/laevolucionsocialvip/app/routes.php(583): jsonRPCClient->sendmany('rpcuser', '{"12w5Ffu8cc8kR...', 1)
#4 [internal function]: {closure}()
#5 /var/www/sites/laevolucionsocialvip/vendor/laravel/framework/src/Illuminate/Routing/Route.php(80): call_user_func_array(Object(Closure), Array)
#6 /var/www/sites/laevolucionsocialvip/vendor/laravel/framework/src/Illuminate/Routing/Route.php(47): Illuminate\Routing\Route->callCallable()
#7 /var/www/sites/laevolucionsocialvip/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1016): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#8 /var/www/sites/laevolucionsocialvip/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(530): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#9 /var/www/sites/laevolucionsocialvip/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(506): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#10 /var/www/sites/laevolucionsocialvip/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []


sr. member
Activity: 426
Merit: 250
what RPC-library are you using?
full member
Activity: 235
Merit: 100
example: print_r($bitcoin->getaddressesbyaccount ('rpcuser')); echo "\n";     Works great

for sendmany I have tried many ways:

1.
$array = array("12w5Ffu8cc8kRwULGBsxAzeo5UCU9QCcqE" => "1000000", "1KpZPdyeXVX8JMGdENhJxqF9g3NG5XxhG3" => "100000");
2.
$array = json_encode($array);
3.
$array["12w5Ffu8cc8kRwULGBsxAzeo5UCU9QCcqE"] = "100000";
$array["1KpZPdyeXVX8JMGdENhJxqF9g3NG5XxhG3"] = "200000";

4. and others... into this function
example:    $bitcoin->sendmany("rpcuser",$array); and also tried with ,0 confirmations and 1,

I am continue looking but 4 hours is a long time for this sendmany() function

I will move on....

thanks
Jump to: