Skip to content

Commit

Permalink
Coordinator Connection String (WalletWasabi#13190)
Browse files Browse the repository at this point in the history
* Introduce CoordinatorConfigString

* implement basic UI for the feature

* Rename + Wipe clipboard on DialogCreation

* Write todo NewCoordinatorConfirmationDialog refresh

* Fix stupid mistakes

* Add sanity checks

* Add Name

* Don't display dialog if new string doesn't change anything

* refactoring

* Polishing

* make link clickable

* simplification

* Small refactoring
 * Move `CoordinatorConnectionString` to Discoverability directory
 * Refactor `ToString`
 * Rename `CoordinatorFeePercentage` to `CoordinationFeeRate`

* Minor improvements

* Minor fixes

* Get navigation target from the dialog

* Add constants

* Rename Endpoint to CoordinatorUri

---------

Co-authored-by: Turbolay <[email protected]>
Co-authored-by: Roland Soós <[email protected]>
Co-authored-by: Lucas Ontivero <[email protected]>
  • Loading branch information
4 people authored Jul 9, 2024
1 parent 0d837c4 commit 40ab4a1
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 72 deletions.
20 changes: 0 additions & 20 deletions WalletWasabi.Daemon/PersistentConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,6 @@ public EndPoint GetBitcoinP2pEndPoint()
throw new NotSupportedNetworkException(Network);
}

public string GetCoordinatorUri()
{
if (Network == Network.Main)
{
return MainNetCoordinatorUri;
}

if (Network == Network.TestNet)
{
return TestNetCoordinatorUri;
}

if (Network == Network.RegTest)
{
return RegTestCoordinatorUri;
}

throw new NotSupportedNetworkException(Network);
}

public string GetBackendUri()
{
if (Network == Network.Main)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.Xaml.Interactions.Custom;
using ReactiveUI;
using WalletWasabi.Discoverability;
using WalletWasabi.Fluent.Extensions;
using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Fluent.Models.UI;
using WalletWasabi.Fluent.ViewModels.Dialogs;
using WalletWasabi.Helpers;
using WalletWasabi.Models;

namespace WalletWasabi.Fluent.Behaviors;

public class CoordinatorConnectionStringBehavior : DisposingBehavior<Window>
{

protected override void OnAttached(CompositeDisposable disposables)
{
if (AssociatedObject is null)
{
return;
}

var uiContext = UiContext.Default;

Observable
.FromEventPattern(AssociatedObject, nameof(AssociatedObject.Activated))
.Where(_ => !uiContext.ApplicationSettings.Oobe)
.SelectMany(async _ =>
{
var clipboardValue = await uiContext.Clipboard.GetTextAsync();
if (!CoordinatorConnectionString.TryParse(clipboardValue, out var coordinatorConnectionString))
{
return null;
}
await uiContext.Clipboard.ClearAsync();
var navigationTarget = NewCoordinatorConfirmationDialogViewModel.MetaData.NavigationTarget;
if (uiContext.Navigate(navigationTarget).CurrentPage is NewCoordinatorConfirmationDialogViewModel currentDialog)
{
if (currentDialog.CoordinatorConnection.ToString() == coordinatorConnectionString.ToString())
{
return null;
}
currentDialog.CancelCommand.ExecuteIfCan();
}
return coordinatorConnectionString;
})
.WhereNotNull()
.DoAsync(async coordinatorConnectionString =>
{
var accepted = await uiContext.Navigate().To().NewCoordinatorConfirmationDialog(coordinatorConnectionString).GetResultAsync();
if (!accepted)
{
return;
}
if (!uiContext.ApplicationSettings.TryProcessCoordinatorConnectionString(coordinatorConnectionString))
{
uiContext.Navigate().To().ShowErrorDialog(
message: "Some of the values were incorrect. See logs for more details.",
title: "Coordinator detected",
caption: "");
}
})
.Subscribe()
.DisposeWith(disposables);
}
}
3 changes: 3 additions & 0 deletions WalletWasabi.Fluent/Icons/Icons.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@
<StreamGeometry x:Key="automatic_control">M3.25 0C1.46 0 0 1.46 0 3.25V14.75C0 16.54 1.46 18 3.25 18H14.75C16.54 18 18 16.54 18 14.75V3.25C18 1.46 16.54 0 14.75 0H3.25ZM1.5 3.25C1.5 2.28 2.28 1.5 3.25 1.5H14.75C15.72 1.5 16.5 2.28 16.5 3.25V14.75C16.5 15.72 15.72 16.5 14.75 16.5H3.25C2.28 16.5 1.5 15.72 1.5 14.75V3.25Z M13.1799 11.92L9.67995 4.67003C9.42995 4.15003 8.57995 4.15003 8.32995 4.67003L4.82995 11.92C4.64995 12.29 4.80995 12.74 5.17995 12.92C5.55995 13.1 5.99995 12.94 6.17995 12.57L6.81995 11.24H11.1899L11.8299 12.57C11.9599 12.84 12.2299 12.99 12.5099 12.99C12.6199 12.99 12.7299 12.97 12.8399 12.92C13.2099 12.74 13.3699 12.29 13.1899 11.92H13.1799ZM7.53995 9.75003L8.99995 6.73003L10.4599 9.75003H7.53995Z</StreamGeometry>
<StreamGeometry x:Key="rocket_bolt">M 19.18 2.33 c -0.27 -0.87 -0.95 -1.55 -1.82 -1.82 l -0.67 -0.21 c -2.41 -0.75 -5.03 -0.1 -6.81 1.68 c -1.81 1.81 -3.61 3.62 -5.42 5.42 c -0.69 0.69 -0.69 1.8 0 2.49 l 0.5 0.5 l -1.4 0.8 c -0.36 0.21 -0.49 0.67 -0.28 1.03 c 0.03 0.06 0.07 0.11 0.12 0.16 l 3.9 3.91 c 0.29 0.29 0.77 0.29 1.07 0 c 0.05 -0.05 0.09 -0.1 0.12 -0.16 l 0.8 -1.4 l 0.5 0.5 c 0.69 0.69 1.8 0.69 2.49 0 c 0 0 0 0 0 0 c 1.81 -1.81 3.61 -3.62 5.42 -5.42 c 1.78 -1.78 2.43 -4.4 1.68 -6.81 l -0.2 -0.67 Z M 16.91 1.95 c 0.4 0.12 0.71 0.43 0.83 0.83 l 0.21 0.67 c 0.58 1.87 0.08 3.91 -1.31 5.3 l -5.42 5.42 c -0.1 0.1 -0.26 0.1 -0.35 0 l -5.33 -5.33 c -0.1 -0.1 -0.1 -0.26 0 -0.35 c 0 0 0 0 0 0 l 5.42 -5.42 c 1.38 -1.39 3.42 -1.89 5.29 -1.31 l 0.66 0.21 Z M 8.19 13.63 l -0.52 0.9 l -2.51 -2.51 l 0.9 -0.51 l 2.13 2.13 Z M 4.28 16.47 c 0.28 -0.31 0.26 -0.78 -0.04 -1.07 c -0.29 -0.27 -0.73 -0.27 -1.02 0 l -2.49 2.49 c -0.28 0.31 -0.26 0.78 0.04 1.07 c 0.29 0.27 0.73 0.27 1.02 0 l 2.49 -2.49 Z M 2.33 13.45 c 0.29 0.29 0.29 0.77 0 1.07 l -1.07 1.07 c -0.31 0.28 -0.78 0.26 -1.07 -0.04 c -0.27 -0.29 -0.27 -0.73 0 -1.02 l 1.07 -1.07 c 0.29 -0.29 0.77 -0.29 1.07 0 Z M 6.24 18.43 c 0.31 -0.28 0.33 -0.76 0.04 -1.07 c -0.28 -0.31 -0.76 -0.33 -1.07 -0.04 c -0.02 0.01 -0.03 0.03 -0.04 0.04 l -1.06 1.06 c -0.31 0.28 -0.33 0.76 -0.04 1.07 c 0.28 0.31 0.76 0.33 1.07 0.04 c 0.02 -0.01 0.03 -0.03 0.04 -0.04 l 1.06 -1.06 Z M 14.38 7.1 l -2.63 4.03 c -0.09 0.15 -0.26 0.24 -0.43 0.24 c -0.35 0 -0.6 -0.35 -0.49 -0.68 l 0.77 -2.32 h -0.78 c -0.35 0 -0.59 -0.35 -0.47 -0.68 l 1.13 -3 c 0.07 -0.19 0.26 -0.32 0.47 -0.32 h 1.43 c 0.35 0 0.59 0.35 0.47 0.68 l -0.5 1.32 h 0.63 c 0.38 0 0.6 0.41 0.4 0.73 Z</StreamGeometry>
<StreamGeometry x:Key="rocket_confirmed">M 17.28 10.23 C 16.73 10.01 16.13 9.89 15.5 9.88 C 15.45 9.87 15.39 9.87 15.34 9.87 c -2.38 0 -4.4 1.51 -5.16 3.62 c -0.21 0.56 -0.33 1.16 -0.34 1.79 v 0.09 c 0 3.04 2.46 5.5 5.5 5.5 c 3.04 0 5.5 -2.46 5.5 -5.5 c 0 -2.36 -1.48 -4.36 -3.56 -5.14 z m 0.77 3.93 l -3.13 3.13 c -0.09 0.09 -0.22 0.14 -0.35 0.14 c -0.14 0 -0.26 -0.05 -0.36 -0.14 l -1.58 -1.58 c -0.19 -0.2 -0.19 -0.51 0 -0.71 c 0.2 -0.19 0.52 -0.19 0.71 0 l 1.23 1.23 l 2.77 -2.78 c 0.19 -0.19 0.51 -0.19 0.71 0 c 0.19 0.2 0.19 0.52 0 0.71 z m -3.82 -8.7 c -0.98 -0.98 -2.57 -0.98 -3.55 0 c -0.49 0.49 -0.74 1.13 -0.74 1.77 c 0 0.64 0.25 1.29 0.74 1.78 c 0.37 0.37 0.82 0.6 1.3 0.69 c 0.72 -0.44 1.53 -0.73 2.4 -0.86 c 0.83 -0.99 0.78 -2.45 -0.15 -3.38 z m -1.06 2.49 c -0.4 0.39 -1.03 0.39 -1.42 0 c -0.4 -0.4 -0.4 -1.03 0 -1.43 c 0.39 -0.39 1.02 -0.39 1.42 0 v 0 c 0.39 0.4 0.39 1.03 0 1.43 z m 1.06 -2.49 c -0.98 -0.98 -2.57 -0.98 -3.55 0 c -0.49 0.49 -0.74 1.13 -0.74 1.77 c 0 0.64 0.25 1.29 0.74 1.78 c 0.37 0.37 0.82 0.6 1.3 0.69 c 0.72 -0.44 1.53 -0.73 2.4 -0.86 c 0.83 -0.99 0.78 -2.45 -0.15 -3.38 z m -1.06 2.49 c -0.4 0.39 -1.03 0.39 -1.42 0 c -0.4 -0.4 -0.4 -1.03 0 -1.43 c 0.39 -0.39 1.02 -0.39 1.42 0 v 0 c 0.39 0.4 0.39 1.03 0 1.43 z M 19.38 3 L 19.17 2.34 C 18.9 1.47 18.22 0.79 17.35 0.52 L 16.69 0.31 C 14.28 -0.44 11.66 0.21 9.88 1.99 l -1 1 C 7.48 1.94 5.52 2.08 4.29 3.32 L 3.04 4.57 c -0.29 0.29 -0.29 0.77 0 1.06 l 1.6 1.6 l -0.18 0.18 c -0.69 0.69 -0.69 1.8 0 2.49 l 0.5 0.5 l -1.41 0.8 c -0.36 0.21 -0.48 0.67 -0.28 1.03 c 0.04 0.06 0.08 0.11 0.13 0.16 l 3.9 3.91 c 0.29 0.29 0.77 0.29 1.07 0 c 0.04 -0.05 0.08 -0.1 0.12 -0.16 l 0.26 -0.46 c -0.01 -0.1 -0.01 -0.2 -0.01 -0.31 c 0 -0.97 0.21 -1.89 0.6 -2.72 L 5.52 8.83 C 5.43 8.74 5.43 8.58 5.52 8.48 l 5.43 -5.42 c 1.38 -1.39 3.42 -1.89 5.29 -1.31 l 0.67 0.21 c 0.39 0.12 0.7 0.43 0.82 0.82 l 0.21 0.67 c 0.58 1.87 0.08 3.91 -1.31 5.3 l -0.12 0.13 c 0.56 0.09 1.09 0.26 1.58 0.5 C 19.57 7.62 20.06 5.22 19.38 3 Z M 6.06 11.5 L 8.19 13.63 L 7.67 14.53 L 5.16 12.02 Z M 5.7 6.17 L 4.64 5.1 L 5.35 4.39 C 6 3.74 7.01 3.61 7.8 4.08 Z m 8.53 -0.71 c -0.98 -0.98 -2.57 -0.98 -3.55 0 c -0.49 0.49 -0.74 1.13 -0.74 1.77 c 0 0.64 0.25 1.29 0.74 1.78 c 0.37 0.37 0.82 0.6 1.3 0.69 c 0.72 -0.44 1.53 -0.73 2.4 -0.86 c 0.83 -0.99 0.78 -2.45 -0.15 -3.38 z m -1.06 2.49 c -0.4 0.39 -1.03 0.39 -1.42 0 c -0.4 -0.4 -0.4 -1.03 0 -1.43 c 0.39 -0.39 1.02 -0.39 1.42 0 v 0 c 0.39 0.4 0.39 1.03 0 1.43 z m 1.06 -2.49 c -0.98 -0.98 -2.57 -0.98 -3.55 0 c -0.49 0.49 -0.74 1.13 -0.74 1.77 c 0 0.64 0.25 1.29 0.74 1.78 c 0.37 0.37 0.82 0.6 1.3 0.69 c 0.72 -0.44 1.53 -0.73 2.4 -0.86 c 0.83 -0.99 0.78 -2.45 -0.15 -3.38 z m -1.06 2.49 c -0.4 0.39 -1.03 0.39 -1.42 0 c -0.4 -0.4 -0.4 -1.03 0 -1.43 c 0.39 -0.39 1.02 -0.39 1.42 0 v 0 c 0.39 0.4 0.39 1.03 0 1.43 z M 4.24 15.41 C 3.95 15.14 3.5 15.14 3.22 15.41 L 0.73 17.9 c -0.28 0.3 -0.26 0.78 0.04 1.06 c 0.29 0.27 0.74 0.27 1.02 0 L 4.28 16.48 C 4.56 16.17 4.54 15.69 4.24 15.41 Z M 2.33 13.46 c -0.3 -0.3 -0.77 -0.3 -1.07 0 L 0.2 14.52 c -0.27 0.29 -0.27 0.74 0 1.02 c 0.28 0.31 0.76 0.33 1.06 0.05 l 1.07 -1.07 c 0.29 -0.29 0.29 -0.77 0 -1.06 z m 3.95 3.91 C 6 17.06 5.52 17.04 5.21 17.32 C 5.2 17.34 5.18 17.35 5.17 17.37 l -1.06 1.06 c -0.31 0.28 -0.33 0.76 -0.05 1.06 c 0.29 0.31 0.76 0.33 1.07 0.05 c 0.01 -0.02 0.03 -0.03 0.04 -0.05 l 1.06 -1.06 c 0.31 -0.28 0.33 -0.76 0.05 -1.06 z</StreamGeometry>
<StreamGeometry x:Key="globe">M16 30C23.732 30 30 23.732 30 16C30 8.26801 23.732 2 16 2C8.26801 2 2 8.26801 2 16C2 23.732 8.26801 30 16 30ZM16 4C17.0317 4 18.283 4.94804 19.3347 7.22667C19.7084 8.03639 20.0331 8.9697 20.2941 10H11.7059C11.9669 8.9697 12.2916 8.03639 12.6653 7.22667C13.717 4.94804 14.9683 4 16 4ZM10.8494 6.38855C10.36 7.44883 9.95424 8.66735 9.64867 10H5.60539C6.97928 7.62495 9.1438 5.76448 11.7391 4.77849C11.4088 5.27683 11.1118 5.81994 10.8494 6.38855ZM9.27878 12C9.0968 13.2705 9 14.6141 9 16C9 17.3859 9.0968 18.7295 9.27878 20H4.68282C4.24062 18.7489 4 17.4025 4 16C4 14.5975 4.24062 13.2511 4.68282 12H9.27878ZM9.64867 22C9.95424 23.3327 10.36 24.5512 10.8494 25.6114C11.1118 26.1801 11.4088 26.7232 11.7391 27.2215C9.1438 26.2355 6.97928 24.375 5.60539 22H9.64867ZM11.7059 22H20.2941C20.0331 23.0303 19.7084 23.9636 19.3347 24.7733C18.283 27.052 17.0317 28 16 28C14.9683 28 13.717 27.052 12.6653 24.7733C12.2916 23.9636 11.9669 23.0303 11.7059 22ZM20.6991 20H11.3009C11.1068 18.7518 11 17.4068 11 16C11 14.5932 11.1068 13.2482 11.3009 12H20.6991C20.8932 13.2482 21 14.5932 21 16C21 17.4068 20.8932 18.7518 20.6991 20ZM22.3513 22H26.3946C25.0207 24.375 22.8562 26.2355 20.2609 27.2215C20.5912 26.7232 20.8882 26.1801 21.1506 25.6114C21.64 24.5512 22.0458 23.3327 22.3513 22ZM27.3172 20H22.7212C22.9032 18.7295 23 17.3859 23 16C23 14.6141 22.9032 13.2705 22.7212 12H27.3172C27.7594 13.2511 28 14.5975 28 16C28 17.4025 27.7594 18.7489 27.3172 20ZM20.2609 4.77849C22.8562 5.76448 25.0207 7.62495 26.3946 10H22.3513C22.0458 8.66735 21.64 7.44883 21.1506 6.38855C20.8882 5.81994 20.5912 5.27683 20.2609 4.77849Z</StreamGeometry>
<StreamGeometry x:Key="read_more">M17.75 2.00098C18.9409 2.00098 19.9156 2.92614 19.9948 4.09693L20 4.25098V19.749C20 20.9399 19.0748 21.9147 17.904 21.9939L17.75 21.999H6.25012C5.05926 21.999 4.08448 21.0739 4.00531 19.9031L4.00012 19.749V4.25098C4.00012 3.06011 4.92528 2.08533 6.09607 2.00617L6.25012 2.00098H17.75ZM17.75 3.50098H6.25012C5.87043 3.50098 5.55663 3.78313 5.50697 4.14921L5.50012 4.25098V19.749C5.50012 20.1287 5.78228 20.4425 6.14835 20.4922L6.25012 20.499H17.75C18.1297 20.499 18.4435 20.2169 18.4931 19.8508L18.5 19.749V4.25098C18.5 3.87128 18.2178 3.55749 17.8518 3.50782L17.75 3.50098ZM12.2482 12.9973C12.6624 12.9973 12.9982 13.3331 12.9982 13.7473C12.9982 14.127 12.716 14.4408 12.35 14.4905L12.2482 14.4973H7.75006C7.33585 14.4973 7.00006 14.1615 7.00006 13.7473C7.00006 13.3676 7.28221 13.0538 7.64829 13.0042L7.75006 12.9973H12.2482ZM16.2501 9.99866C16.6643 9.99866 17.0001 10.3344 17.0001 10.7487C17.0001 11.1284 16.7179 11.4421 16.3518 11.4918L16.2501 11.4987H7.75006C7.33585 11.4987 7.00006 11.1629 7.00006 10.7487C7.00006 10.369 7.28221 10.0552 7.64829 10.0055L7.75006 9.99866H16.2501ZM16.2501 7.00001C16.6643 7.00001 17.0001 7.3358 17.0001 7.75001C17.0001 8.12971 16.7179 8.4435 16.3518 8.49316L16.2501 8.50001H7.75006C7.33585 8.50001 7.00006 8.16422 7.00006 7.75001C7.00006 7.37031 7.28221 7.05652 7.64829 7.00686L7.75006 7.00001H16.2501Z</StreamGeometry>
<StreamGeometry x:Key="input_count">M7.5 9C9.15685 9 10.5 7.65685 10.5 6C10.5 4.34315 9.15685 3 7.5 3C5.84315 3 4.5 4.34315 4.5 6C4.5 7.65685 5.84315 9 7.5 9ZM7.5 7.5C6.67157 7.5 6 6.82843 6 6C6 5.17157 6.67157 4.5 7.5 4.5C8.32843 4.5 9 5.17157 9 6C9 6.82843 8.32843 7.5 7.5 7.5ZM3 11.75C3 10.7835 3.7835 10 4.75 10H10.25C11.2165 10 12 10.7835 12 11.75V16.5C12 18.9853 9.98528 21 7.5 21C5.01472 21 3 18.9853 3 16.5V11.75ZM4.75 11.5C4.61193 11.5 4.5 11.6119 4.5 11.75V16.5C4.5 18.1569 5.84315 19.5 7.5 19.5C9.15685 19.5 10.5 18.1569 10.5 16.5V11.75C10.5 11.6119 10.3881 11.5 10.25 11.5H4.75ZM10.5273 8.61436C10.9623 8.85989 11.4647 9 11.9999 9C13.6567 9 14.9999 7.65685 14.9999 6C14.9999 4.34315 13.6567 3 11.9999 3C11.4647 3 10.9623 3.14011 10.5273 3.38564C10.8539 3.76346 11.1109 4.20305 11.2785 4.68452C11.4925 4.5669 11.7384 4.5 11.9999 4.5C12.8283 4.5 13.4999 5.17157 13.4999 6C13.4999 6.82843 12.8283 7.5 11.9999 7.5C11.7384 7.5 11.4925 7.4331 11.2785 7.31548C11.1109 7.79695 10.8539 8.23654 10.5273 8.61436ZM10.8602 20.8544C11.2242 20.9494 11.6061 21 11.9999 21C14.4851 21 16.4999 18.9853 16.4999 16.5V11.75C16.4999 10.7835 15.7164 10 14.7499 10H12.3713C12.7142 10.4152 12.9375 10.9328 12.9887 11.5H14.7499C14.8879 11.5 14.9999 11.6119 14.9999 11.75V16.5C14.9999 18.1194 13.7168 19.4391 12.1117 19.4979C11.7733 20.0175 11.3495 20.4763 10.8602 20.8544ZM15.0273 8.61436C15.4623 8.85989 15.9647 9 16.4999 9C18.1567 9 19.4999 7.65685 19.4999 6C19.4999 4.34315 18.1567 3 16.4999 3C15.9647 3 15.4623 3.14011 15.0273 3.38564C15.3539 3.76346 15.6109 4.20305 15.7785 4.68452C15.9925 4.5669 16.2384 4.5 16.4999 4.5C17.3283 4.5 17.9999 5.17157 17.9999 6C17.9999 6.82843 17.3283 7.5 16.4999 7.5C16.2384 7.5 15.9925 7.4331 15.7785 7.31548C15.6109 7.79695 15.3539 8.23654 15.0273 8.61436ZM15.3602 20.8544C15.7242 20.9494 16.1061 21 16.4999 21C18.9851 21 20.9999 18.9853 20.9999 16.5V11.75C20.9999 10.7835 20.2164 10 19.2499 10H16.8713C17.2142 10.4152 17.4375 10.9328 17.4887 11.5H19.2499C19.3879 11.5 19.4999 11.6119 19.4999 11.75V16.5C19.4999 18.1194 18.2168 19.4391 16.6117 19.4979C16.2733 20.0175 15.8495 20.4763 15.3602 20.8544Z</StreamGeometry>

<ControlTemplate x:Key="wasabi_logo_text_dynamic">
<StackPanel Margin="0,0,0,-5" TextElement.FontFamily="{StaticResource WasabiLogoTextFont}"
Expand Down
Loading

0 comments on commit 40ab4a1

Please sign in to comment.