<p>Turns out that there was a bug in my code and not the invalid extranonce2 value!</p>

CC BY-SA 4.0
2021-04-01T13:47:43.030Z
2021-04-01T13:47:43.030Z
AhmadBenos
<p>I'm developing a stratum mining client. I read on <a href="https://braiins.com/stratum-v1/docs" rel="nofollow noreferrer">stratum v1 docs on braiins.com</a> how mining work is done on the stratum protocol and that the coinbase is done by concatenating coinb1+extranonce1+extranonce2+coinb2. At the end, mining work is submitted by sending this JSON: <code>{&quot;params&quot;: [&quot;&lt;worker&gt;&quot;, &quot;&lt;job_id&gt;&quot;, &quot;&lt;extranonce2&gt;&quot;, &quot;&lt;ntime&gt;&quot;, &quot;&lt;nonce&gt;&quot;], &quot;id&quot;: 4, &quot;method&quot;: &quot;mining.submit&quot;}</code>.</p>
<p>It says that the extranonce2 value is generated by the miner but must be based on the extranonce2 size provided by the pool. The extranonce2_size im getting from the pool is: 4 (4 bytes). So an extranonce2 value of 00000001(in hex) can be valid.</p>
<p><strong>However</strong>, when i'm trying to submit a random miner work to the pool(just testing) by throwing in random nonce and extraonce2(but of course using the current jobId and ntime provided by the response i got from the pool) i keep getting this error response: <code>20,incorrect size of extranonce2</code>.</p>
<p>The random extranonce2 i'm sending is '00000002' and random nonce is 'b2957c02'. Shouldn't i get a rejected share and not an incorrect extranonce2 size? I'm still new to this and don't yet understand exactly how everything works so where's my mistake here? or is it a pool problem? I know there's a lot of stuff to do before sending the miner work but here i'm trying to send a random miner work here.</p>
<p>btw is the request id always 4 in stratum for submitting work(or id: 'mining.submit')?</p>
<p>I'm authorizing the miner before submitting.</p>

<mining-pools><client><development><stratum>
What is a correct extranonce2 value in the stratum protocol?
AhmadBenos
# What is a correct extranonce2 value in the stratum protocol?

(Asked by: username_0 on 2021-03-31)

I'm developing a stratum mining client. I read on [stratum v1 docs on braiins.com](https://braiins.com/stratum-v1/docs) how mining work is done on the stratum protocol and that the coinbase is done by concatenating coinb1+extranonce1+extranonce2+coinb2. At the end, mining work is submitted by sending this JSON: `{"params": ["", "", "", "", ""], "id": 4, "method": "mining.submit"}`.

It says that the extranonce2 value is generated by the miner but must be based on the extranonce2 size provided by the pool. The extranonce2\_size im getting from the pool is: 4 (4 bytes). So an extranonce2 value of 00000001(in hex) can be valid.

**However**, when i'm trying to submit a random miner work to the pool(just testing) by throwing in random nonce and extraonce2(but of course using the current jobId and ntime provided by the response i got from the pool) i keep getting this error response: `20,incorrect size of extranonce2`.

The random extranonce2 i'm sending is '00000002' and random nonce is 'b2957c02'. Shouldn't i get a rejected share and not an incorrect extranonce2 size? I'm still new to this and don't yet understand exactly how everything works so where's my mistake here? or is it a pool problem? I know there's a lot of stuff to do before sending the miner work but here i'm trying to send a random miner work here.

btw is the request id always 4 in stratum for submitting work(or id: 'mining.submit')?

I'm authorizing the miner before submitting.

**Tags:** mining-pools, client, development, stratum


---

## 1 answers

### Answer by username_0 on 2021-04-01. Score: 2

Turns out that there was a bug in my code and not the invalid extranonce2 value!


---

