Création de sa propre cryptomonnaie basé sur Litecoin v0.15 : Cubecoin
Lien : https://www.hackster.io/pjdecarlo/how-to-make-a-cryptocurrency-using-litecoin-v0-15-source-fb5e82 Distribution de travail : Lubuntu 18.04
1/ Mise-à-jour du système d'exploitation.
util01@station01:~$ sudo apt-get update && sudo apt-get upgrade
2/ Installation des paquets de développement.
util01@station01:~$ sudo apt-get install build-essential git libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb-dev libdb++-dev libminiupnpc-dev libzmq3-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
3/ Installation de 'libdb4.8'.
util01@station01:~$ sudo add-apt-repository ppa:bitcoin/bitcoin util01@station01:~$ sudo apt-get update util01@station01:~$ sudo apt-get install -y libdb4.8-dev libdb4.8++-dev
4/ Création du répertoire de travail.
util01@station01:~$ mkdir CUBECOIN util01@station01:~$ cd CUBECOIN/ util01@station01:~/CUBECOIN$
5/ Téléchargement du code source de Litecoin.
util01@station01:~/CUBECOIN$ git clone https://github.com/litecoin-project/litecoin.git cubecoin
util01@station01:~/CUBECOIN$ cd cubecoin/ util01@station01:~/CUBECOIN/cubecoin$
6/ Récupération de la version 0.15.1.
util01@station01:~/CUBECOIN/litecoin$ git checkout tags/v0.15.1 util01@station01:~/CUBECOIN/litecoin$ git checkout -b v0.15.1
7/ Création de la branche 'cubecoin'.
util01@station01:~/CUBECOIN/cubecoin$ git checkout -b cubecoin
8/ Renommage de la monnaie : Litecoin en Cubecoin.
util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/Litecoin/Cubecoin/g" {} \; util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/LiteCoin/CubeCoin/g" {} \; util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/LTC/CC/g" {} \; util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/litecoin/cubecoin/g" {} \; util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/litecoind/cubecoind/g" {} \;
9/ Renommage du code la monnaie.
util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/lites/cubes/g" {} \; util01@station01:~/CUBECOIN/cubecoin$ find ./ -type f -readable -writable -exec sed -i "s/photons/atoms/g" {} \;
10/ Changement du 'numéro magic' dans les messages 'pch'.
http://www.asciitable.com/
c = 63 u = 75 b = 62 e = 65
Ouvrir :
src/chainparams.cpp
**Chercher :
line 104**
pchMessageStart[0] = 0xfb; pchMessageStart[1] = 0xc0; pchMessageStart[2] = 0xb6; pchMessageStart[3] = 0xdb;
Remplacer par :
pchMessageStart[0] = 0x63; pchMessageStart[1] = 0x75; pchMessageStart[2] = 0x62; pchMessageStart[3] = 0x65;
11/ Mise-à-jour de la valeur de 'base58Prefixes'.
https://en.bitcoin.it/wiki/List_of_address_prefixes
Decimal version Leading symbol Address length 28 C 34
Ouvrir :
src/chainparams.cpp
Chercher :
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,48); base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5); base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1,50); base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,176); base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
Remplacer par :
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,28); base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5); base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1,50); base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,28); base58Prefixes[EXT_PUBLIC_KEY] = {0xff, 0x88, 0xB2, 0x1E}; base58Prefixes[EXT_SECRET_KEY] = {0xff, 0x88, 0xAD, 0xE4};
util01@station01:~/CUBECOIN/cubecoin$ cd .. util01@station01:~/CUBECOIN$
12/ Installation de la dépendance pour GenesisH0.
util01@station01:~/CUBECOIN$ sudo apt install python-pip util01@station01:~/CUBECOIN$ sudo pip install scrypt construct==2.5.2
13/ Installation de GenesisH0.
util01@station01:~/CUBECOIN$ git clone https://github.com/lhartikk/GenesisH0.git
util01@station01:~/CUBECOIN$ cd GenesisH0/ util01@station01:~/CUBECOIN/GenesisH0$
14/ Récupération du timestamp actuel.
util01@station01:~/CUBECOIN/GenesisH0$ date +%s 1594148555
15/ Création du 'Genesis Block' et du 'Merkle Root' : 1ère passe.
util01@station01:~/CUBECOIN/GenesisH0$ python genesis.py -a scrypt -z "Blockchain for CubeCoin" -p "040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9" -t 1594148555 -n 2084524493
04ffff001d010417426c6f636b636861696e20666f722043756265436f696e algorithm: scrypt merkle hash: 75c043ef2b32fdb1625beb798e10f03561a07492809fc5021865fe342365c25f pszTimestamp: Blockchain for CubeCoin pubkey: 040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9 time: 1594148555 bits: 0x1e0ffff0 Searching for genesis hash.. 2539.0 hash/s, estimate: 469.9 hgenesis hash found! nonce: 2085137478 genesis hash: ef6cdb4ebe56effe9e0292470d3d4f42ac53f7e86091883f721d1f6838cba6f5
16/ Création du 'Genesis Block' et du 'Merkle Root' : 2ème passe.
util01@station01:~/CUBECOIN/GenesisH0$ python genesis.py -a scrypt -z "Blockchain for CubeCoin" -p "040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9" -t 1594148555 -n 2085137478
04ffff001d010417426c6f636b636861696e20666f722043756265436f696e algorithm: scrypt merkle hash: 75c043ef2b32fdb1625beb798e10f03561a07492809fc5021865fe342365c25f pszTimestamp: Blockchain for CubeCoin pubkey: 040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9 time: 1594148555 bits: 0x1e0ffff0 Searching for genesis hash.. genesis hash found! nonce: 2085137478 genesis hash: ef6cdb4ebe56effe9e0292470d3d4f42ac53f7e86091883f721d1f6838cba6f5
17/ Modification de 'chainparams.cpp' : Timestamp, Genesis Block, Merkle Root, nonce.
Ouvrir :
src/chainparams.cpp
**Chercher :
line 51**
const char* pszTimestamp = "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56";
Remplacer par :
const char* pszTimestamp = "Blockchain for CubeCoin";
**Chercher :
line 121**
genesis = CreateGenesisBlock(1317972665, 2084524493, 0x1e0ffff0, 1, 50 * COIN);
Remplacer par :
genesis = CreateGenesisBlock(1594148555, 2085137478, 0x1e0ffff0, 1, 50 * COIN);
**Chercher :
line 123**
assert(consensus.hashGenesisBlock == uint256S("0x12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2")); assert(genesis.hashMerkleRoot == uint256S("0x97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9"));
Remplace par :
assert(consensus.hashGenesisBlock == uint256S("0xef6cdb4ebe56effe9e0292470d3d4f42ac53f7e86091883f721d1f6838cba6f5")); assert(genesis.hashMerkleRoot == uint256S("0x75c043ef2b32fdb1625beb798e10f03561a07492809fc5021865fe342365c25f"));
Chercher :
# class CRegTestParams : public CChainParams genesis = CreateGenesisBlock( consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S(" assert(genesis.hashMerkleRoot == uint256S("
Remplace par :
genesis = CreateGenesisBlock(1594148555, 2085137478, 0x1e0ffff0, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0xef6cdb4ebe56effe9e0292470d3d4f42ac53f7e86091883f721d1f6838cba6f5")); assert(genesis.hashMerkleRoot == uint256S("0x75c043ef2b32fdb1625beb798e10f03561a07492809fc5021865fe342365c25f"));
**Chercher :
line 146**
checkpointData = (CCheckpointData) { { { 1500, uint256S("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967")}, { 4032, uint256S("0x9ce90e427198fc0ef05e5905ce3503725b80e26afd35a987965fd7e3d9cf0846")}, { 8064, uint256S("0xeb984353fc5190f210651f150c40b8a4bab9eeeff0b729fcb3987da694430d70")}, { 16128, uint256S("0x602edf1859b7f9a6af809f1d9b0e6cb66fdc1d4d9dcd7a4bec03e12a1ccd153d")}, { 23420, uint256S("0xd80fdf9ca81afd0bd2b2a90ac3a9fe547da58f2530ec874e978fce0b5101b507")}, { 50000, uint256S("0x69dc37eb029b68f075a5012dcc0419c127672adb4f3a32882b2b3e71d07a20a6")}, { 80000, uint256S("0x4fcb7c02f676a300503f49c764a89955a8f920b46a8cbecb4867182ecdb2e90a")}, {120000, uint256S("0xbd9d26924f05f6daa7f0155f32828ec89e8e29cee9e7121b026a7a3552ac6131")}, {161500, uint256S("0xdbe89880474f4bb4f75c227c77ba1cdc024991123b28b8418dbbf7798471ff43")}, {179620, uint256S("0x2ad9c65c990ac00426d18e446e0fd7be2ffa69e9a7dcb28358a50b2b78b9f709")}, {240000, uint256S("0x7140d1c4b4c2157ca217ee7636f24c9c73db39c4590c4e6eab2e3ea1555088aa")}, {383640, uint256S("0x2b6809f094a9215bafc65eb3f110a35127a34be94b7d0590a096c3f126c6f364")}, {409004, uint256S("0x487518d663d9f1fa08611d9395ad74d982b667fbdc0e77e9cf39b4f1355908a3")}, {456000, uint256S("0xbf34f71cc6366cd487930d06be22f897e34ca6a40501ac7d401be32456372004")}, {638902, uint256S("0x15238656e8ec63d28de29a8c75fcf3a5819afc953dcd9cc45cecc53baec74f38")}, {721000, uint256S("0x198a7b4de1df9478e2463bd99d75b714eab235a2e63e741641dc8a759a9840e5")}, } };
Remplacer par :
checkpointData = { { { 0, uint256S("0xef6cdb4ebe56effe9e0292470d3d4f42ac53f7e86091883f721d1f6838cba6f5")}, } };
**Chercher :
line 152**
chainTxData = ChainTxData{ // Data as of block 59c9b9d3fec105bdc716d84caa7579503d5b05b73618d0bf2d5fa639f780a011 (height 1353397). 1516406833, // * UNIX timestamp of last known number of transactions 19831879, // * total number of transactions between genesis and that timestamp // (the tx=... number in the SetBestChain debug.log lines) 0.06 // * estimated number of transactions per second after that timestamp };
Remplacer par :
chainTxData = ChainTxData{ // Data as of block 59c9b9d3fec105bdc716d84caa7579503d5b05b73618d0bf2d5fa639f780a011 (height 1353397). 1594148555, // * UNIX timestamp of last known number of transactions 0, // * total number of transactions between genesis and that timestamp // (the tx=... number in the SetBestChain debug.log lines) 0.0 // * estimated number of transactions per second after that timestamp };
18/ Modification de 'dnsseed'.
Ouvrir :
src/chainparams.cpp
**Chercher :
line 127**
vSeeds.emplace_back("seed-a.cubecoin.loshan.co.uk", true); vSeeds.emplace_back("dnsseed.thrasher.io", true); vSeeds.emplace_back("dnsseed.cubecointools.com", true); vSeeds.emplace_back("dnsseed.cubecoinpool.org", true); vSeeds.emplace_back("dnsseed.koin-project.com", false);
Remplacer par :
vSeeds.emplace_back("dnsseed.cubeco.in");
19/ Modification du consensus.
Ouvrir :
src/chainparams.cpp
**Chercher :
line 104**
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000002ee655bf00bf13b4cca");
Remplacer par :
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
20/ Modificatio du port.
util01@station01:~/CUBECOIN/litecoin$ find ./ -type f -readable -writable -exec sed -i "s/9333/9666/g" {} \;
21/ Renommage de la documentation.
util01@station01:~/CUBECOIN/litecoin$ cp doc/man/litecoin-cli.1 doc/man/cubecoin-cli.1 util01@station01:~/CUBECOIN/litecoin$ cp doc/man/litecoind.1 doc/man/cubecoind.1 util01@station01:~/CUBECOIN/litecoin$ cp doc/man/litecoin-qt.1 doc/man/cubecoin-qt.1 util01@station01:~/CUBECOIN/litecoin$ cp doc/man/litecoin-tx.1 doc/man/cubecoin-tx.1
22/ Configuration de la compilation, compilation et installation.
util01@station01:~/CUBECOIN/litecoin$ ./autogen.sh util01@station01:~/CUBECOIN/litecoin$ ./configure util01@station01:~/CUBECOIN/litecoin$ make util01@station01:~/CUBECOIN/litecoin$ sudo make install
util01@station01:~/CUBECOIN/litecoin$ cd
23/ Création du répertoire caché de configuration de 'cubecoin'.
util01@station01:~$ mkdir .cubecoin
24/ Création du fichier de configuration.
Ouvrir :
.cubecoin/cubecoin.conf
Ajouter :
`# Use as many addnode= settings as you like to connect to specific peers
addnode=192.168.1.200:9666
addnode=192.168.1.201:9666
JSON-RPC options (for controlling a running cubecoin/cubecoind process)
server=1 tells cubecoin-QT to accept JSON-RPC commands.
server=1
You must set rpcuser and rpcpassword to secure the JSON-RPC api
rpcuser=cubecoinrpc rpcpassword=mot2passe
How many seconds cubecoin will wait for a complete RPC HTTP request.
after the HTTP connection is established.
rpctimeout=30
By default, only RPC connections from localhost are allowed. Specify
as many rpcallowip= settings as you like to allow connections from
other hosts (and you may use * as a wildcard character):
rpcallowip=10.1.1.34
rpcallowip=192.168..
rpcallowip=1.2.3.4/255.255.255.0
rpcallowip=127.0.0.1
Set gen=1 to attempt to generate cubecoins
gen=1
Use SSE instructions to try to generate cubecoins faster.
4way=1
Pay an optional transaction fee every time you send cubecoins. Transactions with fees
are more likely than free transactions to be included in generated blocks, so may
be validated sooner.
paytxfee=0.001`
25/ Sur 3 nodes (== serveurs), lancement du daemon 'cubecoin'.
util01@station01:~$ cubecoind --printconsole
26/ Sur 2 ordinateurs : Lancement du porte-feuille (wallet) Cubecoin.
util01@station01:~$ cubecoin-qt -reindex

27/ Sur ces ordinateurs : Lancement du minage.
Ouvrir :
~/CUBECOIN/mine_cubecoin.sh
Ajouter :
#!/bin/bash echo "Mining... Press [CTRL+C] to stop" while : do cubecoin-cli generate 1 done
Action :
chmod +x mine_cubecoin.sh
util01@station01:~/CUBECOIN$ ./mine_cubecoin.sh
