<p>The issue here is with:</p>

<pre><code>  (block.nVersion &lt; 3 &amp;&amp; nHeight &gt;= consensusParams.BIP66Height)
</code></pre>

<p>Your block has version 2, but I assume the block you are trying to download is higher than BIP66Height so it rejects it.</p>

<p>Its very difficult and requires a <strong>lot</strong> of expert know-how to modify the source code of a coin, and it sounds like you probably don't have the experience/skillset needed at this point, so I'd like to gently suggest you spend some more time learning about how bitcoin and the altcoin you are working on are coded, etc. before trying to make this modification, because you can't just copy and paste code from bitcoin into an altcoin and expect it to work. Different coins just aren't compatible with each other in that way.</p>

CC BY-SA 3.0
2017-07-28T08:28:33.440Z
i know how to modify ,but problem is only with acceptable block... i cannot find info how work.
tseries
CC BY-SA 3.0
2017-07-28T08:59:17.707Z
End not just copy past code. I try update , but stuck on this bip settings
tseries
CC BY-SA 3.0
2017-07-28T11:26:03.777Z
I'm afraid to say that if this is giving you difficulty, you probably don't have the skillset required for modifying the coin, as I said. I've voted to close this question as too broad because of that, it's simply not narrow enough to answer.
meshcollider
CC BY-SA 3.0
2017-07-28T12:13:48.503Z
You think i do not try so simple how change values of version's in this a piece sources ? Way  you try answer if you do not know  ? Find simple question end answer ... Way people how you try answer question if they do not know answer end if they answer is wrong they try quickly down vot question.
tseries
CC BY-SA 3.0
2017-07-28T12:29:32.827Z
I know c++ , i know how create change any coin's , any wallet. But i only have problem with this bip. End i ask solution , it's faster then research all code if any who know this end can share it , you do not think that ? End for this i think been created this service , not for collect reputation which is worth nothing... + compilation on my hardware is very long process, end it make a problem to research all self on this moment.
tseries
CC BY-SA 3.0
2017-07-29T17:45:56.017Z
@tseries Please do not insult people who are trying to help you. Assume food faith and be nice. https://bitcoin.stackexchange.com/help/be-nice
Nick ODell
CC BY-SA 3.0
2017-07-29T20:08:17.333Z
sorry for that , i do not sleep 2 day's where trying to fix this ...
tseries
CC BY-SA 3.0
2017-07-28T06:59:31.583Z
2017-07-28T06:59:31.583Z
meshcollider
<p>I have altcoin bassed on old Litecoin sources, end i try to convert it for latest available sources. How i can do this ? What need for this ?</p>

<p>I try simple download it on old wallet, then run new. But mine new or download them from other wallet no possible. I try find info how do this. But find noting. </p>

<p>I have this error when trying download block's from peer's</p>

<pre><code>ERROR: AcceptBlockHeader: Consensus::ContextualCheckBlockHeader: 90e718e6878f4b7ae4de4ae83db75881d00ca017f5a117c2054798bcb76c4178, bad-version(0x00000002), rejected nVersion=0x00000002 block (code 17)
2017-07-28 04:12:10 ERROR: invalid header received
2017-07-28 04:12:10 ProcessMessages(headers, 162003 bytes) FAILED peer=0
2017-07-28 04:12:10 receive version message: /Satoshi:1.0.0/: version 70002, blocks=3293, us=x.x.x.x:12815, peer=1
</code></pre>

<p>in</p>

