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)
raylearn
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
June 04, 2021, 05:22:18 AM
 #41

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.

Thanks for the tutorial, that's very helpful. I tried the MineGenesis() function (on windows 10) based on the latest bitcoin core. It's been running for more than 2+ hours but couldn't find the genesis block yet, I wonder if that is normal and roughly how long it'd take to mine the genesis block?
jonas bellaert
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
August 06, 2021, 12:13:50 AM
 #42

Hey,

I wanna help you guys by solving a problem,
If your confirmations are going to fast (sometimes x100 faster than blocks mined) than you have to lower the coin maturity, i still didn't find out why this is happening and i will soon test other coin maturity amounts, but i know 100 is not working proberly and 10 does.

after months of searching and trying things out i managed to get a good working coin on version 0.18.1 (windows included).
(thx TheWolf666 for helping me with the segwit and IsNullDummyEnabled problem that fixed the transactions that stay forever in memory pool Smiley
(For the people that come here for the same problem under here you can see a copy of a piece out of the tutorial to fix this problem

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.

Greetings,
Jonas Bellaert
dafa_ce
Newbie
*
Offline Offline

Activity: 10
Merit: 0


View Profile
August 16, 2021, 06:57:55 AM
 #43

Hi

Was wondering if anyone has come across this error before when running the getblocktemplate method

error -10: bitcoin is downloading blocks...

I cant seem to get past this error. Has anyone ever experienced anything similar? Any suggestions welcomed.

Thanks

Toki.Fujinami
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile
September 23, 2021, 10:26:31 AM
 #44

Hello
i hope you can help me
i cloned a coin bitcoinpos,all is ok,block genesis generated but i can't mine pow blocks,i tried with generatetoaddress also setting a pool,nothing,what i do?
--------------------------------------------------
class CMainParams : public CChainParams {
public:
    CMainParams() {
        strNetworkID = CBaseChainParams::MAIN;
        consensus.signet_blocks = false;
        consensus.signet_challenge.clear();
        consensus.nSubsidyHalvingInterval = 2200000;
        consensus.BIP16Exception = uint256S("0x00000bcd2d9ccbb28606a8b2d962b97394f612bf6e021ce1d64d71cecb008029");
        consensus.BIP34Height = 1;
        consensus.BIP34Hash = uint256S("0x00000b3b403a2b37780a8dc3813e02463cbaceab135efffe4aaacf0446f862d5");
        consensus.BIP65Height = 1;
        consensus.BIP66Height = 1;
        consensus.CSVHeight = 1;
        consensus.SegwitHeight = 1;
        consensus.MinBIP9WarningHeight = consensus.SegwitHeight + consensus.nMinerConfirmationWindow;
        consensus.BPSRewardMatchStep = 6000;
        consensus.BPSRewardMatchHeight = 3 * consensus.BPSRewardMatchStep;
        consensus.BPSDiffAdjHeight = 13000;
        consensus.BPSColdStakeEnableHeight = 26000;
        consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.posLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 10 * 1 * 60; // every 10 blocks
        consensus.nPowTargetSpacing = 1 * 60;
        consensus.fPowAllowMinDifficultyBlocks = false;
        consensus.fPowNoRetargeting = false;
        consensus.fPoSNoRetargeting = false;
        consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
        consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
        consensus.nLastPOWBlock = 5000;
        consensus.nMPoSRewardRecipients = 10;
        consensus.nFirstMPoSBlock = consensus.nLastPOWBlock +
                                    consensus.nMPoSRewardRecipients +
                                    COINBASE_MATURITY;
        consensus.nLastMPoSBlock = consensus.BPSColdStakeEnableHeight;
        consensus.nEnableHeaderSignatureHeight = 0;
        consensus.nCheckpointSpan = COINBASE_MATURITY;
        consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
        consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
        consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008

        // Deployment of Taproot (BIPs 340-342)
        consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
        consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 1199145601; // January 1, 2008
        consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1230767999; // December 31, 2008

        consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001"); //block 1
        consensus.defaultAssumeValid = uint256S("0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); //block 1
Toki.Fujinami
Newbie
*
Offline Offline

Activity: 25
Merit: 1


View Profile
September 24, 2021, 01:01:51 PM
 #45

How are you mining? via generatetoaddress or a miner?

hi can you help me? Same issue
liorko87
Newbie
*
Offline Offline

Activity: 29
Merit: 6


View Profile
September 29, 2021, 06:39:55 AM
 #46

@Toki.Fujinami which software are you using in order to mine?
thebest866
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
November 11, 2021, 11:27:12 PM
Last edit: November 12, 2021, 10:47:22 AM by thebest866
 #47

hi guys,
I'm having a weird issue, sometimes it would confirm transactions and sometimes it wouldn't, I don't understand the issue here, I saw the guide I followed that but I got other issues however I switched back to my original source code. I'm using Litecoin latest code

check this screenshot and check the timestamp, many blocks were mined and the number is incrementing and those are still in mempool



Image link https://ibb.co/nkBpZzM

quasimotoca
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
January 06, 2022, 03:01:28 PM
 #48

Has anyone given this a shot with the latest Bitcoin repo? (22.x) I'm going to dive in shortly and report back.....
BlockM
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
January 07, 2022, 09:37:16 AM
 #49

Lets do it together. i just starting to new own bitcoin on v22.

Has anyone given this a shot with the latest Bitcoin repo? (22.x) I'm going to dive in shortly and report back.....
Snipez
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
January 04, 2023, 09:11:32 PM
 #50

Hello everyone.

I am moving my older alt-coin from bitcoin core 9.0 to bitcoin core 13.0.

I have everything I can think of done, but I seem to be missing one thing.

If anyone can help, it would be greatly appreciated!

Here is the error that I am getting.

Run the wallet, get the following :
bitcoin-qt: main.cpp:1856: void InvalidChainFound(CBlockIndex*): Assertion `tip' failed.
Aborted (core dumped)

Debug log shows this :

2023-01-04 21:00:11 ERROR: ConnectBlock: Consensus::CheckBlock: high-hash, proof of work failed (code
16)
2023-01-04 21:00:11 InvalidChainFound: invalid block=000005232c6fe11ca78e898bcd61a031b461dee02ef950dae
74423c3fcbd8e69  height=0  log2_work=20.000001  date=2018-05-31 20:33:34

Now, this IS the genesis block that was created on the 9.0 version.


Any help would be greatly appreciated!

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!