Bitcoin Forum
April 26, 2024, 03:44:38 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: 1
  Print  
Author Topic: [1 BTC BOUNTY] Did the JSON-RPC commands change?  (Read 2873 times)
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 18, 2012, 01:02:43 AM
Last edit: November 19, 2012, 06:55:18 AM by SgtSpike
 #1

Just curious - did the JSON commands change between version 0.3 and 0.7?  I tried using sendmany with the same code I used on 0.3, but it doesn't work in 0.7.  I haven't rolled back to 0.3 to try it again (is there a legitimate place to download 0.3 from still?), but I haven't changed any of the code since the last time I used it on 0.3 either.

" 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 C:\wamp\www\includes\jsonRPCClient.php on line 132"

Offering 1 BTC bounty to whomever solves my problem here.
1714103078
Hero Member
*
Offline Offline

Posts: 1714103078

View Profile Personal Message (Offline)

Ignore
1714103078
Reply with quote  #2

1714103078
Report to moderator
1714103078
Hero Member
*
Offline Offline

Posts: 1714103078

View Profile Personal Message (Offline)

Ignore
1714103078
Reply with quote  #2

1714103078
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
jgarzik
Legendary
*
Offline Offline

Activity: 1596
Merit: 1091


View Profile
November 18, 2012, 01:38:02 AM
 #2

Just curious - did the JSON commands change between version 0.3 and 0.7?  I tried using sendmany with the same code I used on 0.3, but it doesn't work in 0.7.  I haven't rolled back to 0.3 to try it again (is there a legitimate place to download 0.3 from still?), but I haven't changed any of the code since the last time I used it on 0.3 either.

" 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 C:\wamp\www\includes\jsonRPCClient.php on line 132"

'sendmany' should be unchanged, AFAIK.

Want to post a debug.log snippet?


Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 18, 2012, 02:06:50 AM
 #3

Just curious - did the JSON commands change between version 0.3 and 0.7?  I tried using sendmany with the same code I used on 0.3, but it doesn't work in 0.7.  I haven't rolled back to 0.3 to try it again (is there a legitimate place to download 0.3 from still?), but I haven't changed any of the code since the last time I used it on 0.3 either.

" 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 C:\wamp\www\includes\jsonRPCClient.php on line 132"

'sendmany' should be unchanged, AFAIK.

Want to post a debug.log snippet?


Sure, but I've had more activity after this attempt... what should I look for in the log to find the relevant section?  Or at the very least, what could I look for to find a receipt and send of coins?
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 06:54:36 AM
 #4

I found this much...

Code:
...
AddAddress(x.x.x.x:8333)
ThreadRPCServer method=getinfo
keypool reserve 3
keypool return 3
ThreadRPCServer method=sendmany
connection timeout
trying connection x.x.x.x:8333 lastseen=-1.0hrs lasttry=-375918.9hrs

Neither of the x.x.x.x was my local or external IP, and the code I am attempting to run is being executed on the local machine with the bitcoin client on it.

EDIT:  Now offering a 1 BTC bounty for whoever comes up with a solution to my problem.
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 07:27:10 AM
 #5

It seems your php can't connect to your bitcoind, make sure you have set the correct allowip in the bitcoin.conf. Also if your using a shared hosting server for the php, fopen could be blocked, at that time I can sell you a curl version of JSONclient that I wrote.
That's what I am gathering.  I can't figure out why though, because the getinfo command I send right before the sendmany command works just fine.  The HTTP server running the PHP code and the bitcoind server run on the same local machine.  Nothing is hosted outside of my house in this situation - it's all local.

I caught this exception as well:
Code:
Caught exception: Unable to connect to http://secret:mypassword@127.0.0.1:8332/

So why can it connect with the secret:password combo to utilize the getinfo() command but not use the same connection to do sendmany?

EDIT:  Here's the relevant code for the connection and getinfo (which, again, is working fine).

Code:
	$bitcoin = new jsonRPCClient('http://secret:mypassword@127.0.0.1:8332/');

echo "<pre>\n";
print_r($bitcoin->getinfo());
echo "</pre>";
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 07:37:44 AM
 #6

It seems your php can't connect to your bitcoind, make sure you have set the correct allowip in the bitcoin.conf. Also if your using a shared hosting server for the php, fopen could be blocked, at that time I can sell you a curl version of JSONclient that I wrote.
That's what I am gathering.  I can't figure out why though, because the getinfo command I send right before the sendmany command works just fine.  The HTTP server running the PHP code and the bitcoind server run on the same local machine.  Nothing is hosted outside of my house in this situation - it's all local.

I caught this exception as well:
Code:
Caught exception: Unable to connect to http://secret:mypassword@127.0.0.1:8332/

So why can it connect with the secret:password combo to utilize the getinfo() command but not use the same connection to do sendmany?

