Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitcoind have some problem when support regtest mode #38

Open
wanggeng01041454 opened this issue Sep 29, 2024 · 0 comments
Open

bitcoind have some problem when support regtest mode #38

wanggeng01041454 opened this issue Sep 29, 2024 · 0 comments

Comments

@wanggeng01041454
Copy link

bitcoin.conf 's content like this:

chain=regtest

txindex=1
server=1
rest=1

[regtest]
port=18444

rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcport=18443
rpcuser=bitcoin
rpcpassword=opcatAwesome
rpcworkqueue=2048
rpcthreads=32
rpcservertimeout=120

maxconnections=50

run bitcoind

and then , run bitcoin-cli -generate 1 to generate a block.

bitcoind print following log:
"""
2024-09-29T10:23:17Z ERROR: CheckProofOfWork : block does not have our chain ID (got 8192, expected 8228, full nVersion 536871168)
2024-09-29T10:23:17Z ERROR: ProcessNewBlock: AcceptBlock FAILED (high-hash, proof of work failed)
"""

I guess the reason is that you forget to set ChainId of block.
BECAUSE I can avoid the problem in a extremly strange way!

bitcoind -blockversion=539230208

I get the number in the following way:

#include <stdio.h>
#include <stdlib.h>

// void SetChainId(u_int32_t chainId)
// {
//     nVersion %= VERSION_CHAIN_START;
//     nVersion |= chainId * VERSION_CHAIN_START;
// }

static const int32_t VERSION_CHAIN_START = (1 << 16);
u_int32_t chainId = 0x2024;
static const int32_t VERSION_AUXPOW = (1 << 8);

int main()
{
  u_int32_t nVersion = 536871168;
  nVersion %= VERSION_CHAIN_START;
  nVersion |= chainId * VERSION_CHAIN_START;

  nVersion &= ~(VERSION_AUXPOW);

  printf("nVersion: %u\n", nVersion);

  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant