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

ZEUS-2688: Receive: auto-enable route hints #2716

Merged
merged 3 commits into from
Jan 9, 2025
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
3 changes: 2 additions & 1 deletion components/Modals/InfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export default class InfoModal extends React.Component<InfoModalProps, {}> {
color: themeColor('text'),
fontSize:
infoModalText.length > 3 ? 18 : 20,
marginBottom: 40
marginBottom:
infoModalText.length > 3 ? 18 : 20
}}
>
{text}
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@
"views.Receive.lspSwitchExplainer2": "The LSP will also wrap your invoices, making it easier to receive payments while protecting your privacy.",
"views.Receive.routeHintSwitchExplainer1": "Route hints provide information to find non-advertised, or unannounced, channels. This allows routing of payments to nodes that are not publicly visible on the network.",
"views.Receive.routeHintSwitchExplainer2": "It's helpful to toggle route hints on if you're using only unannounced channels, or if someone trying to pay you cannot reach you via your announced channels.",
"views.Receive.routeHintSwitchExplainer3": "Route hints are automatically enabled when you only have unannounced channels",
"views.Receive.ampSwitchExplainer1": "Atomic Multi-path Payments (AMP) are a new type of Lightning payments that can be paid multiple times.",
"views.Receive.ampSwitchExplainer2": "Please note that AMP invoices are currently only compatible with LND nodes.",
"views.Receive.lspZeroAmt": "The LSP is incompatible with zero amounts. An unwrapped invoice has been generated. Your node's public key will be exposed.",
Expand Down
11 changes: 11 additions & 0 deletions stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default class ChannelsStore {
@observable public pending_chan_ids: Array<string>;
// pending HTLCs
@observable public pendingHTLCs: Array<PendingHTLC>;
@observable public haveAnnouncedChannels = false;

settingsStore: SettingsStore;

Expand Down Expand Up @@ -180,6 +181,7 @@ export default class ChannelsStore {
@action
reset = () => {
this.resetOpenChannel();
this.haveAnnouncedChannels = false;
this.nodes = {};
this.channels = [];
this.pendingChannels = [];
Expand Down Expand Up @@ -353,7 +355,15 @@ export default class ChannelsStore {

if (setPendingHtlcs) this.pendingHTLCs = [];

let haveAnnouncedChannels = false;
for (const channel of channels) {
if (
!haveAnnouncedChannels &&
!channel.private &&
channel.isActive
) {
haveAnnouncedChannels = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can break early when 1 announced channel was found

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use break; after haveAnnouncedChannels = true;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use break; after haveAnnouncedChannels = true;

there are other enhancements occurring in this loop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah of course

if (channel.alias == null) {
channel.alias =
this.nodes[channel.remotePubkey]?.alias ||
Expand All @@ -373,6 +383,7 @@ export default class ChannelsStore {
this.pendingHTLCs.push(...channel.pending_htlcs);
}
}
this.haveAnnouncedChannels = haveAnnouncedChannels;

if (this.pendingHTLCs.length > 0) {
console.log('Pending HTLCs', this.pendingHTLCs);
Expand Down
10 changes: 9 additions & 1 deletion views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ export default class Receive extends React.Component<
expiry: settings?.invoices?.expiry || '3600',
timePeriod: settings?.invoices?.timePeriod || 'Seconds',
expirySeconds: newExpirySeconds,
routeHints: settings?.invoices?.routeHints || false,
routeHints:
settings?.invoices?.routeHints ||
!this.props.ChannelsStore.haveAnnouncedChannels
? true
: false,
ampInvoice:
(settings?.invoices?.ampInvoice &&
BackendUtils.supportsAMP()) ||
Expand Down Expand Up @@ -2661,6 +2665,9 @@ export default class Receive extends React.Component<
),
localeString(
'views.Receive.routeHintSwitchExplainer2'
),
localeString(
'views.Receive.routeHintSwitchExplainer3'
)
]}
>
Expand Down Expand Up @@ -2697,6 +2704,7 @@ export default class Receive extends React.Component<
)}

{BackendUtils.isLNDBased() &&
!lspIsActive &&
routeHints && (
<Row>
<Text
Expand Down
Loading