<pre><code>validator i have this settings

        // Check proof of work
    if (block.nBits != GetNextWorkRequired(pindexPrev, &amp;block, consensusParams))
        return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work");

    // Check timestamp against prev
    if (block.GetBlockTime() &lt;= pindexPrev-&gt;GetMedianTimePast())
        return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early");

    // Check timestamp
    if (block.GetBlockTime() &gt; nAdjustedTime + 2 * 60 * 60)
        return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");

    // Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:
    // check for version 2, 3 and 4 upgrades
    if((block.nVersion &lt; 2 &amp;&amp; nHeight &gt;= consensusParams.BIP34Height) ||
       (block.nVersion &lt; 3 &amp;&amp; nHeight &gt;= consensusParams.BIP66Height) ||
       (block.nVersion &lt; 4 &amp;&amp; nHeight &gt;= consensusParams.BIP65Height))
            return state.Invalid(false, REJECT_OBSOLETE, strprintf("bad-version(0x%08x)", block.nVersion),
                                 strprintf("rejected nVersion=0x%08x block", block.nVersion));

    if (block.nVersion &lt; VERSIONBITS_TOP_BITS &amp;&amp; IsWitnessEnabled(pindexPrev, consensusParams))
        return state.Invalid(false, REJECT_OBSOLETE, strprintf("bad-version(0x%08x)", block.nVersion),
                                 strprintf("rejected nVersion=0x%08x block", block.nVersion));

    return true;
}
</code></pre>

<p>in genesis block settings i have</p>

<pre><code>    genesis = CreateGenesisBlock(1498204210, 215446, 0x1e0ffff0, 1, 500 * COIN);

but i have in old sources this setting

        // Check that the block chain matches the known block chain up to a checkpoint
        if (!Checkpoints::CheckBlock(nHeight, hash))
            return state.DoS(100, error("AcceptBlock() : rejected by checkpoint lock-in at %d", nHeight));

        // Don't accept any forks from the main chain prior to last checkpoint
        CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
        if (pcheckpoint &amp;&amp; nHeight &lt; pcheckpoint-&gt;nHeight)
            return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight));

        // Reject block.nVersion=1 blocks (mainnet &gt;= 710000, testnet &gt;= 400000)
        if (nVersion &lt; 2)
        {
            if ((!fTestNet &amp;&amp; nHeight &gt;= 710000) ||
               (fTestNet &amp;&amp; nHeight &gt;= 400000))
            {
                return state.Invalid(error("AcceptBlock() : rejected nVersion=1 block"));
            }
        }
        // Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
        if (nVersion &gt;= 2)
        {
            if ((!fTestNet &amp;&amp; nHeight &gt;= 710000) ||
               (fTestNet &amp;&amp; nHeight &gt;= 400000))
            {
                CScript expect = CScript() &lt;&lt; nHeight;
                if (vtx[0].vin[0].scriptSig.size() &lt; expect.size() ||
                    !std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin()))
                    return state.DoS(100, error("AcceptBlock() : block height mismatch in coinbase"));
            }
        }
    }
</code></pre>

<p>what i need to change for it's start accept block's</p>

<altcoin-development><block-header>
how to convert blockchain to new version?
tseries
# how to convert blockchain to new version?

(Asked by: username_0 on 2017-07-28)

I have altcoin bassed on old Litecoin sources, end i try to convert it for latest available sources. How i can do this ? What need for this ?

I try simple download it on old wallet, then run new. But mine new or download them from other wallet no possible. I try find info how do this. But find noting.

I have this error when trying download block's from peer's

```
ERROR: AcceptBlockHeader: Consensus::ContextualCheckBlockHeader: 90e718e6878f4b7ae4de4ae83db75881d00ca017f5a117c2054798bcb76c4178, bad-version(0x00000002), rejected nVersion=0x00000002 block (code 17)
2017-07-28 04:12:10 ERROR: invalid header received
2017-07-28 04:12:10 ProcessMessages(headers, 162003 bytes) FAILED peer=0
2017-07-28 04:12:10 receive version message: /Satoshi:1.0.0/: version 70002, blocks=3293, us=x.x.x.x:12815, peer=1

```

in

```
validator i have this settings

        // Check proof of work
    if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
        return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work");

    // Check timestamp against prev
    if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast())
        return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early");

    // Check timestamp
    if (block.GetBlockTime() > nAdjustedTime + 2 * 60 * 60)
        return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");

    // Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:
    // check for version 2, 3 and 4 upgrades
    if((block.nVersion < 2 && nHeight >= consensusParams.BIP34Height) ||
       (block.nVersion < 3 && nHeight >= consensusParams.BIP66Height) ||
       (block.nVersion < 4 && nHeight >= consensusParams.BIP65Height))
            return state.Invalid(false, REJECT_OBSOLETE, strprintf("bad-version(0x%08x)", block.nVersion),
                                 strprintf("rejected nVersion=0x%08x block", block.nVersion));

    if (block.nVersion < VERSIONBITS_TOP_BITS && IsWitnessEnabled(pindexPrev, consensusParams))
        return state.Invalid(false, REJECT_OBSOLETE, strprintf("bad-version(0x%08x)", block.nVersion),
                                 strprintf("rejected nVersion=0x%08x block", block.nVersion));

    return true;
}

```

in genesis block settings i have

```
    genesis = CreateGenesisBlock(1498204210, 215446, 0x1e0ffff0, 1, 500 * COIN);

but i have in old sources this setting

        // Check that the block chain matches the known block chain up to a checkpoint
        if (!Checkpoints::CheckBlock(nHeight, hash))
            return state.DoS(100, error("AcceptBlock() : rejected by checkpoint lock-in at %d", nHeight));

        // Don't accept any forks from the main chain prior to last checkpoint
        CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
        if (pcheckpoint && nHeight < pcheckpoint->nHeight)
            return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight));

        // Reject block.nVersion=1 blocks (mainnet >= 710000, testnet >= 400000)
        if (nVersion < 2)
        {
            if ((!fTestNet && nHeight >= 710000) ||
               (fTestNet && nHeight >= 400000))
            {
                return state.Invalid(error("AcceptBlock() : rejected nVersion=1 block"));
            }
        }
        // Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
        if (nVersion >= 2)
        {
            if ((!fTestNet && nHeight >= 710000) ||
               (fTestNet && nHeight >= 400000))
            {
                CScript expect = CScript() << nHeight;
                if (vtx[0].vin[0].scriptSig.size() < expect.size() ||
                    !std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin()))
                    return state.DoS(100, error("AcceptBlock() : block height mismatch in coinbase"));
            }
        }
    }

```

what i need to change for it's start accept block's

**Tags:** altcoin-development, block-header


---

## 1 answers

### Answer by username_1 on 2017-07-28. Score: 5 | Accepted answer

The issue here is with:

```
  (block.nVersion < 3 && nHeight >= consensusParams.BIP66Height)

```

Your block has version 2, but I assume the block you are trying to download is higher than BIP66Height so it rejects it.

Its very difficult and requires a **lot** of expert know-how to modify the source code of a coin, and it sounds like you probably don't have the experience/skillset needed at this point, so I'd like to gently suggest you spend some more time learning about how bitcoin and the altcoin you are working on are coded, etc. before trying to make this modification, because you can't just copy and paste code from bitcoin into an altcoin and expect it to work. Different coins just aren't compatible with each other in that way.

> **Comments:**
> **username_0**: i know how to modify ,but problem is only with acceptable block... i cannot find info how work.  
> **username_0**: End not just copy past code. I try update , but stuck on this bip settings  
> **username_1**: I'm afraid to say that if this is giving you difficulty, you probably don't have the skillset required for modifying the coin, as I said. I've voted to close this question as too broad because of that, it's simply not narrow enough to answer.  
> **username_0**: You think i do not try so simple how change values of version's in this a piece sources ? Way  you try answer if you do not know  ? Find simple question end answer ... Way people how you try answer question if they do not know answer end if they answer is wrong they try quickly down vot question.  
> **username_0**: I know c++ , i know how create change any coin's , any wallet. But i only have problem with this bip. End i ask solution , it's faster then research all code if any who know this end can share it , you do not think that ? End for this i think been created this service , not for collect reputation which is worth nothing... + compilation on my hardware is very long process, end it make a problem to research all self on this moment.  
> **username_2**: @username_0 Please do not insult people who are trying to help you. Assume food faith and be nice. https://bitcoin.stackexchange.com/help/be-nice  
> **username_0**: sorry for that , i do not sleep 2 day's where trying to fix this ...  

---

