1

I've been reading lots of articles, trying to understand how to hash the data returned from getwork; but I totally overlooked getblocktemplate.

I'm just trying to understand how all the data below is put together to generate hashes, in order to form a valid block (using various nonces).

Apologies if this has been answered already. I know there are lots of articles on how to put together a block header, and using midstate, etc. Most of that I understand; but the data composition of getblocktemplate is quite a bit different, and really threw me off.

If someone would be kind enough to explain the whole hashing process (from a mining point of view), I'd really appreciate it. A programmatic explanation would be ideal, as I'm trying to make my own mining client.

{
    "result":{
        "version":2,
        "previousblockhash":"00000000000000075f2f454573766ffae69fe41d6c7ccfcabbf8588fcd80ed52",
        "transactions":[
                  {     
                        "data":"0100000001cba672d0bfdbcc441d171ef0723a191bf050932c6f8adc8a05b0cac2d1eb022f010000006c493046022100a23472410d8fd7eabf5c739bdbee5b6151ff31e10d5cb2b52abeebd5e9c06977022100c2cdde5c632eaaa1029dff2640158aaf9aab73fa021ed4a48b52b33ba416351801210212ee0e9c79a72d88db7af3fed18ae2b7ca48eaed995d9293ae0f94967a70cdf6ffffffff02905f0100000000001976a91482db4e03886ee1225fefaac3ee4f6738eb50df9188ac00f8a093000000001976a914c94f5142dd7e35f5645735788d0fe1343baf146288ac00000000",
                        "hash":"7c90a5087ac4d5b9361d47655812c89b4ad0dee6ecd5e08814d00ce7385aa317",
                        "depends":[],
                        "fee":10000,
                        "sigops":2
                  },
                  ...
            ],
        "coinbaseaux":{
            "flags":"062f503253482f"
        },
        "coinbasevalue":2501100000,
        "target":"0000000000000026222200000000000000000000000000000000000000000000",
        "mintime":1379549850,
        "mutable":[
            "time",
            "transactions",
            "prevblock"
        ],
        "noncerange":"00000000ffffffff",
        "sigoplimit":20000,
        "sizelimit":1000000,
        "curtime":1379553872,
        "bits":"19262222",
        "height":258736
    },
    "error":null,
    "id":"curltest"
}
2

The wiki has an extremely good explanation, with a python run-through that takes you from GBT output to share submission. You could also have a look at some of the implementation in Luke-Jr's "gmp-proxy", which translates GBT reponses into a getwork compatible interface.

https://en.bitcoin.it/wiki/Getblocktemplate

https://gitlab.com/bitcoin/eloipool/blob/master/gmp-proxy.py

  • 1
    I read through that, but a lot of the terminology is new to me, and hard to understand. For example, it doesn't explain the parameters it's passing in, and their significance - {"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}. Also, on the return data - '"mutable":["time","transactions","prevblock"] vs "mutable": ["coinbase/append"]. On my GBT response, it has coinbaseaux flags instead of coinbasetxn data - what's the significance of that? What exactly does height mean? How is that all put together? It doesn't explain the smaller details. – xil3 Sep 19 '13 at 18:54
  • Thanks for posting the gmp-proxy - I'll take a look at that. – xil3 Sep 19 '13 at 19:05
  • Unfortunately, I'm not even that well versed in working with GBT. There's very little detail in any of the documentation, and it's actually quite unusual to have that much detail on an internal topic on the internal wiki. I'd suggest talking to one of the developers on freenode#bitcoin, maybe try and catch Luke-Jr if he is around. If anyone knows how GBT works, it's the person who developed it. – Anonymous Sep 21 '13 at 5:34
  • Yeah, I just joined that channel, but everyone seems to be idle. Hopefully someone sees my plea for help. – xil3 Sep 21 '13 at 5:54
  • #bitcoin-dev would be the correct channel for this. – Luke-Jr Dec 17 '13 at 1:32
1

You probably want to look at BIPs 22 and 23, as well as the libblkmaker source code (which includes an example of usage).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.