Bitcoin Forum
October 31, 2024, 01:29:27 PM *
News: Bitcoin Pumpkin Carving Contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Raw original work request of solved block  (Read 237 times)
nQuant (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 4


View Profile
January 12, 2018, 07:53:13 PM
 #1

Does anybody has the actual raw work request of solved block ? I'm just creating mining application and need to very it actually working after that all endiness conversion mombo jumbo. The only missing part from blockchain explorer is params used to create markel root. Appreciate if anybody has it handy or pull from their log or something.

Just to add more below params I'm after of any solved block to test

Coinbase1
ExtraNonce
ExtraNonce2
Coinbase2
Transaction Ids[]
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6884


Just writing some code


View Profile WWW
January 13, 2018, 12:14:38 AM
 #2

The merkle root is computed from the transaction ids.

nQuant (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 4


View Profile
January 13, 2018, 12:24:31 AM
 #3

The merkle root is computed from the transaction ids.

Not just transaction ids, all of the parameters below
Coinbase1
ExtraNonce
ExtraNonce2
Coinbase2
Transaction Ids[]


ref:
https://github.com/m0mchil/poclbm/blob/2ae15b77df1d17d2ec2748673ba2e8e0a01891c5/StratumSource.py

Code:
j.extranonce2 = self.increment_nonce(j.extranonce2)
coinbase = j.coinbase1 + self.extranonce + j.extranonce2 + j.coinbase2
merkle_root = sha256(sha256(unhexlify(coinbase)).digest()).digest()

for hash_ in j.merkle_branch:
merkle_root = sha256(sha256(merkle_root + unhexlify(hash_)).digest()).digest()
merkle_root_reversed = ''
for word in chunks(merkle_root, 4):
merkle_root_reversed += word[::-1]
merkle_root = hexlify(merkle_root_reversed)
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6884


Just writing some code


View Profile WWW
January 13, 2018, 12:26:50 AM
 #4

Not just transaction ids, all of the parameters below
Coinbase1
ExtraNonce
ExtraNonce2
Coinbase2
Transaction Ids[]
Those parameters are part of the transaction ids. All of those parameters except for transaction Ids[] are for constructing the coinbase transaction. It's txid is then used in the merkle root.

nQuant (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 4


View Profile
January 13, 2018, 04:39:05 AM
Last edit: January 13, 2018, 05:03:00 AM by nQuant
 #5

Not just transaction ids, all of the parameters below
Coinbase1
ExtraNonce
ExtraNonce2
Coinbase2
Transaction Ids[]
Those parameters are part of the transaction ids. All of those parameters except for transaction Ids[] are for constructing the coinbase transaction. It's txid is then used in the merkle root.

But to form a block header, I need markel which is calculated using coinbase + transaction ids. Right ? I'm referring to the logic from the reference link and other miner source code I referred, which happen to be doing same thing.

Edit 1:
Ok so if I'm getting what you are saying is, once the block is solved below markel_root becomes a transaction id to send newly generated coins which is already included in blocexplorer's transactions

merkle_root = sha256(sha256(unhexlify(coinbase)).digest()).digest()

Edit 2:
I just tested markel calculation just using transaction id from random solved block and its not matching with that blocks markel.
Am I missing something, to reverse engineer the solved block ?


achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6884


Just writing some code


View Profile WWW
January 13, 2018, 05:00:50 AM
 #6

Ok so if I'm getting what you are saying is, once the block is solved below markel_root becomes a transaction id to send newly generated coins which is already included in blocexplorer's transactions

merkle_root = sha256(sha256(unhexlify(coinbase)).digest()).digest()
No, not at all.

The coinbase transaction's txid is included as part of the merkle root. The construction of the merkle root is described here: https://github.com/bitcoin/bitcoin/blob/master/src/consensus/merkle.cpp#L9. Basically you concatenate the txids of pairs of transactions and hash them, then concatenate pairs of hashes, and so on until there is only one hash remaining.

The fields Coinbase1, ExtraNonce, ExtraNonce2, and Coinbase2 are used to construct the coinbase transaction which pays the miner. The transaction id of that coinbase transaction is then used to construct the merkle root.

nQuant (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 4


View Profile
January 13, 2018, 05:18:50 AM
 #7

Ok so if I'm getting what you are saying is, once the block is solved below markel_root becomes a transaction id to send newly generated coins which is already included in blocexplorer's transactions

merkle_root = sha256(sha256(unhexlify(coinbase)).digest()).digest()
No, not at all.

The coinbase transaction's txid is included as part of the merkle root. The construction of the merkle root is described here: https://github.com/bitcoin/bitcoin/blob/master/src/consensus/merkle.cpp#L9. Basically you concatenate the txids of pairs of transactions and hash them, then concatenate pairs of hashes, and so on until there is only one hash remaining.

The fields Coinbase1, ExtraNonce, ExtraNonce2, and Coinbase2 are used to construct the coinbase transaction which pays the miner. The transaction id of that coinbase transaction is then used to construct the merkle root.

Correct you are referring to process of calculating markel, actually I need all those parameters to test my application is actually calculating same markel and all the required inputs further to find same nonce as blockexplorer. That's just for end to end testing of my own mining application.
kotlarz
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
January 13, 2018, 03:57:05 PM
 #8

This helped me when I played around with the stratum protocol a few years ago, might help you a bit (see "Building Local Work"): http://archive.is/CH9a0
Anti-Cen
Member
**
Offline Offline

Activity: 210
Merit: 26

High fees = low BTC price


View Profile
January 13, 2018, 11:56:54 PM
 #9

https://github.com/bitcoin/bitcoin/blob/master/src/consensus/merkle.cpp#L9. Basically you concatenate the txids of pairs of transactions and hash them, then concatenate pairs of

I was hoping the hash was just the previous hash added to a hash of all the data below the header for the block

Nothing is easy with bitcoin but it's good to see you know your stuff so i will bookmark the post and thanks

Mining is CPU-wars and Intel, AMD like it nearly as much as big oil likes miners wasting electricity. Is this what mankind has come too.
nQuant (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 4


View Profile
January 14, 2018, 03:39:02 AM
 #10

This helped me when I played around with the stratum protocol a few years ago, might help you a bit (see "Building Local Work"): http://archive.is/CH9a0

Thanks that's what I wanted.
nQuant (OP)
Newbie
*
Offline Offline

Activity: 18
Merit: 4


View Profile
January 15, 2018, 04:28:34 AM
 #11

This helped me when I played around with the stratum protocol a few years ago, might help you a bit (see "Building Local Work"): http://archive.is/CH9a0

Seems its not example of actually solvable block. Result hash is not less than target. Or I got the markel wrong ?

http://learnmeabitcoin.com/tools/hashblockheader/?version=2&hashPrevBlock=000000001e920b44c0c6771b61e57a48787fe66d2aae448f19e2f65af8b6164d&hashMerkleRoot=4f699989fde3ff7ad9824846f4fb4c72c35fa8a716cef88fdda926ccf7cc8a6e&time=2012-09-11+00%3A33%3A49&bits=1c2ac4af&nonce=2996141058&submit=true
LevaMuS
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
February 27, 2021, 08:18:20 PM
 #12

This post is old, but maybe someone is searching for working example:


https://learnmeabitcoin.com/explorer/block/0000000000000b60bc96a44724fd72daf9b92cf8ad00510b5224c6253ac40095

https://learnmeabitcoin.com/tools/hashblockheader/?version=1&hashPrevBlock=0000000000004df94b4488e034359e862725dc969c498b9678dc261c58a679dc&hashMerkleRoot=271bb1df11fbb9aaf1e06b7719843635e057808fd9a4daee7c30070eb8d7ad50&time=2011-05-12+11%3A43%3A04&bits=1a6a93b3&nonce=1160139541&submit=true
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!