-
-
Notifications
You must be signed in to change notification settings - Fork 218
feat: Embedded LND testnet4 support #3583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @kaloudis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Embedded LND node functionality by adding full support for Testnet4. It provides users with greater control over their node's blockchain interaction through a new dedicated settings screen for selecting between Neutrino and Esplora backends. The changes ensure that the application correctly identifies, configures, and displays information for Testnet4, laying the groundwork for future remote node support. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for testnet4 to Embedded LND nodes. The changes are generally good, but I've identified some areas for code improvement, including refactoring for better readability and fixing inconsistencies in how network settings are handled, especially regarding network type checks. Please review the detailed comments for specific suggestions.
| export const EMBEDDED_NODE_NETWORK_KEYS = [ | ||
| { key: 'Mainnet', translateKey: 'network.mainnet', value: 'mainnet' }, | ||
| { key: 'Testnet', translateKey: 'network.testnet', value: 'testnet' } | ||
| { key: 'Testnet3', translateKey: 'network.testnet3', value: 'testnet' }, | ||
| { key: 'Testnet4', translateKey: 'network.testnet4', value: 'testnet4' } | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be an inconsistency in how embeddedLndNetwork is used across the codebase. This constant defines the internal values as mainnet, testnet, and testnet4. However, some parts of the code are checking for Testnet3 or testnet3 (e.g., stores/AlertStore.ts, views/Settings/EmbeddedNode/LNDLogs.tsx, utils/LndMobileUtils.ts). This can lead to bugs where conditions are not met as expected. Please ensure consistent use of the internal values (mainnet, testnet, testnet4) throughout the application.
References
- This rule clarifies the expected string value for 'Mainnet' when checking the network type from
settingsStore.embeddedLndNetworkand emphasizes consistency in network naming and checks across the codebase.
| @computed public get isTestNet(): boolean { | ||
| return ( | ||
| this.testnet || | ||
| this.network === 'testnet' || | ||
| this.network === 'testnet4' || | ||
| (this.chains && | ||
| this.chains[0] && | ||
| this.chains[0].network === 'testnet') | ||
| (this.chains[0].network === 'testnet' || | ||
| this.chains[0].network === 'testnet4')) | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for isTestNet can be simplified for better readability and to reduce redundancy, especially now that isTestNet4 is available.
| @computed public get isTestNet(): boolean { | |
| return ( | |
| this.testnet || | |
| this.network === 'testnet' || | |
| this.network === 'testnet4' || | |
| (this.chains && | |
| this.chains[0] && | |
| this.chains[0].network === 'testnet') | |
| (this.chains[0].network === 'testnet' || | |
| this.chains[0].network === 'testnet4')) | |
| ); | |
| } | |
| @computed public get isTestNet(): boolean { | |
| const networks = ['testnet', 'testnet4']; | |
| return ( | |
| this.testnet || | |
| (this.network && networks.includes(this.network)) || | |
| (this.chains && | |
| this.chains[0] && | |
| this.chains[0].network && | |
| networks.includes(this.chains[0].network)) | |
| ); | |
| } |
| export const getNetworkDisplayName = (network: string): string => { | ||
| const networkDisplayMap: { [key: string]: string } = { | ||
| mainnet: 'Mainnet', | ||
| Mainnet: 'Mainnet', | ||
| testnet: 'Testnet3', | ||
| Testnet3: 'Testnet3', | ||
| testnet4: 'Testnet4', | ||
| Testnet4: 'Testnet4' | ||
| }; | ||
| return networkDisplayMap[network] || network; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The networkDisplayMap contains redundant entries for capitalized and lowercased keys. You can simplify this function by converting the input network string to lowercase before the lookup. This will make the map more concise and easier to maintain.
export const getNetworkDisplayName = (network: string): string => {
const lowercasedNetwork = network.toLowerCase();
const networkDisplayMap: { [key: string]: string } = {
mainnet: 'Mainnet',
testnet: 'Testnet3',
testnet4: 'Testnet4'
};
return networkDisplayMap[lowercasedNetwork] || network;
};| compactDb?: boolean; | ||
| }) => { | ||
| const isMainnet = !network || network === 'mainnet'; | ||
| const isTestnet = network === 'testnet' || network === 'testnet3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check network === 'testnet3' will always be false because the network value for Testnet3 is 'testnet'. This is confusing and should be removed to avoid potential bugs.
const isTestnet = network === 'testnet';References
- This rule clarifies the expected string value for 'Mainnet' when checking the network type from
settingsStore.embeddedLndNetworkand emphasizes consistency in network naming and checks across the codebase.
Description
Adds support for testnet4 to Embedded LND nodes. Will soon add support for testnet4 remote nodes.
This pull request is categorized as a:
Checklist
yarn run tscand made sure my code compiles correctlyyarn run lintand made sure my code didn’t contain any problematic patternsyarn run prettierand made sure my code is formatted correctlyyarn run testand made sure all of the tests passTesting
If you modified or added a utility file, did you add new unit tests?
I have tested this PR on the following platforms (please specify OS version and phone model/VM):
I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):
Locales
Third Party Dependencies and Packages
yarnafter this PR is merged inpackage.jsonandyarn.lockhave been properly updatedOther: