Bitcoin Forum
November 06, 2024, 11:11:57 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 »  All
  Print  
Author Topic: *** Complete Guide on How to Create a New Alt Coin – Update 2019 ***  (Read 2153 times)
TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
April 21, 2019, 05:33:17 AM
Last edit: September 01, 2020, 07:55:56 AM by TheWolf666
Merited by d5000 (1), Fatunad (1), Vispilio (1), ophyrim (1), Dermelon (1)
 #1

Introduction

I am the author of the Kryptofranc ... you will hear about them very soon. https://kryptofranc.com
I have spent the time to adapt the latest Bitcoin Core development to my own fully functional blockchain and on the way of doing it, I have found that a LOT of things in the previous guides posted on the net were lacking of update or were totally obsolete.
Therefore, I have decided to update these guides to my own sauce, and I hope it will save time for the newbies, and update the legendary programmers to the latest roadblocks the Bitcoin core team have left for us recently.


1) Choice of Bitcoin Core 0.18 (mostly still works with 0.20)
This is the most updated and dynamic development out there. Almost all the good ideas from other coins are ending up in the Bitcoin core source one day or another, and usually with a better implementation.
Take Sigwit, pruning, HD address, privacy, lightning network; Bitcoin Core does it all.
However, the Bitcoin core team seems to try to make it impossible to create an alt coin from their core, by removing the solo mining first, then the RPC mining, and by adding plethora of tests for “security” but that are blocking new coins to mine when they are at the genesis state.
This guide will sort out all these problems.
2) Do not expect it to be easy.
Many people around are offering alt coin based on templates. First, be careful as a Trojan can be hidden very easily and you might lose all your work if you deal with the wrong people. Then most of the time they are using outdated versions of Bitcoin core, Litecoin that is based on outdated Bitcoin core, Dash that is based on outdated Bitcoin core etc… basically, they are using a version with solo-mining or RPC mining enabled, avoiding the real problems. If you are doing that, you are going to get an obsolete coin that will never be trusted, and it is just a matter of time until investors realize that, and sell.
3) Do not blame me for errors
If you find an error, tell me and I will fix it. Let us collaborate. I am writing this guide quickly, it is a complex subject so, be kind and complete the missing points if you find some.
4) Give credit to this page with a link if you copy this post to your blog.


Setting Up

a)   You will need two Unix instances to create a functional coin that will also mine.
Server 1: Mining wallet and development server.
Server 2: Second node and receiving wallet.
I suggest purchasing a dedicated server at Hetzner. Their auctions have the best value for the price (I am not related to them, you can use any ISP) : https://www.hetzner.com/sb
For 21 Eur you can get a 9000 Benchmark server. Don’t take an Atom that will take forever to compile. Get 2 instances for about 42 Eur.

b)   Get an account at Github, and fork the latest Bitcoin core version (0.18 here).

c)   Install the latest Ubuntu on both servers. Install Mate to have a graphic interface that is fast. Do that on both servers.
Code:
sudo apt install ubuntu-mate-desktop

and XRDP
Code:
sudo apt install xrdp
sudo systemctl enable xrdp
Now you can login with Remote Desktop from your local windows.
Install Clion to edit your C++ code with ease. You get 1 month free, enough for your development. This development tool is worth every penny, specially for its search that will save you a lot of time.
   
Code:
https://www.jetbrains.com/clion/download/#section=windows

d)   On server 1 install Yiimp by using this script: https://github.com/xavatar/yiimp_install_scrypt_ubuntu18.04 or use my backup on my repository, it is working and clean https://github.com/NicolasChoukroun/yiimp_install_scrypt_ubuntu18.04
Also be cautious, some people are offering to install Yiimp for you but they also install a backdoor and get a fee from every mining, I got this problem and I had to do everything myself to get rid of it. So beware the “services”. Do it yourself!
Now you are ready to modify Bitcoin Core to your flavor, do it on server 1. Server 2 will compile the result and run a second node when you have finished.
Yiimp will be used to mine the coin, do your premine and also as a block explorer.


Bitcoin Core modifications.

