Skip to content

static ctor of Network must run before creating other networks #32

@ghost

Description

One cannot run NetworkBuilder.BuildAndRegister() to create a Network before triggering the static ctor of Network one time before so that it already creates BitcoinMain. Otherwise, this line will crash:
assert(consensus.HashGenesisBlock == uint256.Parse("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));

This can be worked around like shown below, but it's very confusing :-)

 
public static void Main(string[] args)
        {
	        var fix= Network.Main; // execute static constructor of Network before everything else, or crash

	        var network = !args.Contains("-testnet") 
				? MyNetworks.RegisterMain() 
				: MyNetworks.RegisterTest();

	        if (NodeSettings.PrintHelp(args, network))
		        return;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions