2

I have modified bitcoin source code for my altcoin. I have successfully created genesis block, merkel root, noonce and daemon is working well. I have tweaked number of coins per day, total coins etc.. I have also set the bitcoin.conf to server=1, regtest=1 with rpc user and password.

Now i am following the bitcoin CLI tutorial to create first 101 blocks, but it only creates 1 block instead of 101 blocks.

https://bitcoin.org/en/developer-examples#testing-applications

The problem is using the CLI, when i generate 100 blocks only one block is created why?

Here is my chainparams.cpp (clipped code)

/**
 * Regression test
 */
class CRegTestParams : public CChainParams {
public:
    CRegTestParams() {
        strNetworkID = "regtest";
        consensus.nSubsidyHalvingInterval = 150;
        consensus.BIP16Height = 0; // always enforce P2SH BIP16 on regtest
        consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
        consensus.BIP34Hash = uint256();
        consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
        consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
        consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
        consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
        consensus.nPowTargetSpacing = 10 * 60;
        consensus.fPowAllowMinDifficultyBlocks = true;
        consensus.fPowNoRetargeting = true;
        consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
        consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)[/code]

and in the commanline, it is executing only one block.

./bitcoin-cli -regtest generate 101
[
  "179ef1bb855aed3d01324e6eff17ce63773b3ae79a0e123bfdf7f5d11cad0360"
]

and the output (clipped)