a)   Directory structure.
Use this structure.
Yourcoin/Yourcoincore/
In /Yourcoin/ put everything that needs to be out of the Bitcoin Core source code, your scripts, assets, pictures, translation scripts etc…
In /Yourcoin/Yourcoincore/ dump the Bitcoin source code that you have forked
Save that result to your own GitHub so that when you make a mess, you can clone and start again.
You can also use this script to automatically compile your coin and the dependencies. Note that this script solves some compilation issues for windows that many seems to be unaware of.
https://github.com/NicolasChoukroun/BitcoinMaker
Usage is included in the script just run ./maker.sh and see.
At this point, you need to compile Bitcoin: https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
Or
Code:
./maker.sh unix install
./maker.sh unix all

Don’t go further until Bitcoin is launching on your machine.

b)   Creation of the certificates (optional)
You can keep the Bitcoin certificates, but it is better to have your own for the strength of your blockchain.
Code:
openssl ecparam -genkey -name secp256k1 -text -noout -outform DER | xxd -p -c 1000 | sed 's/41534e31204f49443a20736563703235366b310a30740201010420/PrivKey: /' | sed 's/a00706052b8104000aa144034200/\'$'\nPubKey: /'


Replace the result in chainparams.cpp here:
Code:
const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;

And change your passphrase here with what you want:

Code:
const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
Remember to keep it short, I think that the length is limited to 150 characters, so do not write a book or you will get an error.

c)   Creation of the genesis.
In order to have your own blockchain, you need to have your own genesis. This step is explained in many tutorials; it should not be a problem.

I have made my own function based on what I have found in another altcoin, you can get the code here:
https://github.com/NicolasChoukroun/altcoin-genesis

You need to copy the code as explained in the readme and you will get the nTime, nNone, nBits, Hash and Merkle Root (inverted).

You can now replace these in chainparams.cpp, in 3 places, in “main”, “testnet” and “regnet”.

Code:
	genesis = CreateGenesisBlock(nTime, nNonce, 0x1d00ffff, 1, 50 * COIN);

Also change the asserts with the Hash and Merkle Root you got from the genesis. Do it 3 times for main, testnet and regnet.

Code:
assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
        assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));

Compile and run the wallet, see if you get an assert error. If you have, you made a typo.

d)   Change all Bitcoin core mentions with your altcoin name.
This is tricky as Bitcoin is all over the place. I cannot help too much; I personally use PHP to do it. You need to scan all the files with conditions to avoid replacing code. Show your scripting skills here.

e)   Change the graphics
/src/qt/res/ there are icons and graphics, replace them with the one from yourcoin.

f)   Customize chainparams.cpp
This file has things to change to personalize your coin, so I will make a list to get this done quickly. Read the comments in the following code.

Code:
// change all the pchMessageStart with something else, so that your messages are unique.
pchMessageStart[0] = 0xf9;
pchMessageStart[1] = 0xbe;
pchMessageStart[2] = 0xb4;
pchMessageStart[3] = 0xd9;

// change the default port, choose one port that is not used by another popular prog like ftp, or emails. Choose a different port for main,testnet and regnet.
nDefaultPort = 8333;

// change this to this value so that the consensus will accept your low difficulty mining at starting.
consensus.nMinimumChainWork = uint256S("0000000000000000000000000000000000000000000000000000000100010001");

// start all the PIB from height 1, so change these to 1
consensus.BIP34Height = 1;
consensus.BIP65Height = 1;
consensus.BIP65Height = 1;

// change the hash of BIPs to your genesis hash (see the genesis section) ??? is your genesis hash
// do it for main, testnet and regnet.
consensus.BIP16Exception = uint256S("0x???");
consensus.BIP34Hash = uint256S("0x???");

// fix the checkpoint data with your genesis hash, do it for main,testnet and regnet
checkpointData = {{{0, uint256S("0x???")},}};

// empty ChainTxData like this
chainTxData = ChainTxData{};

// you can change how often the wallet will retarget the difficulty.
consensus.nPowTargetTimespan =   14 * 24 * 60 * 60; // two weeks

// you can change the target for coin generation; bitcoin is 10 minutes, litecoin 2.5 minutes. Short means quicker transactions, but also more risk of orphan and failed transactions due to network issues.
// Also the faster, the more inflation, take this in account when you calculate your max coin generation, and rates.
consensus.nPowTargetSpacing = 10*60;

// blockchain size: your blockchain is very small; change this parameter to 1 so that it will not ask too much space at starting.
m_assumed_blockchain_size = 1; // was 240

// comments all the vSeeds, and change that to your server 1 and server 2 address since they will run the wallet and need to be peer to each other to get your coin to be functional.
vSeeds.emplace_back("seed.bitcoin.sipa.be");
vSeeds.emplace_back("dnsseed.bluematt.me");

// change the prefixes to your coin. If your coin is named Yourcoin for example you want that prefix to be Y
// prefixes are not that obvious, check https://en.bitcoin.it/wiki/List_of_address_prefixes
// to understand how prefixes are calculated
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);

// change this to something of your own
bech32_hrp = "bc"; // change to yc for yourcoin for example?

That’s it for chainparams.cpp. Remember to do these changes for all the networks, main, testnet and regnet

g)   Customize validation.cpp
Mostly validation deals with subsidy and validity checks. Subsidy defines how many coins are created when the proof of work submitted by a miner is accepted. This is the reward formula. This is where you will do your premine.
There are some traps not to fall into here. nSubsidy is a CAmount (int64_t), it is not a float. So be sure that with your calculation, you will not have a divide by zero!

Here is an example that is functioning. Note the +1 to avoid having 0 divides. I also add a debug to console so that the subsidy can be witnessed from the console.

In that code, you can see that we premine 120000 coins to 6 wallets. The method is as follow.
At height 10, 50, 70, 90, 110 and 130 we will mine 20000 coins. The blocks in between are here to allow the time to get the mined coins to maturity, then send the coins from server1 wallet to server2 wallet, then mine more to allow the transaction to be confirmed. Once this done you can encrypt the server2 wallet, backup it, remove the .yourcoin directory and restart the wallet with a fresh new address
This way you can premine and save in different wallet to distribute to your team, friends, investors.
Once the premine is done, the script will delivers 63/halfing coins every coin mined.
Note that this algorithm is not waiting 2 years to adjust like Bitcoin, it adjust every coin mined. You might change it to your liking.

Code:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams) {
    CAmount nSubsidy;
    if (nHeight == 10 || nHeight == 50 || nHeight == 70 || nHeight == 90 || nHeight == 110 || nHeight == 130)  {
        nSubsidy = 20000*COIN;   // premine 6x20000 coins
    } else {
        if (nHeight <= 150) {
            nSubsidy = 10 * COIN ;  // small mining to carry out the transactions
        } else {
            float year= (nHeight / 210240)+1; // avoid to get a negative nSubsidy
            float halfing =  year/ 1.618033988750;
            nSubsidy = (63 / halfing)*COIN;
        }
    }
    printf("GetBlockSubsidy: height: %i - nSubsidy: %ld \n",nHeight, nSubsidy);
    return nSubsidy;

}

Validation.cpp is not finished yet. We have a problem with SEGWIT. It cannot work at height 1. So in the beginning, we need to disable some checks, that will have to be re-enabled when the blockchain has at least 2000 blocks mined. You have to experiment here; the goal of this tutorial is not to deal with the blockchain maintenance.

bool IsWitnessEnabled needs to return true in all cases. So just add return true; at the beginning of the function.

IsNullDummyEnabled has the same problem, do the same to that function.

Find this “return state.DoS(100, false, REJECT_INVALID, "bad-cb-height", false, "block height mismatch in coinbase");” and comment it.

End of the validation.cpp customization.

h)   Other code modifications.
There are more modifications, spread everywhere that needs to be fixed in order to get the coin to work correctly.

validation.h  :
-   you need to change the DEFAULT_MAX_TIP_AGE to something very large (60*60*24*365 for example). This is temporary. This is the interval when the blockchain is not mining. At starting you might have a genesis made long time ago, and not have mined for a while, so that this has to be changed or your Coin will not work.
-   DEFAULT_CHECKPOINTS_ENABLED = true; needs to be changed to false, or your coin will try to verify that you are on the Bitcoin blockchain, which you are not.

\rpc\mining.cpp :
Another SEGWIT test that needs to be removed:

Code:
throw JSONRPCError(RPC_INVALID_PARAMETER, "getblocktemplate must be called with the segwit rule set (call with {\"rules\": [\"segwit\"]})");
Comment this line.

net_processing.cpp :
-   STALE_CHECK_INTERVAL need to be changed to a large value to avoid having a STALE error, this is again temporary, once the blockchain is mined by many people, it can be back to the original values. (3600*24*365 for example)
-   STALE_RELAY_AGE_LIMIT same for this static variable.

\qt\bitcoingui.cpp
Get rid of the loading form set this variable to 0.

