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