@@ -23,12 +23,13 @@ import {
23
23
} from "../storage/app" ;
24
24
25
25
import { Chain } from "../utils/build" ;
26
- import { IBitcoinUnits } from "../utils/bitcoin-units" ;
26
+ import { BitcoinUnits , IBitcoinUnits } from "../utils/bitcoin-units" ;
27
27
import { IFiatRates } from "./Fiat" ;
28
28
import { IStoreModel } from "./index" ;
29
29
import { MapStyle } from "../utils/google-maps" ;
30
30
import { i18n } from "../i18n/i18n" ;
31
31
import logger from "./../utils/log" ;
32
+ import { languages } from "../i18n/i18n.constants" ;
32
33
33
34
const log = logger ( "Settings" ) ;
34
35
@@ -94,6 +95,7 @@ export interface ISettingsModel {
94
95
changeLightningBoxAddress : Thunk < ISettingsModel , string > ;
95
96
changeLightningBoxLnurlPayDesc : Thunk < ISettingsModel , string > ;
96
97
changeHideAmountsEnabled : Thunk < ISettingsModel , boolean > ;
98
+ changeRandomizeSettingsOnStartup : Thunk < ISettingsModel , boolean > ;
97
99
98
100
setBitcoinUnit : Action < ISettingsModel , keyof IBitcoinUnits > ;
99
101
setFiatUnit : Action < ISettingsModel , keyof IFiatRates > ;
@@ -143,6 +145,7 @@ export interface ISettingsModel {
143
145
setLightningBoxAddress : Action < ISettingsModel , string > ;
144
146
SetLightningBoxLnurlPayDesc : Action < ISettingsModel , string > ;
145
147
setHideAmountsEnabled : Action < ISettingsModel , boolean > ;
148
+ setRandomizeSettingsOnStartup : Action < ISettingsModel , boolean > ;
146
149
147
150
bitcoinUnit : keyof IBitcoinUnits ;
148
151
fiatUnit : keyof IFiatRates ;
@@ -192,11 +195,23 @@ export interface ISettingsModel {
192
195
lightningBoxAddress : string ;
193
196
lightningBoxLnurlPayDesc : string ;
194
197
hideAmountsEnabled : boolean ;
198
+ randomizeSettingsOnStartup : boolean ;
199
+
200
+ randomize : Thunk < ISettingsModel , void , any , IStoreModel > ;
195
201
}
196
202
197
203
export const settings : ISettingsModel = {
198
204
initialize : thunk ( async ( actions ) => {
199
205
log . d ( "Initializing" ) ;
206
+ const randomizeSettingsOnStartup =
207
+ ( await getItemObject ( StorageItem . randomizeSettingsOnStartup ) ) ?? false ;
208
+ if ( randomizeSettingsOnStartup ) {
209
+ actions . setRandomizeSettingsOnStartup ( randomizeSettingsOnStartup ) ;
210
+ actions . randomize ( ) ;
211
+ return ;
212
+ }
213
+ actions . setRandomizeSettingsOnStartup ( randomizeSettingsOnStartup ) ;
214
+
200
215
actions . setBitcoinUnit ( ( await getItemObject ( StorageItem . bitcoinUnit ) ) || "bitcoin" ) ;
201
216
actions . setFiatUnit ( ( await getItemObject ( StorageItem . fiatUnit ) ) || "USD" ) ;
202
217
actions . setName ( ( await getItemObject ( StorageItem . name ) ) || null ) ;
@@ -537,6 +552,11 @@ export const settings: ISettingsModel = {
537
552
actions . setHideAmountsEnabled ( payload ) ;
538
553
} ) ,
539
554
555
+ changeRandomizeSettingsOnStartup : thunk ( async ( actions , payload ) => {
556
+ await setItemObject < boolean > ( StorageItem . randomizeSettingsOnStartup , payload ) ;
557
+ actions . setRandomizeSettingsOnStartup ( payload ) ;
558
+ } ) ,
559
+
540
560
setBitcoinUnit : action ( ( state , payload ) => {
541
561
state . bitcoinUnit = payload ;
542
562
} ) ,
@@ -682,6 +702,10 @@ export const settings: ISettingsModel = {
682
702
state . hideAmountsEnabled = payload ;
683
703
} ) ,
684
704
705
+ setRandomizeSettingsOnStartup : action ( ( state , payload ) => {
706
+ state . randomizeSettingsOnStartup = payload ;
707
+ } ) ,
708
+
685
709
bitcoinUnit : "bitcoin" ,
686
710
fiatUnit : "USD" ,
687
711
name : null ,
@@ -730,4 +754,141 @@ export const settings: ISettingsModel = {
730
754
lightningBoxAddress : "" ,
731
755
lightningBoxLnurlPayDesc : DEFAULT_LIGHTNINGBOX_LNURLPDESC ,
732
756
hideAmountsEnabled : false ,
757
+ randomizeSettingsOnStartup : false ,
758
+
759
+ randomize : thunk ( ( state , _ , { getStoreState, dispatch } ) => {
760
+ const bitcoinUnits = Object . keys ( BitcoinUnits ) ;
761
+ state . setBitcoinUnit ( getRandomFromArray ( bitcoinUnits ) ) ;
762
+
763
+ const fiatUnits = Object . keys ( getStoreState ( ) . fiat . fiatRates ) ;
764
+ state . setFiatUnit ( getRandomFromArray ( fiatUnits ) ) ;
765
+
766
+ state . setName ( getRandomFromArray ( funnyNames ) ) ;
767
+
768
+ const language = getRandomFromArray ( Object . keys ( languages ) ) ;
769
+ state . setLanguage ( getRandomFromArray ( language ) ) ;
770
+ i18n . changeLanguage ( language ) ;
771
+
772
+ const autopilotEnabled = rand ( 0 , 1 ) === 1 ;
773
+ state . setAutopilotEnabled ( autopilotEnabled ) ;
774
+ dispatch . lightning . setupAutopilot ( autopilotEnabled ) ;
775
+
776
+ state . setPushNotificationsEnabled ( rand ( 0 , 1 ) === 1 ) ;
777
+ state . setClipboardInvoiceCheckInvoicesEnabled ( rand ( 0 , 1 ) === 1 ) ;
778
+ // state.scheduledSyncEnabled;
779
+ // state.scheduledGossipSyncEnabled;
780
+ state . setDebugShowStartupInfo ( rand ( 0 , 1 ) === 1 ) ;
781
+ // state.googleDriveBackupEnabled;
782
+ state . setPreferFiat ( rand ( 0 , 1 ) === 1 ) ;
783
+ // state.transactionGeolocationEnabled;
784
+ // state.transactionGeolocationMapStyle;
785
+ const onchainExplorers = Object . keys ( OnchainExplorer ) ;
786
+ state . setOnchainExplorer ( getRandomFromArray ( onchainExplorers ) ) ;
787
+ state . setMultiPathPaymentsEnabled ( rand ( 0 , 1 ) === 1 ) ;
788
+ // state.torEnabled;
789
+ state . setHideExpiredInvoices ( rand ( 0 , 1 ) === 1 ) ;
790
+ state . setScreenTransitionsEnabled ( rand ( 0 , 1 ) === 1 ) ;
791
+ // state.iCloudBackupEnabled;
792
+ // state.lndChainBackend;
793
+ // state.neutrinoPeers;
794
+ // state.bitcoindRpcHost;
795
+ // state.bitcoindRpcUser;
796
+ // state.bitcoindRpcPassword;
797
+ // state.bitcoindPubRawBlock;
798
+ // state.bitcoindPubRawTx;
799
+ // state.dunderServer;
800
+ state . setRequireGraphSync ( rand ( 0 , 1 ) === 1 ) ;
801
+ state . setDunderEnabled ( rand ( 0 , 1 ) === 1 ) ;
802
+ // state.lndNoGraphCache;
803
+ state . setInvoiceExpiry ( rand ( 0 , 1000 ) ) ; // TODO
804
+ // state.rescanWallet;
805
+ // state.strictGraphPruningEnabled;
806
+ // state.lndPathfindingAlgorithm;
807
+ state . setMaxLNFeePercentage ( rand ( 0 , 100 ) / 10 ) ;
808
+ // state.lndLogLevel;
809
+ // state.lndCompactDb;
810
+ // state.zeroConfPeers;
811
+ // state.enforceSpeedloaderOnStartup;
812
+ // state.persistentServicesEnabled;
813
+ // state.persistentServicesWarningShown;
814
+ // state.customInvoicePreimageEnabled;
815
+ state . setCustomInvoicePreimageEnabled ( rand ( 0 , 1 ) === 1 ) ;
816
+ // state.speedloaderServer;
817
+ // state.lightningBoxServer;
818
+ // state.lightningBoxAddress;
819
+ state . SetLightningBoxLnurlPayDesc ( generateGarbageText ( ) ) ;
820
+ state . setHideAmountsEnabled ( rand ( 0 , 1 ) === 1 ) ;
821
+ } ) ,
733
822
} ;
823
+
824
+ function rand ( min : number , max : number ) : number {
825
+ return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
826
+ }
827
+
828
+ function getRandomFromArray ( arr : any [ ] ) {
829
+ return arr [ rand ( 0 , arr . length - 1 ) ] ;
830
+ }
831
+
832
+ function generateGarbageText ( ) : string {
833
+ // Add any weird characters you want to this string
834
+ const characters =
835
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~`!@#$%^&*()_-+={[}]|\\:;"<,>.?/⊙△ΩβφÇ' ;
836
+ const length = Math . floor ( Math . random ( ) * 20 ) + 4 ; // This will give a random number between 4 and 16
837
+
838
+ return [ ...Array ( length ) ]
839
+ . map ( ( ) => characters [ Math . floor ( Math . random ( ) * characters . length ) ] )
840
+ . join ( "" ) ;
841
+ }
842
+
843
+ const funnyNames = [
844
+ "Binky" ,
845
+ "Fido" ,
846
+ "Peaches" ,
847
+ "Puddles" ,
848
+ "Snickers" ,
849
+ "Wiggles" ,
850
+ "Twinkle" ,
851
+ "Pickles" ,
852
+ "Muffin" ,
853
+ "Giggles" ,
854
+ "Bubbles" ,
855
+ "Ziggy" ,
856
+ "Noodle" ,
857
+ "Doodle" ,
858
+ "Pookie" ,
859
+ "Fluffy" ,
860
+ "Sprinkles" ,
861
+ "Jingles" ,
862
+ "Boogie" ,
863
+ "Winky" ,
864
+ "Tootsie" ,
865
+ "Fuzzy" ,
866
+ "Spunky" ,
867
+ "Goober" ,
868
+ "Snuggles" ,
869
+ "Scrappy" ,
870
+ "Puddin'" ,
871
+ "Biscuit" ,
872
+ "Doogie" ,
873
+ "Waffle" ,
874
+ "Zippy" ,
875
+ "Jolly" ,
876
+ "Sassy" ,
877
+ "Rascal" ,
878
+ "Boppy" ,
879
+ "Cuddles" ,
880
+ "Dinky" ,
881
+ "Fiddle" ,
882
+ "Gadget" ,
883
+ "Hopper" ,
884
+ "Jester" ,
885
+ "Kiki" ,
886
+ "Lollipop" ,
887
+ "Mimi" ,
888
+ "Nibbles" ,
889
+ "Oreo" ,
890
+ "Peppy" ,
891
+ "Quirky" ,
892
+ "Roo" ,
893
+ "Sprout" ,
894
+ ] ;
0 commit comments