diff --git a/src/app/main-core-config/settings-pages/network/network.component.ts b/src/app/main-core-config/settings-pages/network/network.component.ts index 7e4873ea4..3524f2308 100644 --- a/src/app/main-core-config/settings-pages/network/network.component.ts +++ b/src/app/main-core-config/settings-pages/network/network.component.ts @@ -46,7 +46,7 @@ export class NetworkComponent implements OnInit, OnDestroy { private destroy$: Subject = new Subject(); - private allowEditingNetwork: boolean = false; + private allowMainNetwork: boolean = false; private controlNetworkPrefix: NetworkPrefix = ''; @@ -59,7 +59,7 @@ export class NetworkComponent implements OnInit, OnDestroy { ngOnInit(): void { - this.allowEditingNetwork = !this._store.selectSnapshot(ApplicationConfigState).requestedTestingNetworks; + this.allowMainNetwork = !this._store.selectSnapshot(ApplicationConfigState).requestedTestingNetworks; const settings$ = this._coreConfigService.getSettings().pipe( filter(settings => settings !== null), @@ -131,27 +131,27 @@ export class NetworkComponent implements OnInit, OnDestroy { private loadSettings(settings: Settings): void { let selectedNetwork: NetworkPrefixType = ''; - if (this.allowEditingNetwork) { - if (settings[Controls.network_main] || settings[Controls.network_test] || settings[Controls.network_regtest]) { - switch (true) { - case settings[Controls.network_main] && settings[Controls.network_main].value: selectedNetwork = 'mainnet'; break; - case settings[Controls.network_test] && settings[Controls.network_test].value: selectedNetwork = 'testnet'; break; - case settings[Controls.network_regtest] && settings[Controls.network_regtest].value: selectedNetwork = 'regtest'; break; - } + if (settings[Controls.network_main] || settings[Controls.network_test] || settings[Controls.network_regtest]) { + switch (true) { + case this.allowMainNetwork && settings[Controls.network_main] && settings[Controls.network_main].value: + selectedNetwork = 'mainnet'; + this.networkLabel = TextContent.NETWORK_LABEL_MAINNET; + break; + case settings[Controls.network_test] && settings[Controls.network_test].value: + selectedNetwork = 'testnet'; + this.networkLabel = TextContent.NETWORK_LABEL_TESTNET; + break; + case settings[Controls.network_regtest] && settings[Controls.network_regtest].value: + selectedNetwork = 'regtest'; + this.networkLabel = TextContent.NETWORK_LABEL_REGTEST; + break; + default: + this.networkLabel = ''; } - } else { - selectedNetwork = 'testnet'; } this.controlNetworkPrefix = selectedNetwork.length > 0 ? `${selectedNetwork}.` : ''; - switch (selectedNetwork) { - case 'mainnet': this.networkLabel = TextContent.NETWORK_LABEL_MAINNET; break; - case 'testnet': this.networkLabel = TextContent.NETWORK_LABEL_TESTNET; break; - case 'regtest': this.networkLabel = TextContent.NETWORK_LABEL_REGTEST; break; - default: this.networkLabel = ''; - } - for (const field of [Controls.rpcIP, Controls.rpcPort, Controls.zmqIP, Controls.zmqPort]) { const fieldName = `${this.controlNetworkPrefix}${field}`; diff --git a/src/app/main-core-config/settings-pages/startup/startup.component.html b/src/app/main-core-config/settings-pages/startup/startup.component.html index 3f136ba7b..333413e5b 100644 --- a/src/app/main-core-config/settings-pages/startup/startup.component.html +++ b/src/app/main-core-config/settings-pages/startup/startup.component.html @@ -44,14 +44,14 @@

Allows for selecting which network to connect to when starting a new Particl Core node.

Note that this selection only applies when starting a new Particl Core node. If Particl Core is already running, it will need to be stopped or disconnected from, and a new node started afterwards, in order to to take effect.

-

This is currently disabled since the application has been forced into a testing state, in which case the relevant testing network will be enforced (this helps to ensure that testing builds do not result in real funds being used).

-

This should only typically be changed away from the main network when wanting to test functionality!

+

The main network is currently disabled since the application has been forced into a testing state, in which case the relevant testing network will be enforced (this helps to ensure that testing builds do not result in real funds being used).

+

This should only typically be changed away from the main network when wanting to test functionality!

-
Main
+
Main
Test
RegTest
diff --git a/src/app/main-core-config/settings-pages/startup/startup.component.ts b/src/app/main-core-config/settings-pages/startup/startup.component.ts index f8b316985..f89366595 100644 --- a/src/app/main-core-config/settings-pages/startup/startup.component.ts +++ b/src/app/main-core-config/settings-pages/startup/startup.component.ts @@ -37,7 +37,7 @@ export class StartupComponent implements OnInit, OnDestroy { controlNetwork: FormControl = new FormControl({ value: '', disabled: true}); controlDataDir: FormControl = new FormControl({ value: '', disabled: true}); - allowEditingNetwork: boolean = false; + allowMainNetwork: boolean = false; private destroy$: Subject = new Subject(); @@ -52,7 +52,7 @@ export class StartupComponent implements OnInit, OnDestroy { ngOnInit(): void { - this.allowEditingNetwork = !this._store.selectSnapshot(ApplicationConfigState).requestedTestingNetworks; + this.allowMainNetwork = !this._store.selectSnapshot(ApplicationConfigState).requestedTestingNetworks; const settings$ = this._coreConfigService.getSettings().pipe( filter(settings => settings !== null), @@ -98,7 +98,11 @@ export class StartupComponent implements OnInit, OnDestroy { [Controls.network_regtest]: false, }; switch (value) { - case 'main': updatedValue[Controls.network_main] = true; break; + case 'main': + if (this.allowMainNetwork) { + updatedValue[Controls.network_main] = true; + } + break; case 'test': updatedValue[Controls.network_test] = true; break; case 'regtest': updatedValue[Controls.network_regtest] = true; break; } @@ -187,22 +191,18 @@ export class StartupComponent implements OnInit, OnDestroy { this.controlStartNew.enable({emitEvent: false}); } - let networkSelection = 'main'; - if (!this.allowEditingNetwork) { - networkSelection = 'test'; - } else { - if (settings[Controls.network_main] || settings[Controls.network_test] || settings[Controls.network_regtest]) { - switch (true) { - case settings[Controls.network_main] && settings[Controls.network_main].value: networkSelection = 'main'; break; - case settings[Controls.network_test] && settings[Controls.network_test].value: networkSelection = 'test'; break; - case settings[Controls.network_regtest] && settings[Controls.network_regtest].value: networkSelection = 'regtest'; break; - } + let networkSelection = this.allowMainNetwork ? 'main' : 'test'; + + if (settings[Controls.network_main] || settings[Controls.network_test] || settings[Controls.network_regtest]) { + switch (true) { + case this.allowMainNetwork && settings[Controls.network_main] && settings[Controls.network_main].value: networkSelection = 'main'; break; + case settings[Controls.network_test] && settings[Controls.network_test].value: networkSelection = 'test'; break; + case settings[Controls.network_regtest] && settings[Controls.network_regtest].value: networkSelection = 'regtest'; break; } } + this.controlNetwork.setValue(networkSelection, {onlySelf: true, emitEvent: false}); - if (this.allowEditingNetwork) { - this.controlNetwork.enable({emitEvent: false}); - } + this.controlNetwork.enable({emitEvent: false}); if (settings[Controls.datadir]) { this.controlDataDir.setValue(settings[Controls.datadir].value, {onlySelf: true, emitEvent: false});