giantdragon (OP)
Legendary
Offline
Activity: 1582
Merit: 1002
|
|
July 18, 2011, 09:58:35 PM Last edit: July 18, 2011, 10:32:10 PM by giantdragon |
|
I want to send multiple payments at once, so I use "sendmany", but seems I wrongly pass arrays. Tried for($i = 0; $i < sizeof($list); $i++) { ... $params[$address] = $amount; } $bitcoin->sendmany($params);
and $bitcoin->sendmany(array('address1' => 0.001, 'address2' => 0.002));
both doesn't work. What I am doing incorrectly?
|
|
|
|
drawoc
Full Member
Offline
Activity: 168
Merit: 100
Firstbits: 175wn
|
|
July 18, 2011, 10:07:54 PM |
|
The first parameter is the account name - "" by default. So, instead of: $bitcoin->sendmany($params);
try: $bitcoin->sendmany("", $params);
|
Donate: 175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA
|
|
|
giantdragon (OP)
Legendary
Offline
Activity: 1582
Merit: 1002
|
|
July 18, 2011, 10:21:36 PM |
|
$bitcoin->sendmany("", array('address1' => 0.001, 'address2' => 0.002)); Now works. But dynamically created array doesn't works... tried $params[$address] = $amount; and $params["$address"] = $amount; ... $bitcoin->sendmany("", $params);
|
|
|
|
giantdragon (OP)
Legendary
Offline
Activity: 1582
Merit: 1002
|
|
July 18, 2011, 10:31:56 PM |
|
Solved. It seems type conversion bug in PHP, just need to explicitly convert amount to float type. $params[$address] = doubleval($amount);
|
|
|
|
drawoc
Full Member
Offline
Activity: 168
Merit: 100
Firstbits: 175wn
|
|
July 18, 2011, 10:32:51 PM |
|
Glad it's working.
|
Donate: 175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 21, 2012, 12:09:01 AM |
|
this isn't working for me... i've tried every different combination of single quote / double quote but the following just kills the json-rpc connection:
What do you see if you do this: $params = array();
var_dump($params);
$params['1addr1'] = 1.2; $params['1addr2'] = 1.3;
var_dump($params);
var_dump($bitcoin->sendmany('account', $params)); The var_dump should show you what's going wrong. Maybe it's "PHP Fatal error: Uncaught exception 'Exception' with message 'Request error: {"code":-6,"message":"Account has insufficient funds"}'" or "PHP Fatal error: Uncaught exception 'Exception' with message 'Request error: {"code":-13,"message":"Error: Please enter the wallet passphrase with walletpassphrase first."}'" or some such other error. It should give you an idea of what's going wrong though.
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
payb.tc
|
|
July 21, 2012, 12:59:48 AM |
|
no, it dies before the 3rd vardump can output anything: array(0) { }
array(2) { ["175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA"]=> float(0.02) ["13QTW27b3SgqrEjefB9PbiZ6hcrVCJAxfx"]=> float(0.03) }
just before that, the json connection is alive and well; i do a getinfo and it works, and sendtoaddress still works. i am trying this first on an older box, but this [version] => 40101 should be able to handle it, shouldn't it? also, i don't actually know a 'from' account because i'm using a wallet that's only ever been used in the GUI, so no account names. so I'm leaving that blank: var_dump($bitcoin->sendmany('', $params));
|
|
|
|
payb.tc
|
|
July 21, 2012, 01:09:37 AM |
|
i found out how to output what's actually being sent through json: Array ( [http] => Array ( [method] => POST [header] => Content-type: application/json [content] => {"method":"sendmany","params":["",{"175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA":0.02,"13QTW27b3SgqrEjefB9PbiZ6hcrVCJAxfx":0.03}],"id":1} )
)
can't see anything wrong there though.
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 21, 2012, 02:06:05 AM |
|
Do you get any kind of an error message when it quits? Is there a logfile with errors in maybe?
Where did you get your copy of jsonRPCClient.php from?
What's 40101 the version number of?
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
payb.tc
|
|
July 21, 2012, 02:18:23 AM |
|
Do you get any kind of an error message when it quits? Is there a logfile with errors in maybe?
Where did you get your copy of jsonRPCClient.php from?
What's 40101 the version number of?
1. the php log file is just the usual... Warning: fopen(http://...@127.0.0.1:8332/) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in... etc, etc. same as what's printed on the browser with full error reporting. this was in the tail of bitcoin's debug.log: ThreadRPCServer method=getinfo keypool reserve 1353 keypool return 1353 ThreadRPCServer method=sendmany askfor tx 2e60cb02f1d7961d518e 0 sending getdata: tx 2e60cb02f1d7961d518e askfor tx 2e60cb02f1d7961d518e 1342836949000000 askfor tx 2e60cb02f1d7961d518e 1342837069000000 ERROR: ConnectInputs() : 2e60cb02f1 mapTransactions prev not found 9612453f24 ERROR: AcceptToMemoryPool() : ConnectInputs failed 2e60cb02f1 storing orphan tx 2e60cb02f1 askfor tx cc505b8b6973449c51af 0 sending getdata: tx cc505b8b6973449c51af askfor tx cc505b8b6973449c51af 1342836951000000 AcceptToMemoryPool(): accepted cc505b8b69 askfor tx 0d43330369bb8cf84053 0 sending getdata: tx 0d43330369bb8cf84053 received getdata for: tx cc505b8b6973449c51af askfor tx 0d43330369bb8cf84053 1342836952000000 askfor tx 3e68f2e0f7bcdede4c9b 0 sending getdata: tx 3e68f2e0f7bcdede4c9b askfor tx 3e68f2e0f7bcdede4c9b 1342836953000000
are those ERROR's related to the sendmany? 2. i don't remember where my copy came from, but it's worked for every other function i've thrown at it. 3. 40101 is the bitcoin client, as returned by getinfo()
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 21, 2012, 03:13:08 AM |
|
I just built a version 4 bitcoind. I didn't let it touch my wallet, so I don't know if it would work fully, but it gets as far as complaining that the account I'm sending from has insufficient funds. Can you try code like this and tell me what it shows? $params = array();
$params['1addr1'] = 1.2; $params['1addr2'] = 1.3;
try { $bitcoin->sendmany('', $params); } catch (Exception $e) { print "caught exception: "; var_dump($e); }
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
payb.tc
|
|
July 21, 2012, 03:22:31 AM |
|
Array ( [http] => Array ( [method] => POST [header] => Content-type: application/json [content] => {"method":"sendmany","params":["",{"175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA":1.2,"13QTW27b3SgqrEjefB9PbiZ6hcrVCJAxfx":1.3}],"id":1} )
) </pre><br /> <b>Warning</b>: fopen(http://...@127.0.0.1:8332/) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
in <b>[full path redacted]\jsonRPCClient.php</b> on line <b>137</b><br /> caught exception: object(Exception)#2 (7) { ["message":protected]=> string(68) "Unable to connect to http://myusername:mypassword@127.0.0.1:8332/" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(83) "[full path redacted]\jsonRPCClient.php" ["line":protected]=> int(145) ["trace":"Exception":private]=> array(2) { [0]=> array(6) { ["file"]=> string(76) "[full path redacted]\index2.php" ["line"]=> int(16) ["function"]=> string(6) "__call" ["class"]=> string(13) "jsonRPCClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(8) "sendmany" [1]=> array(2) { [0]=> string(0) "" [1]=> array(2) { ["175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA"]=> float(1.2) ["13QTW27b3SgqrEjefB9PbiZ6hcrVCJAxfx"]=> float(1.3) } } } } [1]=> array(6) { ["file"]=> string(76) "[full path redacted]\index2.php" ["line"]=> int(16) ["function"]=> string(8) "sendmany" ["class"]=> string(13) "jsonRPCClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(0) "" [1]=> array(2) { ["175WNXmJ1WVhFgVGKUqEhYtAQGRYAvqPA"]=> float(1.2) ["13QTW27b3SgqrEjefB9PbiZ6hcrVCJAxfx"]=> float(1.3) } } } } ["previous":"Exception":private]=> NULL } line 137 of the rpc client is this: if ($fp = fopen($this->url, 'r', false, $context)) {
|
|
|
|
payb.tc
|
|
July 21, 2012, 03:25:55 AM |
|
oh one other thing (maybe this is where some people will say 'well, duh'), this isn't actually bitcoind. this is bitcoin.exe with server=1 in the config.
this seems to work fine for sendtoaddress... when i call sendtoaddress via json it works and i suddenly see the transaction come up in the GUI.
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 21, 2012, 05:10:04 AM |
|
It shouldn't matter whether you use bitcoin -server or bitcoind - they should react the same way to RPC calls. I'm unable to reproduce having bitcoin fail like it is for you - but also I've not been able to find version 40101. I only see the following tags in the repository: $ git tag -l | grep v0.4 v0.4.0 v0.4.00rc1 v0.4.00rc2 and when I build v0.4.0: $ ./bitcoind getinfo { "version" : 40000, [...] the version string is 40000. I'm using Linux not Windows. I'd suggest updating to a recent version of bitcoin and see if that fixes the problem for you. I'm also wondering what happens if you try running bitcoind from the command line rather than using the PHP interface: $ ./bitcoind sendmany '' '{"1tipznMYcN4SFijpcVXomcynKWAGnNBQ3":1}' error: {"code":-6,"message":"Account has insufficient funds"}
You may find you need to omit the single quotes around the {...} in Windows - I'm not sure - try it with and without.
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
payb.tc
|
|
July 21, 2012, 05:25:52 AM |
|
thanks for the help... i'm off this for now, but will reply again if i find out anything else (when i try a different version, etc).
|
|
|
|
danystatic
|
|
October 14, 2013, 04:46:54 PM |
|
Solved. It seems type conversion bug in PHP, just need to explicitly convert amount to float type. $params[$address] = doubleval($amount); Worked for me, using floatval()
|
|
|
|
|