Skip to content
Bitcoin Roots

v31.1-roots.1 · Commit 5: [PATCH 05/17] feat(net): preserve Roots peer controls and health view on v31

src/init.cpp

Before: src/init.cpp · After: src/init.cpp

File metadata
index c686f4ffbbd327ab8a53ad73e4b6f4a653f8c50b..d49ceb56cf02bbc8cd8829ad51d5d864efee89fb 100644

Download original patch · Release notes

Diff rows 1–64 of 64. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.

src/init.cpp CHANGED
@@ -498,6 +498,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
498
498
  argsman.AddArg("-blocknotify=<cmd>", "Execute command when the best block changes (%s in cmd is replaced by block hash)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
499
499
  #endif
500
500
  argsman.AddArg("-blockreconstructionextratxn=<n>", strprintf("Extra transactions to keep in memory for compact block reconstructions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
501
+ argsman.AddArg("-blockreconstructionextratxnsize=<n>", strprintf("Upper limit of memory usage (in decimal megabytes) for compact block extra transactions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN_SIZE / 1000000), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
501
502
  argsman.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Disables automatic broadcast and rebroadcast of transactions, unless the source peer has the 'forcerelay' permission. RPC transactions are not affected. (default: %u)", DEFAULT_BLOCKSONLY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
502
503
  argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
503
504
  argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
@@ -570,6 +571,8 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
570
571
  argsman.AddArg("-onlynet=<net>", "Make automatic outbound connections only to network <net> (" + Join(GetNetworkNames(), ", ") + "). Inbound and manual connections are not affected by this option. It can be specified multiple times to allow multiple networks.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
571
572
  argsman.AddArg("-v2transport", strprintf("Support v2 transport (default: %u)", DEFAULT_V2_TRANSPORT), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
572
573
  argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
574
+ argsman.AddArg("-v2onlyclearnet", "Disable outbound v1 connections and v1 fallback on IPv4/IPv6 (default: 0)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
575
+ argsman.AddArg("-feefilter", strprintf("Tell peers to filter transaction announcements by the mempool minimum fee (default: %u)", DEFAULT_FEEFILTER), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
573
576
  argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
574
577
  argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
575
578
  argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet3: %u, testnet4: %u, signet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md). If set to a value x, the default onion listening port will be set to x+1.", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), testnet4ChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
@@ -2163,6 +2166,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
2163
2166
  connOptions.whitelist_forcerelay = args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY);
2164
2167
  connOptions.whitelist_relay = args.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY);
2165
2168
  connOptions.m_capture_messages = args.GetBoolArg("-capturemessages", false);
2169
+ connOptions.disable_v1conn_clearnet = args.GetBoolArg("-v2onlyclearnet", false);
2170
+ connOptions.listenonion = listenonion;
2166
2171
 
2167
2172
  // Port to bind to if `-bind=addr` is provided without a `:port` suffix.
2168
2173
  const uint16_t default_bind_port =
@@ -2204,10 +2209,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
2204
2209
  return InitError(ResolveErrMsg("bind", bind_arg));
2205
2210
  }
2206
2211
 
2212
+ NetPermissionFlags all_permission_flags{NetPermissionFlags::None};
2207
2213
  for (const std::string& strBind : args.GetArgs("-whitebind")) {
2208
2214
  NetWhitebindPermissions whitebind;
2209
2215
  bilingual_str error;
2210
2216
  if (!NetWhitebindPermissions::TryParse(strBind, whitebind, error)) return InitError(error);
2217
+ NetPermissions::AddFlag(all_permission_flags, whitebind.m_flags);
2211
2218
  connOptions.vWhiteBinds.push_back(whitebind);
2212
2219
  }
2213
2220
 
@@ -2249,11 +2256,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
2249
2256
  Discover();
2250
2257
  }
2251
2258
 
2252
- for (const auto& net : args.GetArgs("-whitelist")) {
2259
+ std::vector<std::string> whitelist_opts{args.GetArgs("-whitelist")};
2260
+ if ((g_local_services & NODE_BLOOM) == NODE_NONE && args.GetBoolArg("-peerbloomfilters", true)) {
2261
+ whitelist_opts.emplace_back("in,out,bloomfilter@127.0.0.0/8");
2262
+ whitelist_opts.emplace_back("in,out,bloomfilter@[::1]/128");
2263
+ }
2264
+ for (const auto& net : whitelist_opts) {
2253
2265
  NetWhitelistPermissions subnet;
2254
2266
  ConnectionDirection connection_direction;
2255
2267
  bilingual_str error;
2256
2268
  if (!NetWhitelistPermissions::TryParse(net, subnet, connection_direction, error)) return InitError(error);
2269
+ NetPermissions::AddFlag(all_permission_flags, subnet.m_flags);
2257
2270
  if (connection_direction & ConnectionDirection::In) {
2258
2271
  connOptions.vWhitelistedRangeIncoming.push_back(subnet);
2259
2272
  }
@@ -2262,6 +2275,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
2262
2275
  }
2263
2276
  }
2264
2277
 
2278
+ if (NetPermissions::HasFlag(all_permission_flags, NetPermissionFlags::BlockFilters_Explicit) &&
2279
+ !g_enabled_filter_types.contains(BlockFilterType::BASIC)) {
2280
+ return InitError(_("Cannot grant blockfilters permission without -blockfilterindex."));
2281
+ }
2282
+
2265
2283
  connOptions.vSeedNodes = args.GetArgs("-seednode");
2266
2284
 
2267
2285
  const auto connect = args.GetArgs("-connect");