Bitcoin Forum
January 28, 2020, 07:17:27 PM
 News: Latest Bitcoin Core release: 0.19.0.1 [Torrent]
 Home Help Search Login Register More
 Pages: [1]
 Author Topic: Determining a Block's Extranonce Value  (Read 1214 times)
Geremia
Sr. Member

Offline

Activity: 468
Merit: 250

 March 14, 2015, 01:22:31 AM

How do I determine a block's extranonce value? I know they are in the coinbase transaction, but where?

BTC tip jar | my BTC wiki, BTC StackExchange, & Twister posts pages | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
1580239047
Hero Member

Offline

Posts: 1580239047

Ignore
 1580239047

1580239047
 Report to moderator
1580239047
Hero Member

Offline

Posts: 1580239047

Ignore
 1580239047

1580239047
 Report to moderator
1580239047
Hero Member

Offline

Posts: 1580239047

Ignore
 1580239047

1580239047
 Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
laurentmt
Sr. Member

Offline

Activity: 386
Merit: 250

 March 14, 2015, 03:25:53 PMLast edit: March 14, 2015, 03:54:54 PM by laurentmt

The extranonce can be found in the coinbase data from a coinbase transaction.
This data can be interpreted as a script pushing data onto the stack and the extranonce is the second value.

Example
Quote
{
...
"vin" : [
{
"coinbase" : "03443b0403858402062f503253482f",
"sequence" : 4294967295
}
],
...
}

can be interpreted as:
03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack <-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack <-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack <-- arbitrary data

EDIT: This format was defined by BIP34 and applies to blocks with version >= 2. I'm not sure how the extranonce was managed before that.
Geremia
Sr. Member

Offline

Activity: 468
Merit: 250

 March 14, 2015, 03:56:30 PMLast edit: March 14, 2015, 04:08:13 PM by Geremia

Example
Quote
{
...
"vin" : [
{
"coinbase" : "03443b0403858402062f503253482f",
"sequence" : 4294967295
}
],
...
}

can be interpreted as:
03 = push 3 bytes onto the stack
443b04 = 3 bytes pushed onto the stack <-- Block index
03 = push 3 bytes onto the stack
858402 = 3 bytes pushed onto the stack <-- The extranonce
06 = push 6 bytes onto the stack
2f503253482f = 6 bytes pushed onto the stack <-- arbitrary data
I thought the extranonce was 8 bytes.

BTC tip jar | my BTC wiki, BTC StackExchange, & Twister posts pages | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
laurentmt
Sr. Member

Offline

Activity: 386
Merit: 250

 March 14, 2015, 05:25:43 PMLast edit: March 14, 2015, 06:06:00 PM by laurentmt

I thought the extranonce was 8 bytes.
My guess is that the extranonce is 8 bytes max but is stored with a compressed representation for lower values.

The extranonce is outside the scope of the bitcoin protocol (BIP34 doesn't say anything about it) and it seems hard to find reliable information about how mining pools manage the coinbase data. Actually, I think different mining pools may enforce different formats.
I've found some sources indicating the 2nd value as the extranonce but I suspect that it's only true for some clients (bitcoind ?).

Investigation in progress...

EDIT:
After some forum archeology, I've found this interesting post related to a study done by Sergio_Demian_Lerner about extranonces.
It seems to confirm the script structure with the extranonce being the second value pushed onto the stack. I was puzzled by the first value but it may be the same value as the bits fields stored in the header.

Geremia
Sr. Member

Offline

Activity: 468
Merit: 250

 March 14, 2015, 07:25:27 PM

On #eligius I asked Luke-Jr, operator of Eligius pool, and he said:
Quote
[12:08] <@Luke-Jr> throwing it on the end of the coinbase
[12:08] <@Luke-Jr> or in the middle
[12:08] <@Luke-Jr> I think most stratum pools use the end of it
[12:08] <@Luke-Jr> p2pool abuses an output
[12:09] <@Luke-Jr> GBT pools let miners put anything on the end, and at least BFGMiner does <extranonce><miner version>
It seems pretty arbitrary, then.

He also said that the BitcoinTalk post you cited is outdated.

BTC tip jar | my BTC wiki, BTC StackExchange, & Twister posts pages | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
nickodell
Newbie

Offline

Activity: 2
Merit: 0

 March 14, 2015, 07:36:13 PM

EDIT: This format was defined by BIP34 and applies to blocks with version >= 2. I'm not sure how the extranonce was managed before that.
I wrote a summary of how the coinbase scriptSig has changed over time here.
You've pretty much got it right.
laurentmt
Sr. Member

Offline

Activity: 386
Merit: 250

 March 14, 2015, 07:57:39 PM

I wrote a summary of how the coinbase scriptSig has changed over time here.
You've pretty much got it right.
Thanks. It's bookmarked !

It seems pretty arbitrary, then.
Yep !

He also said that the BitcoinTalk post you cited is outdated.
It is. I've linked this thread because I thought you might be interested by formats used in older blocks (before BIP34). It was just an inference from your previous post about nonces & hash values. My apologies if I was wrong.
 Pages: [1]