Author

Topic: get all transactions from a block [bitcoind] (Read 871 times)

legendary
Activity: 1456
Merit: 1076
I may write code in exchange for bitcoins.
September 03, 2014, 09:33:21 PM
#3
Thanks!  I just realized this myself after posting.  I think I didn't notice it because there were only 2 transactions in that random block I illustrated with.

I'm now playing with getrawtransaction.  Cheers!
legendary
Activity: 3388
Merit: 4615
September 03, 2014, 09:20:13 PM
#2
Do I need to parse one of these fields in order to get a list of transactions included in this block?

Yes.

If so, where do I find the spec for that operation?

Code:
$ h=`bitcoind getblockhash 150000`
$ bitcoind getblock $h
{
 - snip -
    "tx" : [
        "235b91c7b53c100f9f836ad17b6e0e417279efda77606d490ec743817bac6ff6",
        "1b1202259a5c28f8e81dbc6d1ddd5bbf37d3af18d549495b2b9ad315fb9738a8"
    ],
- snip -
}

There you go.  There's your list of transactions.

Or is there another rpc call that I should be making?

If you want the actual details of each transaction, you'll need to call getrawtransaction and decoderawtransaction for each transaction in the list.
legendary
Activity: 1456
Merit: 1076
I may write code in exchange for bitcoins.
September 03, 2014, 09:03:35 PM
#1
Hey there,

I'm playing around with rpc calls to a bitcoind instance.  I can get the info about a given block by passing its hash to 'getblock':

Code:
$ h=`bitcoind getblockhash 150000`
$ bitcoind getblock $h
{
    "hash" : "0000000000005e5fd51f764d230441092f1b69d1a1eeab334c5bb32412e8dc51",
    "confirmations" : 128754,
    "size" : 410,
    "height" : 150000,
    "version" : 2,
    "merkleroot" : "ea6054d3d19ea2cc460809179b93946cfb4dac4db48837eb5e3ba3d150ae3ddd",
    "tx" : [
        "235b91c7b53c100f9f836ad17b6e0e417279efda77606d490ec743817bac6ff6",
        "1b1202259a5c28f8e81dbc6d1ddd5bbf37d3af18d549495b2b9ad315fb9738a8"
    ],
    "time" : 1386098130,
    "nonce" : 2666252006,
    "bits" : "1b24a835",
    "difficulty" : 1787.78664453,
    "chainwork" : "000000000000000000000000000000000000000000000000028360d5673d92a9",
    "previousblockhash" : "00000000002380e843bcef7c5656498fd55caa64243cd60acb329ec8bb0f6699",
    "nextblockhash" : "000000000023a097d684c7c3be7a9410b85337374b8d7786cdbe38e947608e1b"
}

Do I need to parse one of these fields in order to get a list of transactions included in this block?  If so, where do I find the spec for that operation?  Or is there another rpc call that I should be making?
Jump to: