Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: nounderscores on February 22, 2011, 04:51:53 AM



Title: getblock method depreciated in 0.3.19?
Post by: nounderscores on February 22, 2011, 04:51:53 AM
Hi All,

I've been trying to use the getblockbycount api call to analyse the block chain

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

but I'm getting


$ bitcoind getblockbycount 109620
error: {"code":-32601,"message":"Method not found"}


any ideas why?

Cheers
nos


Title: Re: getblock method depreciated in 0.3.19?
Post by: theymos on February 22, 2011, 05:33:38 AM
getblockbycount has never existed in the official code. The wiki page is in error.


Title: Re: getblock method depreciated in 0.3.19?
Post by: nounderscores on February 22, 2011, 07:38:24 AM
Ah thanks. getblock in 0.3.19 is also coming up with an error.

the -printblock flag seems to work, but I don't have my gui turned on on my server so I can't see the output.


$ bitcoind getblock
error: {"code":-32601,"message":"Method not found"}


$ bitcoin -printblock
Error: Unable to initialize GTK+, is DISPLAY set properly?


$ bitcoin getblock
error: {"code":-32601,"message":"Method not found"}


is there another way to do it?


Title: Re: getblock method depreciated in 0.3.19?
Post by: theymos on February 22, 2011, 08:00:21 AM
bitcoind -printblock prints to debug.log.

The getblockbycount patch is here:
http://yyz.us/bitcoin/patch.bitcoin-getblock


Title: Re: getblock method depreciated in 0.3.19?
Post by: nounderscores on February 22, 2011, 09:56:21 AM
Thanks!


Title: Re: getblock method depreciated in 0.3.19?
Post by: nounderscores on February 22, 2011, 10:28:10 AM
Hi Themyos,

I just cloned a fresh copy of the bitcoin development tree from github, and then tried to patch in the rpc.cpp getblock patch

I got two successful hunk applications and one fail

--- rpc.cpp
+++ rpc.cpp
@@ -1926,6 +2040,8 @@
         if (strMethod == "sendfrom"               && n > 2) ConvertTo<double>(params[2]);
         if (strMethod == "sendfrom"               && n > 3) ConvertTo<boost::int64_t>(params[3]);
         if (strMethod == "listtransactions"       && n > 1) ConvertTo<boost::int64_t>(params[1]);
+       if (strMethod == "getblock"               && n > 0) ConvertTo<boost::int64_t>(params[0]);
+       if (strMethod == "getblockbycount"        && n > 0) ConvertTo<boost::int64_t>(params[0]);

         // Execute
         Object reply = CallRPC(strMethod, params);

I tried patching 0.3.19 and got three fails.

Should I try patching 0.3.20? I'm downloading it now.

Cheers,
Jin


Title: Re: getblock method depreciated in 0.3.19?
Post by: theymos on February 22, 2011, 01:13:41 PM
Just find the location in the code and patch it manually. The ordering of lines in that section doesn't matter. Getblock (and other RPC patches) doesn't usually apply correctly, but it works on pretty much any version.