@@ -682,6 +682,91 @@ bool AppInitServers(boost::thread_group& threadGroup)
682682 return true ;
683683}
684684
685+ // Parameter interaction based on rules
686+ void InitParameterInteraction ()
687+ {
688+ // when specifying an explicit binding address, you want to listen on it
689+ // even when -connect or -proxy is specified
690+ if (mapArgs.count (" -bind" )) {
691+ if (SoftSetBoolArg (" -listen" , true ))
692+ LogPrintf (" %s: parameter interaction: -bind set -> setting -listen=1\n " , __func__);
693+ }
694+ if (mapArgs.count (" -whitebind" )) {
695+ if (SoftSetBoolArg (" -listen" , true ))
696+ LogPrintf (" %s: parameter interaction: -whitebind set -> setting -listen=1\n " , __func__);
697+ }
698+
699+ if (mapArgs.count (" -connect" ) && mapMultiArgs[" -connect" ].size () > 0 ) {
700+ // when only connecting to trusted nodes, do not seed via DNS, or listen by default
701+ if (SoftSetBoolArg (" -dnsseed" , false ))
702+ LogPrintf (" %s: parameter interaction: -connect set -> setting -dnsseed=0\n " , __func__);
703+ if (SoftSetBoolArg (" -listen" , false ))
704+ LogPrintf (" %s: parameter interaction: -connect set -> setting -listen=0\n " , __func__);
705+ }
706+
707+ if (mapArgs.count (" -proxy" )) {
708+ // to protect privacy, do not listen by default if a default proxy server is specified
709+ if (SoftSetBoolArg (" -listen" , false ))
710+ LogPrintf (" %s: parameter interaction: -proxy set -> setting -listen=0\n " , __func__);
711+ // to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
712+ // to listen locally, so don't rely on this happening through -listen below.
713+ if (SoftSetBoolArg (" -upnp" , false ))
714+ LogPrintf (" %s: parameter interaction: -proxy set -> setting -upnp=0\n " , __func__);
715+ // to protect privacy, do not discover addresses by default
716+ if (SoftSetBoolArg (" -discover" , false ))
717+ LogPrintf (" %s: parameter interaction: -proxy set -> setting -discover=0\n " , __func__);
718+ }
719+
720+ if (!GetBoolArg (" -listen" , DEFAULT_LISTEN )) {
721+ // do not map ports or try to retrieve public IP when not listening (pointless)
722+ if (SoftSetBoolArg (" -upnp" , false ))
723+ LogPrintf (" %s: parameter interaction: -listen=0 -> setting -upnp=0\n " , __func__);
724+ if (SoftSetBoolArg (" -discover" , false ))
725+ LogPrintf (" %s: parameter interaction: -listen=0 -> setting -discover=0\n " , __func__);
726+ if (SoftSetBoolArg (" -listenonion" , false ))
727+ LogPrintf (" %s: parameter interaction: -listen=0 -> setting -listenonion=0\n " , __func__);
728+ }
729+
730+ if (mapArgs.count (" -externalip" )) {
731+ // if an explicit public IP is specified, do not try to find others
732+ if (SoftSetBoolArg (" -discover" , false ))
733+ LogPrintf (" %s: parameter interaction: -externalip set -> setting -discover=0\n " , __func__);
734+ }
735+
736+ if (GetBoolArg (" -salvagewallet" , false )) {
737+ // Rewrite just private keys: rescan to find transactions
738+ if (SoftSetBoolArg (" -rescan" , true ))
739+ LogPrintf (" %s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n " , __func__);
740+ }
741+
742+ // -zapwallettx implies a rescan
743+ if (GetBoolArg (" -zapwallettxes" , false )) {
744+ if (SoftSetBoolArg (" -rescan" , true ))
745+ LogPrintf (" %s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n " , __func__);
746+ }
747+
748+ // disable walletbroadcast and whitelistalwaysrelay in blocksonly mode
749+ if (GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY )) {
750+ if (SoftSetBoolArg (" -whitelistalwaysrelay" , false ))
751+ LogPrintf (" %s: parameter interaction: -blocksonly=1 -> setting -whitelistalwaysrelay=0\n " , __func__);
752+ #ifdef ENABLE_WALLET
753+ if (SoftSetBoolArg (" -walletbroadcast" , false ))
754+ LogPrintf (" %s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n " , __func__);
755+ #endif
756+ }
757+ }
758+
759+ void InitLogging ()
760+ {
761+ fPrintToConsole = GetBoolArg (" -printtoconsole" , false );
762+ fLogTimestamps = GetBoolArg (" -logtimestamps" , true );
763+ fLogTimeMicros = GetBoolArg (" -logtimemicros" , DEFAULT_LOGTIMEMICROS );
764+ fLogIPs = GetBoolArg (" -logips" , false );
765+
766+ LogPrintf (" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n " );
767+ LogPrintf (" Bitcoin version %s (%s)\n " , FormatFullVersion (), CLIENT_DATE );
768+ }
769+
685770/* * Initialize bitcoin.
686771 * @pre Parameters should be parsed and config file should be read.
687772 */
@@ -746,74 +831,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
746831 // ********************************************************* Step 2: parameter interactions
747832 const CChainParams& chainparams = Params ();
748833
749- // Set this early so that parameter interactions go to console
750- fPrintToConsole = GetBoolArg (" -printtoconsole" , false );
751- fLogTimestamps = GetBoolArg (" -logtimestamps" , true );
752- fLogTimeMicros = GetBoolArg (" -logtimemicros" , DEFAULT_LOGTIMEMICROS );
753- fLogIPs = GetBoolArg (" -logips" , false );
754-
755- LogPrintf (" \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n " );
756- LogPrintf (" Bitcoin version %s (%s)\n " , FormatFullVersion (), CLIENT_DATE );
757-
758- // when specifying an explicit binding address, you want to listen on it
759- // even when -connect or -proxy is specified
760- if (mapArgs.count (" -bind" )) {
761- if (SoftSetBoolArg (" -listen" , true ))
762- LogPrintf (" %s: parameter interaction: -bind set -> setting -listen=1\n " , __func__);
763- }
764- if (mapArgs.count (" -whitebind" )) {
765- if (SoftSetBoolArg (" -listen" , true ))
766- LogPrintf (" %s: parameter interaction: -whitebind set -> setting -listen=1\n " , __func__);
767- }
768-
769- if (mapArgs.count (" -connect" ) && mapMultiArgs[" -connect" ].size () > 0 ) {
770- // when only connecting to trusted nodes, do not seed via DNS, or listen by default
771- if (SoftSetBoolArg (" -dnsseed" , false ))
772- LogPrintf (" %s: parameter interaction: -connect set -> setting -dnsseed=0\n " , __func__);
773- if (SoftSetBoolArg (" -listen" , false ))
774- LogPrintf (" %s: parameter interaction: -connect set -> setting -listen=0\n " , __func__);
775- }
776-
777- if (mapArgs.count (" -proxy" )) {
778- // to protect privacy, do not listen by default if a default proxy server is specified
779- if (SoftSetBoolArg (" -listen" , false ))
780- LogPrintf (" %s: parameter interaction: -proxy set -> setting -listen=0\n " , __func__);
781- // to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
782- // to listen locally, so don't rely on this happening through -listen below.
783- if (SoftSetBoolArg (" -upnp" , false ))
784- LogPrintf (" %s: parameter interaction: -proxy set -> setting -upnp=0\n " , __func__);
785- // to protect privacy, do not discover addresses by default
786- if (SoftSetBoolArg (" -discover" , false ))
787- LogPrintf (" %s: parameter interaction: -proxy set -> setting -discover=0\n " , __func__);
788- }
789-
790- if (!GetBoolArg (" -listen" , DEFAULT_LISTEN )) {
791- // do not map ports or try to retrieve public IP when not listening (pointless)
792- if (SoftSetBoolArg (" -upnp" , false ))
793- LogPrintf (" %s: parameter interaction: -listen=0 -> setting -upnp=0\n " , __func__);
794- if (SoftSetBoolArg (" -discover" , false ))
795- LogPrintf (" %s: parameter interaction: -listen=0 -> setting -discover=0\n " , __func__);
796- if (SoftSetBoolArg (" -listenonion" , false ))
797- LogPrintf (" %s: parameter interaction: -listen=0 -> setting -listenonion=0\n " , __func__);
798- }
799-
800- if (mapArgs.count (" -externalip" )) {
801- // if an explicit public IP is specified, do not try to find others
802- if (SoftSetBoolArg (" -discover" , false ))
803- LogPrintf (" %s: parameter interaction: -externalip set -> setting -discover=0\n " , __func__);
804- }
805-
806- if (GetBoolArg (" -salvagewallet" , false )) {
807- // Rewrite just private keys: rescan to find transactions
808- if (SoftSetBoolArg (" -rescan" , true ))
809- LogPrintf (" %s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n " , __func__);
810- }
811834
812- // -zapwallettx implies a rescan
813- if (GetBoolArg (" -zapwallettxes" , false )) {
814- if (SoftSetBoolArg (" -rescan" , true ))
815- LogPrintf (" %s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n " , __func__);
816- }
817835
818836 // if using block pruning, then disable txindex
819837 if (GetArg (" -prune" , 0 )) {
0 commit comments