Skip to content

Commit

Permalink
Merge pull request #2716 from kaloudis/zeus-2688
Browse files Browse the repository at this point in the history
ZEUS-2688: Receive: auto-enable route hints
  • Loading branch information
kaloudis authored Jan 9, 2025
2 parents 3bbda2c + ee3c8b9 commit 2ccf02a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
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;
}
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

0 comments on commit 2ccf02a

Please sign in to comment.