Bitcoin Forum
August 03, 2024, 05:19:33 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: In bitcoind satoshi client, how to show block number of your generated blocks  (Read 620 times)
r.freeman (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
January 15, 2014, 02:28:07 PM
 #1

Please remind me, when you generate blocks, how to show also the block number of them?
listtransactions seems to not show height.

Even gettransaction doesn't.

Well listtransactions and then getblock shows height, but that's 2 step...

You could calculate it from confirmations field, but that's not nice hack.

Any simple solution to list all transactions (or, all generated) including their height? Or do we need to patch source for this?
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1036



View Profile WWW
January 16, 2014, 09:36:06 PM
 #2

gettransaction 0a529c16fb5503e5256bfa1ac74298834c996ff2585360d6b3d299d24e1af18c

{
"amount" : 50.00100000,
"confirmations" : 61773,
"generated" : true,
"blockhash" : "0000000004db9a0a3ea27828ff9b917afa621be19edc54c93152f5eac0dfc6f8",
"blockindex" : 0,
"blocktime" : 1366491299,
"txid" : "0a529c16fb5503e5256bfa1ac74298834c996ff2585360d6b3d299d24e1af18c",
"time" : 1366491299,
"timereceived" : 1366491306,
"details" : [
{
"account" : "",
"address" : "mpjrcSevXAkUqC6n6CA24a4wkutJAiMRrj",
"category" : "generate",
"amount" : 50.00100000
}
]
}

getblock 0000000004db9a0a3ea27828ff9b917afa621be19edc54c93152f5eac0dfc6f8

{
"hash" : "0000000004db9a0a3ea27828ff9b917afa621be19edc54c93152f5eac0dfc6f8",
"confirmations" : 66773,
"size" : 981,
"height" : 67662,
"version" : 2,
"merkleroot" : "04e2e686553d6c10256b90775e14dfd7930f2ad0d1cfc263f3041d0bccb99012",
"tx" : [
"0a529c16fb5503e5256bfa1ac74298834c996ff2585360d6b3d299d24e1af18c",
"6def7395b1517005866105fe32c67fbc414a96e1c8e0f7f4a91de553c1511a47",
"6a16a39a8b01cbdd8b8fe805877886805e3a2b66df971a14b85047746a1fcc44",
"42a412d00f24e6dc676cb40a13eb436bc7dc6c30bd3e8fc507a57f8171ed1a34"
],
"time" : 1366491299,
"nonce" : 3844633920,
"bits" : "1c061134",
"difficulty" : 42.19345103,
"previousblockhash" : "00000000035cf14e882f8352f972e1b2fe81d0e3a23b6cfe385576d09451db3b",
"nextblockhash" : "000000009b0904c6f4d8462c871c0211eb9deac303382c3cda8c4711e7205c0e"
}

Here's a batch file to print a transaction number's block:
Code:
@echo off
setlocal enableextensions

for /f "tokens=* delims=:" %%a in (
'bitcoind gettransaction %1 ^| find "blockhash"'
) do (
set trans=%%a
)

for /f "tokens=3" %%G IN (%trans%) DO (set bhash=%%G)

for /f "tokens=*" %%a in (
'bitcoind getblock %bhash%" ^| find "height"'
) do (
set blknum=%%a
)

echo %blknum%
echo %bhash%

Programatically you could do "listtransactions", a bunch of these:

{
"account" : "",
"address" : "mjF49o7VKpGhPVnqGFJDELPFCeNRbWFYvb",
"category" : "generate",
"amount" : 50.00170000,
"confirmations" : 100600,
"generated" : true,
"blockhash" : "0000000000fb8329a24631d59371ca52724ea15e488b225682ddf7e5a4ee3be8",
"blockindex" : 0,
"blocktime" : 1366486115,
"txid" : "c1d51852a50df9da5c73d7b3023b99018c8d21730efff2854cd6a1c398b406bc",
"time" : 1366486115,
"timereceived" : 1366486118
},


then if category = generate, do getblock blockhash and extract height.
r.freeman (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
January 17, 2014, 07:34:25 AM
 #3

Thanks, that's what I thought... so not native way for it?

I find that would be nice thing. Maybe a patch is in order.
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!