Code:
qint64 secs = blockDate.secsTo(currentDate);
becomes qint64 secs=0;

Now you should have a functional Coin. But you need to mine.


------------------------------------------------------------------------------------------------------------------------------------------

Mining with stratum and Yiimp


a)   Modification of stratum.
In order to mine your coin, you need to use Yiimp that you have installed previously.
But the latest version won’t work with a “virgin” coin at block zero so here is how to fix that.
First, you need to setup your coin by following this tutorial:
https://www.boostrend.com/2018/03/how-to-setup-new-coin-wallet-on-pool.html

The most important things are:
-   Run your coin wallets by using the code given in the coin settings of Yiimp, but don’t forget to change the path since the installation script install stratum in /var/stratum. blocknotify=/var/stratum/blocknotify pool.kryptofranc.net:3333 1455 %s
for example is what is working for me.
-   Run your coin by using the following command line: yourcoin-qt –deprecatedrpc=accounts -printtoconsole
-   Type getnewaddress in the console on server1: enter this address everywhere an address is asked in the coin definition of Yiimp backend.
-   Compile and run your coin on server2
-   Type getnewaddress in the console of server2 to get an address to send to from the mining wallet.
-   Download ccminer (version 230 is working for me) for windows and edit a config file to match your coin definition, for example: ccminer.exe -a bitcoin -o stratum+tcp://pool.yourcoin.com:3333 -u xxxyourserver2addressxxx -p c=KYF
replace xxxyourserver2addressxxx with the address you got from your server2.
-   Run stratum on server1 (/var/stratum/run.sh sha)
If ccminer cannot mine, then you can use my fixed version here: https://github.com/NicolasChoukroun/stratum
Use it at your own risk, it is working for me, but who knows?
What needs to be fixed in Stratum is in coind.cpp function coind_can_mine, there are several tests of (!coind->height) which are not working for us since we are at block 0. This needs to be changed to

Code:
If (!coind->height)
// change to
if (coind->height<0)

My version also adds a lot of real-time comments to help debug stratum.
The coin must be set to auto ready, enabled, and difficulty must be >0

Mission accomplished! Now you have a fully working coin, which can mine though stratum.

------------------------------------------------------------------------------------------------------------------------------------------

DISCLAIMER
This tutorial may contain technical or typographical errors.
I do not guarantee its accuracy, completeness, or suitability.
IN NO EVENT SHALL I BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES RELATING TO THIS TUTORIAL, FOR ANY USE OF THIS TUTORIAL.
I take no responsibility and makes no warranty whatsoever from the use of this tutorial linked to or from this tutorial.
IT IS DELIVERED ** AS IS **.
ANYONE USING THIS TUTORIAL IS DOING IT AT HIS/HER OWN RISKS.


Fatunad
Sr. Member
****
Offline Offline

Activity: 2296
Merit: 360


View Profile
April 21, 2019, 05:39:19 AM
 #2

How are you related to this thread? https://bitcointalk.org/index.php?topic=3345808.0 . Same topic title and same template and by the way i do appreciate your effort on posting it up
on creating a new altcoin but im not really fully agree that these tutorials would be post up yet there are people who would just tend to make use of this tut and create his own shitcoins piling up on
the entire market.
TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
April 21, 2019, 05:49:55 AM
 #3

I am not related to the 2018 tutorial at all.
Bitcoin has changed with version 0.17 and a lot of problems are not published anywhere.
Making a coin ask some programming knowledge. Even if you are using a tutorial, you cannot do a functionnal coin without understanding what you are doing.
It is like an IQ test of some sort.
But I have been blocked by stupid issues that I would have loved to find a solution online. Debuging peer to peer is really complex, and some bugs do not give you any clue about where they are coming from.
For example when a transaction is flagged by a peer, but not by another peer!

So I guess this tutorial removes the obvious mistakes, but you have to be sharp to get to the final line. Smiley

How are you related to this thread? https://bitcointalk.org/index.php?topic=3345808.0 . Same topic title and same template and by the way i do appreciate your effort on posting it up
on creating a new altcoin but im not really fully agree that these tutorials would be post up yet there are people who would just tend to make use of this tut and create his own shitcoins piling up on
the entire market.

Fatunad
Sr. Member
****
Offline Offline

Activity: 2296
Merit: 360


View Profile
April 21, 2019, 05:57:56 AM
 #4

I am not related to the 2018 tutorial at all.
Bitcoin has changed with version 0.17 and a lot of problems are not published anywhere.
Making a coin ask some programming knowledge. Even if you are using a tutorial, you cannot do a functionnal coin without understanding what you are doing.
It is like an IQ test of some sort.
But I have been blocked by stupid issues that I would have loved to find a solution online. Debuging peer to peer is really complex, and some bugs do not give you any clue about where they are coming from.
For example when a transaction is flagged by a peer, but not by another peer!

So I guess this tutorial removes the obvious mistakes, but you have to be sharp to get to the final line. Smiley

How are you related to this thread? https://bitcointalk.org/index.php?topic=3345808.0 . Same topic title and same template and by the way i do appreciate your effort on posting it up
on creating a new altcoin but im not really fully agree that these tutorials would be post up yet there are people who would just tend to make use of this tut and create his own shitcoins piling up on
the entire market.
Okay that cleared out my mind and also i fully agree into this point you said on OP.

Quote
Many people around are offering alt coin based on templates. First, be careful as a Trojan can be hidden very easily and you might lose all your work if you deal with the wrong people. Then most of the time they are using outdated versions of Bitcoin core, Litecoin that is based on outdated Bitcoin core, Dash that is based on outdated Bitcoin core etc… basically they are using version with solo-mining or RPC mining enabled, avoiding the real problems. If you are doing that, you are going to get an obsolete coin that will never be trusted, and it is just a matter of time until investors realize that, and sell.

Common mistake to be missed out.

Im not really knowledagable on programming skills but i do have some sort of idea which i can still possibly follow up those things being post up above thats why i appreciate it.
Judge-Dredd
Sr. Member
****
Offline Offline

Activity: 517
Merit: 257


CryptoTalk.Org - Get Paid for every Post!


View Profile
April 21, 2019, 09:46:10 PM
 #5

Nice little guide but dangerous!! Here comes some more crap in the announcement section  Wink

 
                                . ██████████.
                              .████████████████.
                           .██████████████████████.
                        -█████████████████████████████
                     .██████████████████████████████████.
                  -█████████████████████████████████████████
               -███████████████████████████████████████████████
           .-█████████████████████████████████████████████████████.
        .████████████████████████████████████████████████████████████
       .██████████████████████████████████████████████████████████████.
       .██████████████████████████████████████████████████████████████.
       ..████████████████████████████████████████████████████████████..
       .   .██████████████████████████████████████████████████████.
       .      .████████████████████████████████████████████████.

       .       .██████████████████████████████████████████████
       .    ██████████████████████████████████████████████████████
       .█████████████████████████████████████████████████████████████.
        .███████████████████████████████████████████████████████████
           .█████████████████████████████████████████████████████
              .████████████████████████████████████████████████
                   ████████████████████████████████████████
                      ██████████████████████████████████
                          ██████████████████████████
                             ████████████████████
                               ████████████████
                                   █████████
CryptoTalk.org| 
MAKE POSTS AND EARN BTC!
🏆
Patarawan
Newbie
*
Offline Offline

Activity: 8
Merit: 1


View Profile
June 29, 2019, 11:06:54 AM
 #6

Most complete and updated guide I have found so far... kudo on the job mate.
Ken_terrance
Member
**
Offline Offline

Activity: 574
Merit: 18

Making Smart Money Work


View Profile
June 29, 2019, 11:29:00 AM
 #7

This is a very good tutorial that shouldn't get to the wrong hands ,youve just given those who wants to scam but don't know how a chance and I bet many crap project will be released in the announcement section soon ,I have no reason to create new altcoin when i have nothing to offer im here to invest in very good altcoins only but thanks

▬▬▬▬▬▬▬▬▬▬▬  ▬▬  ▬   Prasaga   │   Making Smart Money Work   ▬  ▬▬  ▬▬▬▬▬▬▬▬▬▬▬
Tech WP  /  Commercial WP  //  Twitter  /  Facebook  /  Discord  /  Telegram
▬▬▬▬▬▬▬▬▬▬▬▬▬  ▬▬▬▬  Powered by BOUNTY DETECTIVE  ▬▬▬▬  ▬▬▬▬▬▬▬▬▬▬▬▬▬
m4acker
Newbie
*
Offline Offline

Activity: 24
Merit: 3


View Profile
July 22, 2019, 10:04:07 PM
Last edit: July 23, 2019, 08:14:08 PM by m4acker
 #8

