<p>I think no - it's not possible using the current bitconind.</p>

<p>Unless you want to use not only RPC, but also the bitcoin protocol. Then you can just download each new block from your node (using getdata command) and check it is has "Mined By ASICMiner" in the expected place.</p>

<p>You could also look into the blocks database directly - the blocks are stored on disk by your bitcoin node, in a pretty straight forward format.</p>

CC BY-SA 3.0
2013-05-25T21:23:06.353Z
-1 "I think" is not an answer, either you know or you do not know.
o0'.
CC BY-SA 3.0
2013-05-26T15:10:26.960Z
It is, when you're modest :) But, since you care about words so much: I am very sure that getrawtransaction will not work for old spent transactions. Feel free to -1 the truth one more time, but this just won't fix the world :)
Gigi
CC BY-SA 3.0
2013-05-24T18:01:34.687Z
2013-05-24T18:01:34.687Z
Gigi
<p>I think this is best answered by an example. Let's find the coinbase from a block on the Bitcoin testnet.</p>

<p>First we'll get the hash for a block we want to look at. We'll have a look at the (as I write this) latest block:</p>

<pre><code>&gt; bitcoind getblockcount
81626
&gt; bitcoind getblockhash 81626
0000000000834f3933b50577b854692ed246728a17d10006ced1283a3fd8074c
</code></pre>

<p>Now we need to find the hash of the generation transaction from that block. It's always the first one listed. In this example there is only 1 transaction.</p>

<pre><code>&gt; bitcoind getblock 0000000000834f3933b50577b854692ed246728a17d10006ced1283a3fd8074c
[...]
    "tx" : [
        "f1fdeb7ced28f697c97b6a3ed7cc1946e1fc5e062ad8c17d05c88b1767b91b2a"
    ],
[...]
</code></pre>

<p>And now we can grab the coinbase from the transaction. The getrawtransaction command's second parameter can be set to 1 to give us individual pieces of the transaction so we can easily find the coinbase. Alternatively we could leave that out and it would give us a single binary blob to navigate ourselves.</p>

<pre><code>&gt; bitcoind getrawtransaction f1fdeb7ced28f697c97b6a3ed7cc1946e1fc5e062ad8c17d05c88b1767b91b2a 1
[...]
"coinbase" : "03da3e012cfabe6d6d18c47c97379852a93158528bb709355a0d38d05fedf072b610bb57442aad4e710400000000000000062f503253482f",
[...]
</code></pre>

<p>And there's the coinbase. Now we can check whether it contains pieces of ASCII text or whatever else we want to do with it.</p>

CC BY-SA 3.0
2013-05-24T17:57:20.713Z
I though "getrawtransaction" would only work for transactions that are in the memory pool? Not for those that have been mined into blocks already...
Gigi
CC BY-SA 3.0
2013-05-25T10:09:54.017Z
I see what I'd been doing - I'd been testing getrawtransaction on the genesis block (since I knew that contained a message) - and of course that didn't work.Thanks DrH!
organofcorti
CC BY-SA 3.0
2013-12-19T03:12:18.703Z
I forgot to add - this method only works for recent blocks.
organofcorti
CC BY-SA 3.0
2013-05-24T16:02:38.910Z
2013-05-24T16:02:38.910Z
Dr.Haribo
<p>ASICMiner includes hex(Mined By ASICMiner) in the coinbase.</p>

<p>I'd like to generate weekly statistics that include ASICMiner' solo-mining efforts, but I don't want to have to rely on blockchain.info or blockexplorer.com. Is there a way to use bitcoind commands to return the coinbase for a block of given height (or hash)?</p>

<bitcoind><blockchain><json-rpc><coinbase-transaction>
Is there a way to find the coinbase for a given block using only bitcoind commands?
organofcorti
# Is there a way to find the coinbase for a given block using only bitcoind commands?

(Asked by: username_0 on 2013-05-24)

ASICMiner includes hex(Mined By ASICMiner) in the coinbase.

I'd like to generate weekly statistics that include ASICMiner' solo-mining efforts, but I don't want to have to rely on blockchain.info or blockexplorer.com. Is there a way to use bitcoind commands to return the coinbase for a block of given height (or hash)?

**Tags:** bitcoind, blockchain, json-rpc, coinbase-transaction


---

## 2 answers

### Answer by username_3 on 2013-05-24. Score: 4 | Accepted answer

I think this is best answered by an example. Let's find the coinbase from a block on the Bitcoin testnet.

First we'll get the hash for a block we want to look at. We'll have a look at the (as I write this) latest block:

```
> bitcoind getblockcount
81626
> bitcoind getblockhash 81626
0000000000834f3933b50577b854692ed246728a17d10006ced1283a3fd8074c

```

Now we need to find the hash of the generation transaction from that block. It's always the first one listed. In this example there is only 1 transaction.

```
> bitcoind getblock 0000000000834f3933b50577b854692ed246728a17d10006ced1283a3fd8074c
[...]
    "tx" : [
        "f1fdeb7ced28f697c97b6a3ed7cc1946e1fc5e062ad8c17d05c88b1767b91b2a"
    ],
[...]

```

And now we can grab the coinbase from the transaction. The getrawtransaction command's second parameter can be set to 1 to give us individual pieces of the transaction so we can easily find the coinbase. Alternatively we could leave that out and it would give us a single binary blob to navigate ourselves.

```
> bitcoind getrawtransaction f1fdeb7ced28f697c97b6a3ed7cc1946e1fc5e062ad8c17d05c88b1767b91b2a 1
[...]
"coinbase" : "03da3e012cfabe6d6d18c47c97379852a93158528bb709355a0d38d05fedf072b610bb57442aad4e710400000000000000062f503253482f",
[...]

```

And there's the coinbase. Now we can check whether it contains pieces of ASCII text or whatever else we want to do with it.

> **Comments:**
> **username_1**: I though "getrawtransaction" would only work for transactions that are in the memory pool? Not for those that have been mined into blocks already...  
> **username_0**: I see what I'd been doing - I'd been testing getrawtransaction on the genesis block (since I knew that contained a message) - and of course that didn't work.Thanks DrH!  
> **username_0**: I forgot to add - this method only works for recent blocks.  

---

### Answer by username_1 on 2013-05-24. Score: 0

I think no - it's not possible using the current bitconind.

Unless you want to use not only RPC, but also the bitcoin protocol. Then you can just download each new block from your node (using getdata command) and check it is has "Mined By ASICMiner" in the expected place.

You could also look into the blocks database directly - the blocks are stored on disk by your bitcoin node, in a pretty straight forward format.

> **Comments:**
> **username_2**: -1 "I think" is not an answer, either you know or you do not know.  
> **username_1**: It is, when you're modest :) But, since you care about words so much: I am very sure that getrawtransaction will not work for old spent transactions. Feel free to -1 the truth one more time, but this just won't fix the world :)  

---