 ./bitcoin-cli -regtest getblockchaininfo
    {
      "chain": "regtest",
      "blocks": 4,
      "headers": 4,
      "bestblockhash": "179ef1bb855aed3d01324e6eff17ce63773b3ae79a0e123bfdf7f5d11cad0360",
      "difficulty": 4.656542373906925e-10,
      "mediantime": 1516037681,
      "verificationprogress": 1,
      "initialblockdownload": false,
      "chainwork": "0000000000000000000000000000000000000000000000000000000100010009",
      "size_on_disk": 1551,
      "pruned": false,
      "softforks": [
        {
          "id": "bip34",
          "version": 2,
          "reject": {
            "status": false
          }

What is preventing creating 101 blocks?

I am seeing this in debug.log

2018-01-16 20:40:30 Bitcoin version v0.15.99.0-45173fa6f-dirty
2018-01-16 20:40:30 InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2018-01-16 20:40:30 Assuming ancestors of block 0000000000000000003b9ce759c2a087d52abc4266f8f4ebd6d768b89defa50a have valid signatures.
2018-01-16 20:40:30 Setting nMinimumChainWork=000000000000000000000000000000000000000000723d3581fe1bd55373540a
2018-01-16 20:40:30 Using the 'sse4' SHA256 implementation
2018-01-16 20:40:30 Using RdRand as an additional entropy source
2018-01-16 20:40:30 Default data directory /Users/prabhubalakrishnan/Library/Application Support/Bitcoin
2018-01-16 20:40:30 Using data directory /Users/prabhubalakrishnan/Library/Application Support/Bitcoin
2018-01-16 20:40:30 Using config file /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/bitcoin.conf
2018-01-16 20:40:30 Using at most 125 automatic connections (283 file descriptors available)
2018-01-16 20:40:30 Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2018-01-16 20:40:30 Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2018-01-16 20:40:30 Using 4 threads for script verification
2018-01-16 20:40:30 scheduler thread start
2018-01-16 20:40:30 HTTP: creating work queue of depth 16
2018-01-16 20:40:30 Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.
2018-01-16 20:40:30 HTTP: starting 4 worker threads
2018-01-16 20:40:30 Using wallet directory /Users/prabhubalakrishnan/Library/Application Support/Bitcoin
2018-01-16 20:40:30 init message: Verifying wallet(s)...
2018-01-16 20:40:30 Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2018-01-16 20:40:30 Using wallet wallet.dat
2018-01-16 20:40:30 CDBEnv::Open: LogDir=/Users/prabhubalakrishnan/Library/Application Support/Bitcoin/database ErrorFile=/Users/prabhubalakrishnan/Library/Application Support/Bitcoin/db.log
2018-01-16 20:40:30 Cache configuration:
2018-01-16 20:40:30 * Using 2.0MiB for block index database
2018-01-16 20:40:30 * Using 8.0MiB for chain state database
2018-01-16 20:40:30 * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
2018-01-16 20:40:30 init message: Loading block index...
2018-01-16 20:40:30 Wiping LevelDB in /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/blocks/index
2018-01-16 20:40:30 Opening LevelDB in /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/blocks/index
2018-01-16 20:40:30 Opened LevelDB successfully
2018-01-16 20:40:30 Using obfuscation key for /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/blocks/index: 0000000000000000
2018-01-16 20:40:30 Initializing databases...
2018-01-16 20:40:30 Wiping LevelDB in /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/chainstate
2018-01-16 20:40:30 Opening LevelDB in /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/chainstate
2018-01-16 20:40:30 Opened LevelDB successfully
2018-01-16 20:40:30 Wrote new obfuscate key for /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/chainstate: 58c6b9c1e6d24649
2018-01-16 20:40:30 Using obfuscation key for /Users/prabhubalakrishnan/Library/Application Support/Bitcoin/chainstate: 58c6b9c1e6d24649
2018-01-16 20:40:30  block index              38ms
2018-01-16 20:40:30 init message: Loading wallet...
2018-01-16 20:40:30 nFileVersion = 159900
2018-01-16 20:40:30 Keys: 1002 plaintext, 0 encrypted, 1002 w/ metadata, 1002 total
2018-01-16 20:40:30  wallet                   38ms
2018-01-16 20:40:30 setKeyPool.size() = 1000
2018-01-16 20:40:30 mapWallet.size() = 0
2018-01-16 20:40:30 mapAddressBook.size() = 2
2018-01-16 20:40:30 Reindexing block file blk00000.dat...
2018-01-16 20:40:30 UpdateTip: new best=00000000f81247b7a7fe3c913d1d4ca3e8534349639cf21d0a0ed45fad2582c5 height=0 version=0x00000001 log2_work=32.000022 tx=1 date='2018-01-08 16:25:32' progress=0.000000 cache=0.0MiB(0txo)
2018-01-16 20:40:30 mapBlockIndex.size() = 1
2018-01-16 20:40:30 nBestHeight = 0
2018-01-16 20:40:30 torcontrol thread start
2018-01-16 20:40:30 Bound to [::]:21600
2018-01-16 20:40:30 Bound to 0.0.0.0:21600
2018-01-16 20:40:30 init message: Loading P2P addresses...
2018-01-16 20:40:30 Loaded 1025 addresses from peers.dat  4ms
2018-01-16 20:40:30 init message: Loading banlist...
2018-01-16 20:40:30 init message: Starting network threads...
2018-01-16 20:40:30 net thread start
2018-01-16 20:40:30 dnsseed thread start
2018-01-16 20:40:30 addcon thread start
2018-01-16 20:40:30 init message: Done loading
2018-01-16 20:40:30 opencon thread start
2018-01-16 20:40:30 msghand thread start
2018-01-16 20:40:30 Loaded 1 blocks from external file in 208ms
2018-01-16 20:40:30 Reindexing finished
2018-01-16 20:40:30 Imported mempool transactions from disk: 0 succeeded, 0 failed, 0 expired, 0 already there
2018-01-16 20:40:41 Loading addresses from DNS seeds (could take a while)
2018-01-16 20:40:41 0 addresses found from DNS seeds
2018-01-16 20:40:41 dnsseed thread exit
 2018-01-17 15:45:56 Potential stale tip detected, will try using extra outbound peer (last tip update: 68726 seconds ago)
    2018-01-17 15:56:26 Potential stale tip detected, will try using extra outbound peer (last tip update: 69356 seconds ago)
    2018-01-17 16:06:56 Potential stale tip detected, will try using extra outbound peer (last tip update: 69986 seconds ago)
    2018-01-17 16:17:26 Potential stale tip detected, will try using extra outbound peer (last tip update: 70616 seconds ago)
    2018-01-17 16:27:56 Potential stale tip detected, will try using extra outbound peer (last tip update: 71246 seconds ago)
  • Can you post the contents of the debug.log file? – Andrew Chow Jan 16 '18 at 21:42
  • @AndrewChow Posted the debug.log – pbu Jan 17 '18 at 16:36
  • The section of debug.log you posted is completely useless. Post all of it. – Andrew Chow Jan 17 '18 at 18:18
1

Your generate command is wrong.

try: ./bitcoin-cli -regtest generate 101 -1

The -1 part means the daemon will continue attempting to generate blocks indefinitely until the amount of blocks, 101 have been generated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.