Skip to content

Commit

Permalink
Merge pull request #1664 from kaloudis/embedded-node-peers-settings
Browse files Browse the repository at this point in the history
Settings > Embedded Node > Peers
  • Loading branch information
kaloudis authored Sep 15, 2023
2 parents 29efb84 + 2b46bf2 commit 1c0eb8f
Show file tree
Hide file tree
Showing 13 changed files with 754 additions and 44 deletions.
12 changes: 12 additions & 0 deletions Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import DisasterRecovery from './views/Settings/EmbeddedNode/DisasterRecovery';
import Pathfinding from './views/Settings/EmbeddedNode/Pathfinding';
import ExpressGraphSync from './views/Settings/EmbeddedNode/ExpressGraphSync';
import LNDLogs from './views/Settings/EmbeddedNode/LNDLogs';
import Peers from './views/Settings/EmbeddedNode/Peers';
import NeutrinoPeers from './views/Settings/EmbeddedNode/Peers/NeutrinoPeers';
import ZeroConfPeers from './views/Settings/EmbeddedNode/Peers/ZeroConfPeers';

// Routing
import Routing from './views/Routing/Routing';
Expand Down Expand Up @@ -319,6 +322,15 @@ const AppScenes = {
LNDLogs: {
screen: LNDLogs
},
Peers: {
screen: Peers
},
NeutrinoPeers: {
screen: NeutrinoPeers
},
ZeroConfPeers: {
screen: ZeroConfPeers
},
LSPSettings: {
screen: LSP
}
Expand Down
3 changes: 2 additions & 1 deletion components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export default function TextInput(props: TextInputProps) {
...style,
...defaultStyle,
...styles.wrapper,
backgroundColor: themeColor('secondary')
backgroundColor: themeColor('secondary'),
opacity: locked ? 0.8 : 1
}}
>
{prefix ? (
Expand Down
17 changes: 17 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
"general.close": "Close",
"general.learnMore": "Learn more",
"general.advancedSettings": "Advanced settings",
"general.note": "Note",
"general.peer": "Peer",
"general.peers": "Peers",
"general.selected": "Selected",
"general.noneSelected": "None selected",
"general.zeusDefaults": "Using Zeus defaults",
"general.restartZeusChanges": "Restart Zeus for changes to take effect",
"components.CollapsedQr.show": "Show QR",
"components.CollapsedQr.hide": "Hide QR",
"components.CollapsedQr.startNfc": "Start NFC broadcast",
Expand Down Expand Up @@ -663,6 +670,16 @@
"views.Settings.Seed.dangerousButton": "Dangerously copy seed to clipboard",
"views.Settings.EmbeddedNode.title": "Embedded node",
"views.Settings.EmbeddedNode.Pathfinding.title": "Pathfinding",
"views.Settings.EmbeddedNode.Peers.addPeer": "Add peer",
"views.Settings.EmbeddedNode.Peers.peersList": "Peers list",
"views.Settings.EmbeddedNode.NeutrinoPeers.title": "Neutrino Peers",
"views.Settings.EmbeddedNode.NeutrinoPeers.subtitle": "Set the peers you would like to download block headers from and broadcast transactions through.",
"views.Settings.EmbeddedNode.NeutrinoPeers.dontAllowOtherPeers": "Connect only to the specified peers",
"views.Settings.EmbeddedNode.NeutrinoPeers.dontAllowOtherPeers.subtitle": "Only connect to the peers specified. Enabling this may slow down block sync to happen quicker but may be helpful if you're having issues broadcasting transactions.",
"views.Settings.EmbeddedNode.NeutrinoPeers.allowingOtherPeers": "Allowing connections to other peers.",
"views.Settings.EmbeddedNode.NeutrinoPeers.notAllowingOtherPeers": "Not allowing connections to other peers.",
"views.Settings.EmbeddedNode.ZeroConfPeers.title": "Zero conf Peers",
"views.Settings.EmbeddedNode.ZeroConfPeers.subtitle": "Set the peers you would like to accept zero conf lightning channels from, other than the LSP.",
"views.Settings.EmbeddedNode.ExpressGraphSync.title": "Express Graph Sync",
"views.Settings.EmbeddedNode.expressGraphSync": "Enable express graph sync (EGS)",
"views.Settings.EmbeddedNode.expressGraphSync.subtitle": "Download Lightning network's gossip data on startup. This will make pathfinding when trying to make a payment much more reliable. Restart the app to take effect. Also known as Speedloader.",
Expand Down
2 changes: 1 addition & 1 deletion stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default class ChannelsStore {
@action
getNodeInfo = (pubkey: string) => {
this.loading = true;
BackendUtils.getNodeInfo([pubkey])
return BackendUtils.getNodeInfo([pubkey])
.then((data: any) => {
this.loading = false;
if (data?.node?.alias)
Expand Down
39 changes: 18 additions & 21 deletions stores/InvoicesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ export default class InvoicesStore {
this.creatingInvoiceError = false;
this.error_msg = null;

this.lspStore.reset();

const req: any = {
memo,
value,
Expand All @@ -199,26 +197,25 @@ export default class InvoicesStore {
value &&
value !== '0'
) {
await this.lspStore.getLSPInfo().then(async (result) => {
const info: any = result;
const method = info.connection_methods[0];

try {
await this.channelsStore.connectPeer(
{
host: `${method.address}:${method.port}`,
node_pubkey_string: info.pubkey,
local_funding_amount: ''
},
false,
true
);
} catch (e) {}

await this.lspStore.getZeroConfFee(
Number(new BigNumber(value).times(1000))
const info: any = this.lspStore?.info;
const method =
info.connection_methods && info.connection_methods[0];

try {
await this.channelsStore.connectPeer(
{
host: `${method.address}:${method.port}`,
node_pubkey_string: info.pubkey,
local_funding_amount: ''
},
false,
true
);
});
} catch (e) {}

await this.lspStore.getZeroConfFee(
Number(new BigNumber(value).times(1000))
);

if (new BigNumber(value).gt(this.lspStore.zeroConfFee || 0)) {
req.value = new BigNumber(value).minus(
Expand Down
15 changes: 10 additions & 5 deletions stores/LSPStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,17 @@ export default class LSPStore {
const channelAcceptRequest =
channel.decodeChannelAcceptRequest(event.data);

// Only allow 0-conf chans from LSP
const requestPubkey = Base64Utils.bytesToHexString(
channelAcceptRequest.node_pubkey
);

// Only allow 0-conf chans from LSP or whitelisted peers
const isZeroConfAllowed =
this.info.pubkey ===
Base64Utils.bytesToHexString(
channelAcceptRequest.node_pubkey
);
this.info?.pubkey === requestPubkey ||
(this.settingsStore?.settings?.zeroConfPeers &&
this.settingsStore?.settings?.zeroConfPeers.includes(
requestPubkey
));

await channel.channelAcceptorResponse(
channelAcceptRequest.pending_chan_id,
Expand Down
6 changes: 6 additions & 0 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export interface Settings {
expressGraphSyncMobile: boolean;
resetExpressGraphSyncOnStartup: boolean;
bimodalPathfinding: boolean;
dontAllowOtherPeers: boolean;
neutrinoPeers: Array<string>;
zeroConfPeers: Array<string>;
waitForGraphSync: boolean;
rescan: boolean;
recovery: boolean;
Expand Down Expand Up @@ -703,6 +706,9 @@ export default class SettingsStore {
expressGraphSyncMobile: false,
resetExpressGraphSyncOnStartup: false,
bimodalPathfinding: false,
dontAllowOtherPeers: false,
neutrinoPeers: [],
zeroConfPeers: [],
waitForGraphSync: false,
rescan: false,
recovery: false,
Expand Down
33 changes: 23 additions & 10 deletions utils/LndMobileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ export function checkLndStreamErrorResponse(
const writeLndConfig = async (isTestnet?: boolean, rescan?: boolean) => {
const { writeConfig } = lndMobile.index;

const peerMode = stores.settingsStore?.settings?.dontAllowOtherPeers
? 'connect'
: 'addpeer';

const peerDefaults = `neutrino.${peerMode}=${
isTestnet
? 'btcd-testnet.lightning.computer'
: 'btcd-mainnet.lightning.computer'
}
neutrino.${peerMode}=${isTestnet ? 'testnet.lnolymp.us' : 'node.lnolymp.us'}
neutrino.${peerMode}=${
isTestnet ? 'testnet.blixtwallet.com' : 'node.blixtwallet.com'
}
${!isTestnet ? `neutrino.${peerMode}=noad.sathoarder.com` : ''}
${!isTestnet ? `neutrino.${peerMode}=btcd.lnolymp.us` : ''}`;

const config = `[Application Options]
debuglevel=info
maxbackoff=2s
Expand All @@ -89,17 +105,14 @@ const writeLndConfig = async (isTestnet?: boolean, rescan?: boolean) => {
bitcoin.defaultchanconfs=1
[Neutrino]
neutrino.addpeer=${
isTestnet
? 'btcd-testnet.lightning.computer'
: 'btcd-mainnet.lightning.computer'
}
neutrino.addpeer=${isTestnet ? 'testnet.lnolymp.us' : 'node.lnolymp.us'}
neutrino.addpeer=${
isTestnet ? 'testnet.blixtwallet.com' : 'node.blixtwallet.com'
${
stores.settingsStore?.settings?.neutrinoPeers &&
stores.settingsStore?.settings?.neutrinoPeers.length > 0
? stores.settingsStore?.settings?.neutrinoPeers.map(
(peer) => `neutrino.${peerMode}=${peer}`
)
: peerDefaults
}
${!isTestnet ? 'neutrino.addpeer=noad.sathoarder.com' : ''}
${!isTestnet ? 'neutrino.addpeer=btcd.lnolymp.us' : ''}
${
!isTestnet
? 'neutrino.assertfilterheader=230000:1308d5cfc6462f877a5587fd77d7c1ab029d45e58d5175aaf8c264cee9bde760'
Expand Down
Loading

0 comments on commit 1c0eb8f

Please sign in to comment.