Author

Topic: bitcoin-cli submitblock template (Read 46 times)

legendary
Activity: 3598
Merit: 2490
Evil beware: We have waffles!
January 06, 2023, 07:31:06 PM
#3
A better area of the Forum to ask this in the Development & Technical area of the Forum where you will find more folks working with core and its various subsystems.
newbie
Activity: 4
Merit: 4
January 06, 2023, 06:00:02 PM
#2
Answer to 1.
The block header is being hashed and consists of six variables: [ 0]

Version + hashPrevBlock + hashMerkleRoot + Time + Bits + Nonce

Answer to 2.
The getblocktemplate method returns the proper template for the blocksubmit method. The getblocktemplate documentation is available in the Bitcoin Core Docs. [ 1] To get a block template, run bitcoin-cli getblocktemplate.


[ 0] https://en.bitcoin.it/wiki/Block_hashing_algorithm

[ 1] https://bitcoincore.org/en/doc/0.16.0/rpc/mining/getblocktemplate/
newbie
Activity: 4
Merit: 4
January 06, 2023, 02:16:47 PM
#1
Thank you in advance for your time in reading. I am working on developing a template for the bitcoin-cli submitblock [1] method. I have posted Issue #26830 on the Bitcoin Core GitHub [2]. Issue #26830 provides a detailed overview of all available information relating to the proper form for block hashing and submission for validation. However, there are still two keystone questions I have to be able to get started:

1. What, exactly, is being hashed?
2. What, exactly, is the required format for submissions?

As far as I can tell, block hashing requires hashing six variables, Version + hashPrevBlock + hashMerkleRoot + Time + Bits + Nonce. However, my previous impression was that hashing was a method for finding a nonce value, such that the nonce when hashed would produce a hash lower than the hash of the previous block. So, I am having trouble working through the logic. I am also struggling to understand what the file format for block submissions should be and how to format the file. It is not clear to me whether JSON or hexadigit format should be used nor how such file should be structured.

Any advice or suggestions would be sincerely appreciated.


References
[1] https://bitcoincore.org/en/doc/0.16.0/rpc/mining/submitblock
[2] https://github.com/bitcoin/bitcoin/issues/26830
Jump to: