Altcoin-Development

如何將區塊鏈轉換為新版本?

  • December 24, 2017

我有基於舊 Litecoin 資源的山寨幣,最後我嘗試將其轉換為最新的可用資源。我怎麼能這樣做?這需要什麼?

我嘗試在舊錢包上簡單地下載它,然後執行新的。但是我的新的或從其他錢包下載它們是不可能的。我嘗試查找資訊如何做到這一點。但發現注意。

嘗試從同行下載塊時出現此錯誤

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

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;
}

在創世塊設置中我有

   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"));
           }
       }
   }

我需要改變它的開始接受塊

這裡的問題在於:

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

您的塊有版本 2,但我假設您嘗試下載的塊高於 BIP66Height,因此它會拒絕它。

修改一個硬幣的原始碼非常困難,需要很多專業知識,聽起來你可能沒有此時需要的經驗/技能,所以我想輕輕地建議你花費在嘗試進行此修改之前,請花更多時間了解比特幣和您正在使用的山寨幣是如何編碼的,等等,因為您不能只是將比特幣中的程式碼複製並粘貼到山寨幣中並期望它能夠工作。不同的硬幣就是不以這種方式相互兼容。

引用自:https://bitcoin.stackexchange.com/questions/57208