EDIT:  Here's the relevant code for the connection and getinfo (which, again, is working fine).

Code:
	$bitcoin = new jsonRPCClient('http://secret:mypassword@127.0.0.1:8332/');

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

I got it you updated to 0.7.1 you probably encrypted your wallet, so you have to unlock it then use the sendmany command then lock it again.
Nope, I'm actually back on 0.3 because I thought it might fix the problem.  Brand new wallet, brand new blockchain downloaded (because 0.7 updated both of those to a later format not compatible with 0.3), and it's still giving me the same trouble.
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 07:50:47 AM
 #7

it sounds like an fopen issue, try this version it is the cURL version I wrote, it works the same exact way as jsonRPCClient just uses curl instead of fopen

http://pastebin.com/UfrgfpAi
Hmmm... I don't really know json, or jsonRPC at all.  I use a bitcoin.php and jsonRPCClient.php file to run my code though.  Json greatly confuses me for some reason.

Can you give an example of how to use your code if I have an array of addresses and amounts?

Here's the array:

Code:
Array ( [18TKNbSLTrd3a2W8mtoH5uNzFhWRWNcuHU] => 0.00000800 [1JTZHBdrDnFaVvuV43sd2oiwDmzUPfa3Ws] => 0.00000100 ) 1

Not sure what the 1 at the end is... didn't notice that before.  Could that potentially be causing problems?  I just did a print_r of the array to get that output.
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 07:58:57 AM
 #8

All you have to do is replace the file named "jsonRPCClient.php" with mine and use it the same way you been using it.

Are you passing an account?

Code:
$client->sendmany("", array("18TKNbSLTrd3a2W8mtoH5uNzFhWRWNcuHU" => 0.00000800,"1JTZHBdrDnFaVvuV43sd2oiwDmzUPfa3Ws" => 0.00000100));
Ok, I'll give that a try.

Account is blank.  "", as you have written.
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 08:00:43 AM
 #9

Code:
 Fatal error: Call to undefined function curl_init() in C:\wamp\www\includes\jsonRPCClient.php on line 126
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 08:10:01 AM
 #10

Code:
 Fatal error: Call to undefined function curl_init() in C:\wamp\www\includes\jsonRPCClient.php on line 126

that means curl isn't in your php build, switch back to the fopen version
Roger that.  :\
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 08:15:32 AM
 #11

Ok, so I figured I'd post the entire code from the php page I am using (sanitized).  Basically, it finds bitcoin sends in the forum of [btcaddress, amount] out of the text pasted in the text area and creates a sendmany array with all of them found.

Following the first code block is the getinfo() output.

Code:
<?
require_once 'includes/jsonRPCClient.php';
$bitcoin = new jsonRPCClient('http://sanitized:sanitized@127.0.0.1:8332/');

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

if ($_SERVER['REQUEST_METHOD']=="POST") {
if ($_POST['password']=="sanitized") {

$fromAccount = "";

$input = $_POST['data'];
$input = explode("[",$input);

$input[0]="";
$sendto="";
for ($i=1; $i<sizeof($input); $i++) {
$temp = explode("]",$input[$i]);
$input[$i] = $temp[0];
$input[$i] = explode(",",$input[$i]);
$sendto[trim($input[$i][0])] = trim($input[$i][1]);
}



try {
echo 'Trying: Sendmany<br/>';
$returned = $bitcoin->sendmany($fromAccount, $sendto);
} catch (Exception $e) {
echo 'Caught exception: ',  $e->getMessage(), "<br/>";
echo print_r($sendto);
}

}
else {
echo "Incorrect password.";
}
}
else {

?>
<form action="" method="post">
    <textarea cols="70" rows="30" name="data" id="data"></textarea></br>
        <input type="password" name="password" id="password" />
        <input type="submit" value="Process Addresses" />
    </form>
<?
}
?>

Output of getinfo():
Code:
Array
(
    [version] => 32300
    [balance] => 1
    [blocks] => 208578
    [connections] => 8
    [proxy] =>
    [generate] =>
    [genproclimit] => -1
    [difficulty] => 3368767.1405329
    [hashespersec] => 0
    [testnet] =>
    [keypoololdest] => 1353202101
    [paytxfee] => 0
    [errors] => URGENT: upgrade required, see http://bitcoin.org/dos for details
)
SgtSpike (OP)
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
November 19, 2012, 08:32:11 AM
 #12

The only thing I can think of is to wrap the amount in the method floatval();
GENIUS!  Ok, not really, but you did think of something to try that I did not!  Wink

Where do I send the 1 BTC?
EDIT:  I'll send to your donation address since it's convenient.
ingrownpocket
Legendary
*
Offline Offline

Activity: 952
Merit: 1000


View Profile
November 19, 2012, 09:01:11 AM
 #13

Damn... Too late...

I had the same problem.
Pages: 1
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!