diff --git a/stores/SettingsStore.ts b/stores/SettingsStore.ts index ff8bbb286..1eba24fb1 100644 --- a/stores/SettingsStore.ts +++ b/stores/SettingsStore.ts @@ -129,7 +129,8 @@ export interface Settings { resetExpressGraphSyncOnStartup: boolean; bimodalPathfinding: boolean; dontAllowOtherPeers: boolean; - neutrinoPeers: Array; + neutrinoPeersMainnet: Array; + neutrinoPeersTestnet: Array; zeroConfPeers: Array; rescan: boolean; compactDb: boolean; @@ -924,6 +925,20 @@ export const TIME_PERIOD_KEYS = [ { key: 'Weeks', translateKey: 'time.weeks', value: 'Weeks' } ]; +export const DEFAULT_NEUTRINO_PEERS_MAINNET = [ + 'btcd1.lnolymp.us', + 'btcd2.lnolymp.us', + 'btcd-mainnet.lightning.computer', + 'node.eldamar.icu', + 'noad.sathoarder.com' +]; + +export const DEFAULT_NEUTRINO_PEERS_TESTNET = [ + 'testnet.lnolymp.us', + 'btcd-testnet.lightning.computer', + 'testnet.blixtwallet.com' +]; + const STORAGE_KEY = 'zeus-settings'; export default class SettingsStore { @@ -991,7 +1006,8 @@ export default class SettingsStore { resetExpressGraphSyncOnStartup: false, bimodalPathfinding: true, dontAllowOtherPeers: true, - neutrinoPeers: [], + neutrinoPeersMainnet: DEFAULT_NEUTRINO_PEERS_MAINNET, + neutrinoPeersTestnet: DEFAULT_NEUTRINO_PEERS_TESTNET, zeroConfPeers: [], rescan: false, compactDb: false, @@ -1267,6 +1283,15 @@ export default class SettingsStore { this.settings.pos.squareEnabled = false; } + if (!this.settings.neutrinoPeersMainnet) { + this.settings.neutrinoPeersMainnet = + DEFAULT_NEUTRINO_PEERS_MAINNET; + } + if (!this.settings.neutrinoPeersTestnet) { + this.settings.neutrinoPeersTestnet = + DEFAULT_NEUTRINO_PEERS_TESTNET; + } + const node: any = this.settings.nodes?.length && this.settings.nodes[this.settings.selectedNode || 0]; diff --git a/utils/LndMobileUtils.ts b/utils/LndMobileUtils.ts index 1f09eb629..4731a8bb7 100644 --- a/utils/LndMobileUtils.ts +++ b/utils/LndMobileUtils.ts @@ -71,18 +71,6 @@ const writeLndConfig = async ( ? 'connect' : 'addpeer'; - const peerDefaults = `neutrino.${peerMode}=${ - isTestnet - ? 'btcd-testnet.lightning.computer' - : 'btcd-mainnet.lightning.computer' - } - ${!isTestnet ? `neutrino.${peerMode}=btcd1.lnolymp.us` : ''} - ${!isTestnet ? `neutrino.${peerMode}=btcd2.lnolymp.us` : ''} - ${!isTestnet ? `neutrino.${peerMode}=node.eldamar.icu` : ''} - ${!isTestnet ? `neutrino.${peerMode}=noad.sathoarder.com` : ''} - ${isTestnet ? `neutrino.${peerMode}=testnet.lnolymp.us` : ''} - ${isTestnet ? `neutrino.${peerMode}=testnet.blixtwallet.com` : ''}`; - const config = `[Application Options] debuglevel=info maxbackoff=2s @@ -114,12 +102,13 @@ const writeLndConfig = async ( [Neutrino] ${ - stores.settingsStore?.settings?.neutrinoPeers && - stores.settingsStore?.settings?.neutrinoPeers.length > 0 - ? stores.settingsStore?.settings?.neutrinoPeers.map( - (peer) => `neutrino.${peerMode}=${peer}` - ) - : peerDefaults + !isTestnet + ? stores.settingsStore?.settings?.neutrinoPeersMainnet + .map((peer) => `neutrino.${peerMode}=${peer}\n `) + .join('') + : stores.settingsStore?.settings?.neutrinoPeersTestnet + .map((peer) => `neutrino.${peerMode}=${peer}\n `) + .join('') } ${ !isTestnet diff --git a/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx b/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx index d76f32ac7..63db8e52c 100644 --- a/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx +++ b/views/Settings/EmbeddedNode/Peers/NeutrinoPeers.tsx @@ -11,7 +11,10 @@ import Screen from '../../../../components/Screen'; import Switch from '../../../../components/Switch'; import { Row } from '../../../../components/layout/Row'; -import SettingsStore from '../../../../stores/SettingsStore'; +import SettingsStore, { + DEFAULT_NEUTRINO_PEERS_MAINNET, + DEFAULT_NEUTRINO_PEERS_TESTNET +} from '../../../../stores/SettingsStore'; import { localeString } from '../../../../utils/LocaleUtils'; import { restartNeeded } from '../../../../utils/RestartUtils'; @@ -48,21 +51,33 @@ export default class NeutrinoPeers extends React.Component< async UNSAFE_componentWillMount() { const { SettingsStore } = this.props; - const { settings } = SettingsStore; - + const { settings, embeddedLndNetwork } = SettingsStore; this.setState({ dontAllowOtherPeers: settings.dontAllowOtherPeers !== undefined ? settings.dontAllowOtherPeers : false, - neutrinoPeers: settings.neutrinoPeers || [] + neutrinoPeers: + embeddedLndNetwork === 'Testnet' + ? settings.neutrinoPeersTestnet + : settings.neutrinoPeersMainnet }); } render() { const { navigation, SettingsStore } = this.props; const { dontAllowOtherPeers, neutrinoPeers, addPeer } = this.state; - const { updateSettings }: any = SettingsStore; + const { updateSettings, embeddedLndNetwork }: any = SettingsStore; + + const mainnetPeersChanged = + embeddedLndNetwork === 'Mainnet' && + JSON.stringify(neutrinoPeers) !== + JSON.stringify(DEFAULT_NEUTRINO_PEERS_MAINNET); + + const testnetPeersChanged = + embeddedLndNetwork === 'Testnet' && + JSON.stringify(neutrinoPeers) !== + JSON.stringify(DEFAULT_NEUTRINO_PEERS_TESTNET); return ( @@ -80,194 +95,261 @@ export default class NeutrinoPeers extends React.Component< }} navigation={navigation} /> - - <> - - + + <> + - {`${localeString( - 'general.note' - ).toUpperCase()}: ${localeString( - 'general.restartZeusChanges' - ).replace('Zeus', 'ZEUS')}`} - - - - + {`${localeString( + 'general.note' + ).toUpperCase()}: ${localeString( + 'general.restartZeusChanges' + ).replace('Zeus', 'ZEUS')}`} + + + - {localeString( - 'views.Settings.EmbeddedNode.NeutrinoPeers.dontAllowOtherPeers' - )} - + + {localeString( + 'views.Settings.EmbeddedNode.NeutrinoPeers.dontAllowOtherPeers' + )} + + + { + this.setState({ + dontAllowOtherPeers: + !dontAllowOtherPeers + }); + await updateSettings({ + dontAllowOtherPeers: + !dontAllowOtherPeers + }); + restartNeeded(); + }} + /> + + - { - this.setState({ - dontAllowOtherPeers: - !dontAllowOtherPeers - }); - await updateSettings({ - dontAllowOtherPeers: - !dontAllowOtherPeers - }); - restartNeeded(); + + > + {localeString( + 'views.Settings.EmbeddedNode.NeutrinoPeers.dontAllowOtherPeers.subtitle' + )} + - - - + + + {localeString( - 'views.Settings.EmbeddedNode.NeutrinoPeers.dontAllowOtherPeers.subtitle' + 'views.Settings.EmbeddedNode.Peers.addPeer' )} - - - - - {localeString( - 'views.Settings.EmbeddedNode.Peers.addPeer' - )} - - - - this.setState({ addPeer: text }) - } - value={addPeer} - style={{ flex: 1 }} - autoCapitalize="none" - autoCorrect={false} - /> - -