Brilliant guide. thank you. I learned a lot !

I wondered if you could point me in the direction of a solution for my only major hurdle...

When using Yiimp, no matter if its on an Azure VPS in France with all ports set up, or an Ubuntu server on my home network, I cannot seem to get the new coin wallet to "connect" to a Yiimp wallet.

Beneath the Difficulty/ Blocks / Balance .. I get "ERROR Connection timed out after 20000 milliseconds"


Coin config correct with rpc data + server/daemon/listen=1 and definitely restarted and running daemon with 'deprecatedrpc=accounts -printtoconsole'

Also - when I run the stratum script with sha config I get a "dead lock" error loop:

20:46:40: 2019-07-22 starting stratum for sha256 on ubuntuserver18:3333
20:47:17: 2019-07-22 sha256 dead lock, exiting...

Am I missing something super Obvious!? The web server works well and wallets all connect perfectly so the network is good.


nevermind I found out bitcoin 18.99 has many reasons why the stratum part will not work well with yamp.
I'm going to clone bitcoin 16 and start over which I think will work better.
Thanks again for this brilliant guide.
TheRidDlerX
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
August 08, 2019, 08:04:43 PM
 #9

Very nice guide OP thank you. I was wondering if you perhaps had any scripts that can generate the genesis for Litecoin? Struggling like mad to get the latest core of LTC going. Tried every code i could find but keeps giving assertion errors.

Thank you
Chemcrier
Copper Member
Newbie
*
Offline Offline

Activity: 154
Merit: 0

IMO Exchange - Customer First.


View Profile
August 17, 2019, 09:42:45 AM
 #10

The wonders of blockchain technology, anybody can just suddenly wake up and print money out of thin air and when they have the right connections and contacts, even get people to invest in it, a nice guild anyways, even if it might empower scammers.

───────────────    IMO Ecosystem    ───────────────
Customer First, Innovation from Everyone, Fair & Transparent
TELEGRAM  ]              J O I N   U S              [   TWITTER   ]
nokati
Full Member
***
Offline Offline

Activity: 312
Merit: 111



View Profile WWW
August 26, 2020, 05:38:21 AM
Last edit: August 27, 2020, 07:21:09 AM by nokati
 #11

Hi, I try to create a new alt from btc code to test couple of things, but somehow I am missing something. I think I can get the genessis block created as assert dont give me any error anymore but I still get the error below;
ERROR: ReadBlockFromDisk: Errors in block header at FlatFilePos(nFile=0, nPos=8)

I think that there is something about the nNonce or minimum difficulty that gets in the way.

benthach
Legendary
*
Offline Offline

Activity: 1764
Merit: 1000


View Profile WWW
August 26, 2020, 06:15:24 AM
 #12

or you can just use ark deployer, in a few clicks you would get a working blockchain/altcoin,
https://ark.io/deployer

soon it will just one click,
https://deployer.io/

reddit btcwriter1 - twitter kingpininvestor
nokati
Full Member
***
Offline Offline

Activity: 312
Merit: 111



View Profile WWW
August 26, 2020, 07:43:55 AM
 #13

or you can just use ark deployer, in a few clicks you would get a working blockchain/altcoin,
https://ark.io/deployer

soon it will just one click,
https://deployer.io/

And whats the point of doing that? I try to build, learn and test, not using some past&copy click & done chain. If you cant help with the code above, don’t bother spamming.

nokati
Full Member
***
Offline Offline

Activity: 312
Merit: 111



View Profile WWW
August 26, 2020, 08:40:04 AM
 #14

to give an update, this coode doesnt work on the latest bitcoin version;

hashGenesisBlock = uint256("0x01");
if (true && genesis.GetHash() != hashGenesisBlock)
        {
            printf("recalculating params for mainnet.\n");
            printf("old mainnet genesis nonce: %d\n", genesis.nNonce);
            printf("old mainnet genesis hash:  %s\n", hashGenesisBlock.ToString().c_str());
            // deliberately empty for loop finds nonce value.
            for(genesis.nNonce == 0; genesis.GetHash() > bnProofOfWorkLimit; genesis.nNonce++){ }
            printf("new mainnet genesis merkle root: %s\n", genesis.hashMerkleRoot.ToString().c_str());
            printf("new mainnet genesis nonce: %d\n", genesis.nNonce);
            printf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString().c_str());
        }


It gives erros;

TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
August 26, 2020, 09:26:43 AM
 #15

