ScaleChain / scalechain

A customizable blockchain for altcoins.
236 stars 64 forks source link

Add regtest mode : sub issue of #146 #147

Open Kangmo opened 8 months ago

Kangmo commented 8 months ago

Integrate regtest mode with updated coin address magic value and enhanced block mining, incorporating support for hidden RPC commands like setmocktime.

This is a sub issue of #146 Implement Python-based End-to-End Testing for Wallet Functionality

Kangmo commented 8 months ago

The purpose of regtest mode for testing and test automation.

In summary:

  1. Users can create new blocks at their discretion, providing full control over the environment.
  2. A specific magic value is assigned for the coin address.
  3. Regtest mode supports hidden RPCs like setmocktime. https://bitcoinrpc.dev/26.0/hidden/setmocktime/

https://developer.bitcoin.org/examples/testing.html#regtest-mode

Kangmo commented 8 months ago

regtest mode tutorial

https://gist.github.com/System-Glitch/cb4e87bf1ae3fec9925725bb3ebe223a

Kangmo commented 8 months ago

Bitcoin chain parameters are described in the following file.

The following magic values are same for testnet and regtest.

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
        base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
        base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
        base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};

https://github.com/bitcoin/bitcoin/blob/master/src/kernel/chainparams.cpp