Skip to content
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

LSP settings: set testnet host based on node info #2020

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions stores/LSPStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactNativeBlobUtil from 'react-native-blob-util';

import SettingsStore from './SettingsStore';
import ChannelsStore from './ChannelsStore';
import stores from './Stores';
import NodeInfoStore from './NodeInfoStore';

import lndMobile from '../lndmobile/LndMobileInjection';
const { channel } = lndMobile;
Expand All @@ -24,10 +24,16 @@ export default class LSPStore {

settingsStore: SettingsStore;
channelsStore: ChannelsStore;
nodeInfoStore: NodeInfoStore;

constructor(settingsStore: SettingsStore, channelsStore: ChannelsStore) {
constructor(
settingsStore: SettingsStore,
channelsStore: ChannelsStore,
nodeInfoStore: NodeInfoStore
) {
this.settingsStore = settingsStore;
this.channelsStore = channelsStore;
this.nodeInfoStore = nodeInfoStore;
}

@action
Expand All @@ -37,9 +43,7 @@ export default class LSPStore {
this.error = false;
this.error_msg = '';
this.showLspSettings = false;
// TODO Pegasus clear channel acceptor when
// it's supported by other backends
// this.channelAcceptor = undefined;
this.channelAcceptor = undefined;
};

@action
Expand All @@ -48,9 +52,9 @@ export default class LSPStore {
};

getLSPHost = () =>
this.settingsStore.embeddedLndNetwork === 'Mainnet'
? this.settingsStore.settings.lspMainnet
: this.settingsStore.settings.lspTestnet;
this.nodeInfoStore!.nodeInfo.isTestNet
? this.settingsStore.settings.lspTestnet
: this.settingsStore.settings.lspMainnet;

@action
public getLSPInfo = () => {
Expand Down Expand Up @@ -127,7 +131,7 @@ export default class LSPStore {
},
JSON.stringify({
amount_msat,
pubkey: stores.nodeInfoStore.nodeInfo.nodeId
pubkey: this.nodeInfoStore.nodeInfo.nodeId
})
)
.then((response: any) => {
Expand Down
6 changes: 5 additions & 1 deletion stores/Stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class Stores {
this.channelsStore,
this.settingsStore
);
this.lspStore = new LSPStore(this.settingsStore, this.channelsStore);
this.lspStore = new LSPStore(
this.settingsStore,
this.channelsStore,
this.nodeInfoStore
);
this.lightningAddressStore = new LightningAddressStore(
this.nodeInfoStore,
this.settingsStore
Expand Down
11 changes: 5 additions & 6 deletions views/Settings/LSP.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ export default class LSP extends React.Component<LSPProps, LSPState> {
};

async UNSAFE_componentWillMount() {
const { SettingsStore } = this.props;
const { settings, embeddedLndNetwork } = SettingsStore;
const { SettingsStore, NodeInfoStore } = this.props;
const { settings } = SettingsStore;

this.setState({
enableLSP: settings.enableLSP,
lsp:
embeddedLndNetwork === 'Mainnet'
? settings.lspMainnet
: settings.lspTestnet,
lsp: NodeInfoStore!.nodeInfo.isTestNet
? settings.lspTestnet
: settings.lspMainnet,
accessKey: settings.lspAccessKey,
requestSimpleTaproot: settings.requestSimpleTaproot
});
Expand Down
Loading