Пример #1
0
        protected void RegisterDefaultCookiePath(string folderName, FolderName folder = null)
        {
            folder = folder ?? new FolderName();
            var bitcoinFolder = Network.GetDefaultDataFolder(folderName);

            if (bitcoinFolder is null)
            {
                return;
            }

            if (Mainnet != null)
            {
                var mainnet = folder.MainnetFolder == null?Path.Combine(bitcoinFolder, ".cookie")
                                  : Path.Combine(bitcoinFolder, folder.MainnetFolder, ".cookie");

                RPCClient.RegisterDefaultCookiePath(Mainnet, mainnet);
            }

            if (Testnet != null)
            {
                var testnet = Path.Combine(bitcoinFolder, folder.TestnetFolder, ".cookie");
                RPCClient.RegisterDefaultCookiePath(Testnet, testnet);
            }

            if (Regtest != null)
            {
                var regtest = Path.Combine(bitcoinFolder, folder.RegtestFolder, ".cookie");
                RPCClient.RegisterDefaultCookiePath(Regtest, regtest);
            }
        }
Пример #2
0
        private Network CreateSignet()
        {
            NetworkBuilder builder = new NetworkBuilder();

            builder.SetChainName(SignetName);
            builder.SetNetworkSet(this);
            builder.SetConsensus(new Consensus()
            {
                SubsidyHalvingInterval      = 210000,
                MajorityEnforceBlockUpgrade = 750,
                MajorityRejectBlockOutdated = 950,
                MajorityWindow                = 1000,
                BIP34Hash                     = new uint256(),
                PowLimit                      = new Target(new uint256("00000377ae000000000000000000000000000000000000000000000000000000")),
                PowTargetTimespan             = TimeSpan.FromSeconds(14 * 24 * 60 * 60),
                PowTargetSpacing              = TimeSpan.FromSeconds(10 * 60),
                PowAllowMinDifficultyBlocks   = false,
                PowNoRetargeting              = false,
                RuleChangeActivationThreshold = 1916,
                MinerConfirmationWindow       = 2016,
                CoinbaseMaturity              = 100,
                SupportSegwit                 = true,
                SupportTaproot                = true
            })
            .SetBase58Bytes(Base58Type.PUBKEY_ADDRESS, new byte[] { 111 })
            .SetBase58Bytes(Base58Type.SCRIPT_ADDRESS, new byte[] { 196 })
            .SetBase58Bytes(Base58Type.SECRET_KEY, new byte[] { 239 })
            .SetBase58Bytes(Base58Type.EXT_PUBLIC_KEY, new byte[] { 0x04, 0x35, 0x87, 0xCF })
            .SetBase58Bytes(Base58Type.EXT_SECRET_KEY, new byte[] { 0x04, 0x35, 0x83, 0x94 })
            .SetBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, "tb")
            .SetBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, "tb")
            .SetBech32(Bech32Type.TAPROOT_ADDRESS, "tb")
            .SetMagic(GetSignetMagic())
            .SetPort(38333)
            .SetRPCPort(38332)
            .SetName("signet")
            .AddAlias("bitcoin-signet")
            .AddAlias("btc-signet")
#if !NOSOCKET
            .AddSeeds(new[]
            {
                "178.128.221.177",
                "2a01:7c8:d005:390::5"
            }.Select(o => new Protocol.NetworkAddress(System.Net.IPAddress.Parse(o))))
#endif
            .SetGenesis("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a008f4d5fae77031e8ad222030101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000");
            var network = builder.BuildAndRegister();
#if !NOFILEIO
            var data = Network.GetDefaultDataFolder("bitcoin");
            if (data != null)
            {
                var signetCookie = Path.Combine(data, "signet", ".cookie");
                RPC.RPCClient.RegisterDefaultCookiePath(network, signetCookie);
            }
#endif
            return(network);
        }