Skip to content

Commit 714d344

Browse files
committed
Fix error when using remote Haveno node
1 parent d18dbdb commit 714d344

4 files changed

Lines changed: 60 additions & 45 deletions

File tree

Components/Pages/SeedBackup.razor

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,45 @@
11
@page "/wallet/seedbackup"
22

33
<div class="seedbackup-main">
4-
@switch (Step)
4+
@if (SeedWords.Count == 0)
55
{
6-
case 0:
7-
<p>Please write down your recovery phrase.</p>
8-
<br/>
6+
<p>Fetching seed words...</p>
7+
}
8+
else
9+
{
10+
@switch (Step)
11+
{
12+
case 0:
13+
<p>Please write down your recovery phrase.</p>
14+
<br />
915

10-
for (int i = 0; i < SeedWords.Count; i++)
11-
{
12-
<div class="seed-word">
13-
<p>@(i+1)</p>
14-
<input value="@SeedWords[i]" disabled="@true"/>
15-
</div>
16-
}
16+
for (int i = 0; i < SeedWords.Count; i++)
17+
{
18+
<div class="seed-word">
19+
<p>@(i + 1)</p>
20+
<input value="@SeedWords[i]" disabled="@true" />
21+
</div>
22+
}
1723

18-
<button class="button-green" @onclick="() => Step = 1">Next</button>
19-
break;
20-
case 1:
21-
<p>Please confirm that you have written down your recovery phrase by filling in the five blank fields.</p>
22-
<br/>
24+
<button class="button-green" @onclick="() => Step = 1">Next</button>
25+
break;
26+
case 1:
27+
<p>Please confirm that you have written down your recovery phrase by filling in the five blank fields.</p>
28+
<br />
2329

24-
for (int i = 0; i < RemovedSeedWords.Count; i++)
25-
{
26-
int iCopy = i;
27-
<div class=@($"seed-word")>
28-
<p>@(i+1)</p>
29-
<input value="@RemovedSeedWords[iCopy].Word" @oninput="(e) => HandleOnInput(e.Value.ToString(), iCopy)" disabled="@(!RemovedIndices.Contains(iCopy))" class=@(RemovedIndices.Contains(iCopy) ? (RemovedSeedWords[iCopy].IsCorrect ? "word-valid" : "word-invalid") : "")/>
30-
</div>
31-
}
30+
for (int i = 0; i < RemovedSeedWords.Count; i++)
31+
{
32+
int iCopy = i;
33+
<div class=@($"seed-word")>
34+
<p>@(i + 1)</p>
35+
<input value="@RemovedSeedWords[iCopy].Word" @oninput="(e) => HandleOnInput(e.Value.ToString(), iCopy)" disabled="@(!RemovedIndices.Contains(iCopy))" class=@(RemovedIndices.Contains(iCopy) ? (RemovedSeedWords[iCopy].IsCorrect ? "word-valid" : "word-invalid") : "") />
36+
</div>
37+
}
3238

33-
<button disabled="@(!IsValid)" class="button-green" @onclick="Submit">Submit</button>
34-
<button class="button-grey" @onclick="GoBack">Go back</button>
35-
break;
36-
default: break;
39+
<button disabled="@(!IsValid)" class="button-green" @onclick="Submit">Submit</button>
40+
<button class="button-grey" @onclick="GoBack">Go back</button>
41+
break;
42+
default: break;
43+
}
3744
}
3845
</div>

Components/Pages/SeedBackup.razor.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ public void HandleOnInput(string word, int i)
5353

5454
protected override async Task OnInitializedAsync()
5555
{
56-
XmrSeed = await HavenoWalletService.GetXmrSeedAsync();
56+
try
57+
{
58+
XmrSeed = await HavenoWalletService.GetXmrSeedAsync();
59+
}
60+
catch
61+
{
62+
// TODO - Only happens if remote node is not connected, handle this better
63+
return;
64+
}
65+
5766
SeedWords = XmrSeed.Split(" ").ToList();
5867
RemovedSeedWords = SeedWords.Select(x => new SeedWord(x, false)).ToList();
5968

Components/Pages/Settings.razor

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,10 @@
109109
</div>
110110
<br />
111111
<p class="bold-p">Monero network</p>
112-
@if (DaemonInstallOption == DaemonInstallOptions.RemoteNode)
113-
{
114-
// Always false when using standalone?
115-
<p>Status: @(IsXmrNodeOnline ? "Running" : "Stopped")</p>
116-
}
117-
@if (UrlConnections.Count == 0)
118-
{
119-
<p>No Monero nodes</p>
120-
}
121-
else
112+
@if (UrlConnections.Count != 0)
122113
{
123114
<ul class="url-connections">
124-
@foreach (var urlConnection in UrlConnections.Where(x => !x.Url.Contains("127.0.0.1")).OrderByDescending(x => x.Url == ConnectedMoneroNodeUrl).ThenBy(x => x.Priority))
115+
@foreach (var urlConnection in UrlConnections.Where(x => DaemonInstallOption == DaemonInstallOptions.RemoteNode ? true : !x.Url.Contains("127.0.0.1")).OrderByDescending(x => x.Url == ConnectedMoneroNodeUrl).ThenBy(x => x.Priority))
125116
{
126117
<li class=@(urlConnection.Url == ConnectedMoneroNodeUrl ? "connection connected" : "connection")>
127118
@switch (urlConnection.OnlineStatus)
@@ -144,8 +135,8 @@
144135
</ul>
145136
}
146137
</div>
147-
<button @onclick="() => ShowAddMoneroNodeModal = true">Add Monero node</button>
148-
<Toggle OnToggledChanged="SetAutoSwitchAsync" @bind-IsToggled="IsAutoSwitchEnabled" Text="Use any Monero node"></Toggle>
138+
<button disabled="@(!IsConnected)" @onclick="() => ShowAddMoneroNodeModal = true">Add Monero node</button>
139+
<Toggle Disabled=@(!IsConnected) OnToggledChanged="SetAutoSwitchAsync" @bind-IsToggled="IsAutoSwitchEnabled" Text="Use any Monero node"></Toggle>
149140
<p class="note">Note: disable this to ensure the app only uses the selected node</p>
150141
<br/>
151142
<p class="bold-p">Preferences</p>
@@ -173,7 +164,7 @@
173164
<div class="@(IsRemoteNodeToggled ? "remote-node-section" : "remote-node-section remote-node-disabled")">
174165
<button @onclick="ScanQRCodeAsync" class="qr-btn">Scan QR code</button>
175166
<p class="or">Or</p>
176-
<label class="bold-p">IP Address</label>
167+
<label class="bold-p">Onion Address</label>
177168
<input @bind="Host" type="text"/>
178169
<label class="bold-p">Password</label>
179170
<input @bind="Password" type="password" />

Components/Pages/Settings.razor.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,16 @@ protected override async Task OnInitializedAsync()
696696
IsXmrNodeOnline = DaemonInfoSingleton.IsXmrNodeOnline;
697697
ConnectedMoneroNodeUrl = DaemonInfoSingleton.ConnectedMoneroNodeUrl;
698698

699-
IsAutoSwitchEnabled = await HavenoXmrNodeService.GetAutoSwitchAsync();
700-
UrlConnections = await HavenoXmrNodeService.GetConnectionsAsync();
699+
try
700+
{
701+
702+
IsAutoSwitchEnabled = await HavenoXmrNodeService.GetAutoSwitchAsync();
703+
UrlConnections = await HavenoXmrNodeService.GetConnectionsAsync();
704+
}
705+
catch
706+
{
707+
708+
}
701709

702710
DaemonInfoSingleton.OnDaemonInfoFetch += HandleDaemonInfoFetch;
703711
DaemonConnectionSingleton.OnConnectionChanged += HandleDaemonConnectionChanged;

0 commit comments

Comments
 (0)