Use this to mine the genesis block

Code:
static void MineGenesis(CBlockHeader &genesisBlock, const uint256 &powLimit, bool noProduction) {
    if (noProduction) genesisBlock.nTime = std::time(nullptr);
    genesisBlock.nNonce = std::time(nullptr);

    printf("NOTE: Genesis nTime = %u \n", genesisBlock.nTime);
    printf("WARN: Genesis nNonce (BLANK!) = %u \n", genesisBlock.nNonce);

    arith_uint256 besthash;
    memset(&besthash, 0xFF, 32);
    arith_uint256 hashTarget = UintToArith256(powLimit);
    printf("Target: %s\n", hashTarget.GetHex().c_str());
    arith_uint256 newhash = UintToArith256(genesisBlock.GetHash());
    while (newhash > hashTarget) {
        genesisBlock.nNonce++;
        if (genesisBlock.nNonce == 0) {
            printf("NONCE WRAPPED, incrementing time\n");
            ++genesisBlock.nTime;
        }
        // If nothing found after trying for a while, print status
        if ((genesisBlock.nNonce & 0xffff) == 0)
            printf("nonce %08X: hash = %s target=%s \r",
                   genesisBlock.nNonce, newhash.ToString().c_str(),
                   hashTarget.ToString().c_str());

        if (newhash < besthash) {
            besthash = newhash;
            printf("New best: %s\n", newhash.GetHex().c_str());
        }
        newhash = UintToArith256(genesisBlock.GetHash());
    }
    printf("\nGenesis nTime = %u \n", genesisBlock.nTime);
    printf("Genesis nNonce = %u \n", genesisBlock.nNonce);
    printf("Genesis nBits: %08x\n", genesisBlock.nBits);
    printf("Genesis Hash = %s\n", newhash.ToString().c_str());
    printf("Genesis Hash Merkle Root = %s\n", genesisBlock.hashMerkleRoot.ToString().c_str());
    printf("Genesis Hash Merkle Root = %s\n", genesisBlock.hashMerkleRoot.ToString().c_str());
}

call like this

Code:
        genesis = CreateGenesisBlock(std::time(nullptr), 546521654, 0x1d00ffff, 1, 50 * COIN);
        MineGenesis(genesis, consensus.powLimit, true);

Then change the asserts with the merkel and hash generated by this algo. It will work on the latest version of Bitcoin core.

nokati
Full Member
***
Offline Offline

Activity: 312
Merit: 111



View Profile WWW
August 26, 2020, 10:37:26 AM
Last edit: August 27, 2020, 07:22:12 AM by nokati
 #16

Solved using another genesis creator script

nokati
Full Member
***
Offline Offline

Activity: 312
Merit: 111



View Profile WWW
August 27, 2020, 04:39:01 PM
Merited by xandry (2), TheWolf666 (1)
 #17

for the hash creation I finally got it using this script;
https://github.com/liveblockchain/genesisgen

Just remember to use Byteswapped as merkelhas! It toke me almst 2 days to find out what I was doig wrong Grin



I got finally the wallet running and adjusted all the other params... But need some info on the instructions mentioned below and would be great if you could give some explanations. I do program in php, python and java but not a C++ guru.. so bear with me Smiley

=========
Suggested:
// change the hash of BIPs to your genesis hash (see the genesis section) Huh is your genesis hash
// do it for main, testnet and regnet.
consensus.BIP16Exception = uint256S("0x???");
consensus.BIP34Hash = uint256S("0x???");

// fix the checkpoint data with your genesis hash, do it for main,testnet and regnet
checkpointData = {{{0, uint256S("0x???")},}};

Question: Do you mean the same hash that also should be used here;
        assert(consensus.hashGenesisBlock == uint256S("000000002737f91027590faddd70434f10ac4d0bc673f4134e2d7671ae7d7a86"));

or is it something else?

===========
Suggested: IsNullDummyEnabled has the same problem, do the same to that function.
Question: Cant find it?!! Is it in validation.cpp on the latest bitcoin version?

===========
Suggested:  Find this “return state.DoS(100, false, REJECT_INVALID, "bad-cb-height", false, "block height mismatch in coinbase");” and comment it.
Question: Cant find it?!! Is it in validation.cpp on the latest bitcoin version?

What I do find is this...

            return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-height", "block height mismatch in coinbase");

===========

TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
September 01, 2020, 07:50:04 AM
 #18

Suggested:
// change the hash of BIPs to your genesis hash (see the genesis section) Huh is your genesis hash
// do it for main, testnet and regnet.
consensus.BIP16Exception = uint256S("0x???");
consensus.BIP34Hash = uint256S("0x???");

=>  you are doing an altcoin so all the BIP should start at Genesis or very early (see my last answer). So, take the hash from your blockchain and yes it should be the same as the assert.

// fix the checkpoint data with your genesis hash, do it for main,testnet and regnet
checkpointData = {{{0, uint256S("0x???")},}};

=> go in your blockchain and add checkpointData = {{{blocknumber, uint256S("hash")},}}; as checkpoint so that if someone change the the blockchain on purpose, the wallets will reject the change. Do it periodically so that you solidify your blockchain against attackers.

===========
Suggested: IsNullDummyEnabled has the same problem, do the same to that function.
Question: Cant find it?!! Is it in validation.cpp on the latest bitcoin version?

=> this I do not understand.

===========
Suggested:  Find this “return state.DoS(100, false, REJECT_INVALID, "bad-cb-height", false, "block height mismatch in coinbase");” and comment it.
Question: Cant find it?!! Is it in validation.cpp on the latest bitcoin version?

What I do find is this...

            return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-height", "block height mismatch in coinbase");

=> the genesis block will shoot this error, so you need to comment it in order to have your wallet to mine, or you will not mine.
Also all similar errors due to SEGWITH security tests needs to be commented, at least for the first blocks. SEGWITH needs to check the block before, and there is none for the first blocks... it is impossible to start mining without commenting these.
then you can reinstall all the BIP tests that were blocking the mining, let say at block 1000 for example and change chainparams.cpp accordingly.



===========

Inkdull
Member
**
Offline Offline

Activity: 238
Merit: 10


View Profile
September 01, 2020, 07:55:02 AM
 #19

Thanks for this amazing post, im sure it will be useful for those who wants to know how to build their own projects, as for me I don't need it because I'm not qualified to be a blockchain developer or something close, I believe we will only see more scam projects from now on but I'm sure I can avoid getting scam.

▬▬▬▬▬▬▌   Vulcan Forged    ▐▬▬▬▬▬▬
▬▬▬▬▬▬▌    Telegram   ▌    Discord      ▌     Twitter      ▐▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬▬▬▬▬   DISCOVER   ▬▬▬▬▬▬▬▬▬▬▬▬▬▬
TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
September 01, 2020, 07:58:00 AM
 #20

Suggested:
// change the hash of BIPs to your genesis hash (see the genesis section) Huh is your genesis hash
// do it for main, testnet and regnet.
consensus.BIP16Exception = uint256S("0x???");
consensus.BIP34Hash = uint256S("0x???");

=>  you are doing an altcoin so all the BIP should start at Genesis or very early (see my last answer). So, take the hash from your blockchain and yes it should be the same as the assert.

// fix the checkpoint data with your genesis hash, do it for main,testnet and regnet
checkpointData = {{{0, uint256S("0x???")},}};

=> go in your blockchain and add checkpointData = {{{blocknumber, uint256S("hash")},}}; as checkpoint so that if someone change the the blockchain on purpose, the wallets will reject the change. Do it periodically so that you solidify your blockchain against attackers. Add many checkpoints as your blockchain grows, at block 1000, 10000, 50000, 100000, etc...

===========
Suggested: IsNullDummyEnabled has the same problem, do the same to that function.
Question: Cant find it?!! Is it in validation.cpp on the latest bitcoin version?

=> this I do not understand.

===========
Suggested:  Find this “return state.DoS(100, false, REJECT_INVALID, "bad-cb-height", false, "block height mismatch in coinbase");” and comment it.
Question: Cant find it?!! Is it in validation.cpp on the latest bitcoin version?

What I do find is this...

            return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-height", "block height mismatch in coinbase");

=> the genesis block will shoot this error, so you need to comment it in order to have your wallet to mine, or you will not mine.
Also all similar errors due to SEGWITH security tests needs to be commented, at least for the first blocks. SEGWITH needs to check the block before, and there is none for the first blocks... it is impossible to start mining without commenting these.
then you can reinstall all the BIP tests that were blocking the mining, let say at block 1000 for example and change chainparams.cpp accordingly.



===========


Pages: [1] 2 3 »  All
  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!