5

So as an exercise I want to build a mining client, just because I'm curious.

I understand that I'm supposed to create a hash, but once I have the hash, where do I send it?

How do I submit it back to the block chain?

Murch
  • 71,155
  • 33
  • 180
  • 600
ghostJago
  • 153
  • 1
  • 7

1 Answers1

6

To submit a valid block to the block chain you don't use the hash, just the block. That's the block header plus the transactions.

Use bitcoind's submitblock RPC call.

> bitcoind help submitblock
submitblock <hex data> [optional-params-obj]
[optional-params-obj] parameter is currently ignored.
Attempts to submit new block to network.
See https://en.bitcoin.it/wiki/BIP_0022 for full specification.

So you hex encode the block and send it as lone parameter to submitblock. That's all.

As the help text says, submitblock is further documented in BIP22

Dr.Haribo
  • 8,409
  • 10
  • 43
  • 62
  • So the hash you create is just part of the overall block? – ghostJago Mar 06 '13 at 09:04
  • The hash is not part of the block. The block is the block header + transactions. There are many hashes used in bit coin, but the one you mine is the hash of the block header. It's not part of the block, but derived from it. What is in the block header though is the hash of the *previous* block. That's how the blocks are linked together in a chain. – Dr.Haribo Mar 06 '13 at 12:21
  • What are the endpoints? – WJA Feb 20 '21 at 16:30