Skip to content

Commit

Permalink
Select script type while receiving (WalletWasabi#13294)
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolay authored Aug 6, 2024
1 parent bea1dbe commit f3f072e
Show file tree
Hide file tree
Showing 27 changed files with 251 additions and 57 deletions.
6 changes: 4 additions & 2 deletions WalletWasabi.Daemon/Rpc/WasabiJsonRpcService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,15 @@ public JsonRpcResult WalletInfo()
}

[JsonRpcMethod("getnewaddress")]
public JsonRpcResult GenerateReceiveAddress(string label)
public JsonRpcResult GenerateReceiveAddress(string label, bool taproot = false)
{
AssertWalletIsLoaded();
label = Guard.NotNullOrEmptyOrWhitespace(nameof(label), label, true);
var activeWallet = Guard.NotNull(nameof(ActiveWallet), ActiveWallet);

var hdKey = activeWallet.KeyManager.GetNextReceiveKey(new LabelsArray(label));
var hdKey = taproot
? activeWallet.KeyManager.GetNextReceiveKey(new LabelsArray(label), ScriptPubKeyType.TaprootBIP86)
: activeWallet.KeyManager.GetNextReceiveKey(new LabelsArray(label));

return new JsonRpcResult
{
Expand Down
10 changes: 10 additions & 0 deletions WalletWasabi.Fluent/Converters/ScriptTypeConverters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Avalonia.Data.Converters;
using WalletWasabi.Fluent.Models.Wallets;

namespace WalletWasabi.Fluent.Converters;

public static class ScriptTypeConverters
{
public static readonly IValueConverter IsSegwit = new FuncValueConverter<ScriptType, bool>(x => x == ScriptType.SegWit);
public static readonly IValueConverter IsTaproot = new FuncValueConverter<ScriptType, bool>(x => x == ScriptType.Taproot);
}
4 changes: 3 additions & 1 deletion WalletWasabi.Fluent/Icons/Icons.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@
<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>
<StreamGeometry x:Key="segwit_short">M3.47161 0.790119C1.96222 0.790119 0.738617 1.87657 0.738617 3.21678C0.738617 4.55699 0.738617 13.7901 0.738617 13.7901C0.738617 15.1303 1.96222 16.2168 3.47161 16.2168L19.5 16.2168C21.0093 16.2168 22.233 14.4086 22.233 13.0684V3.21678C22.233 1.87657 21.0093 0.790115 19.5 0.790115L3.47161 0.790119ZM2 3.21678C2 2.49512 2.65886 1.91012 3.47161 1.91012L19.5 1.91011C20.3128 1.91011 20.9716 2.49512 20.9716 3.21678V13.7901C20.9716 14.5118 20.3128 15.0968 19.5 15.0968C13.8241 15.0968 9.1475 15.0968 3.47161 15.0968C2.65886 15.0968 2 14.5118 2 13.7901V3.21678Z M9.00076 6.87769C8.74675 6.87769 8.54894 6.67439 8.42029 6.45537C8.34992 6.33558 8.25346 6.23307 8.13089 6.14784C7.88281 5.97311 7.57058 5.88575 7.19419 5.88575C6.92473 5.88575 6.69162 5.92998 6.49487 6.01845C6.29812 6.10471 6.14521 6.22414 6.03614 6.37675C5.92921 6.52715 5.87575 6.69854 5.87575 6.89096C5.87575 7.05242 5.91211 7.19175 5.98482 7.30897C6.05967 7.4262 6.15697 7.52461 6.27674 7.60424C6.39863 7.68165 6.52909 7.74689 6.6681 7.79997C6.8071 7.85084 6.94077 7.89286 7.06908 7.92604L7.71066 8.09855C7.92024 8.15163 8.13517 8.22351 8.35544 8.31419C8.57572 8.40487 8.77995 8.52429 8.96815 8.67248C9.15634 8.82067 9.30818 9.00423 9.42367 9.22319C9.54129 9.44216 9.6001 9.70423 9.6001 10.0094C9.6001 10.3943 9.50386 10.736 9.31139 11.0346C9.12106 11.3332 8.84411 11.5687 8.48055 11.7412C8.11913 11.9137 7.68179 12 7.16853 12C6.67665 12 6.25107 11.9192 5.89179 11.7578C5.53251 11.5963 5.25128 11.3674 5.04812 11.0711C4.9364 10.9069 4.85217 10.726 4.79542 10.5284C4.71636 10.2531 4.95453 10.0094 5.24092 10.0094C5.50191 10.0094 5.70548 10.2209 5.82485 10.453C5.85619 10.514 5.89347 10.5707 5.9367 10.6232C6.07357 10.7846 6.24786 10.9052 6.45958 10.9848C6.67344 11.0622 6.90762 11.1009 7.16211 11.1009C7.44227 11.1009 7.69141 11.0556 7.90955 10.9649C8.12982 10.872 8.30305 10.7437 8.42922 10.5801C8.5554 10.4142 8.61849 10.2207 8.61849 9.9995C8.61849 9.79823 8.56289 9.63346 8.45168 9.50518C8.34261 9.3769 8.19398 9.27075 8.00578 9.1867C7.81973 9.10265 7.60908 9.02857 7.37383 8.96443L6.59752 8.74547C6.07143 8.59728 5.65441 8.37944 5.34645 8.09191C5.04063 7.80439 4.88772 7.42399 4.88772 6.95068C4.88772 6.5592 4.99037 6.21751 5.19568 5.92556C5.40098 5.63361 5.679 5.40692 6.02973 5.24547C6.38046 5.0818 6.7761 4.99997 7.21664 4.99997C7.66147 4.99997 8.0539 5.08069 8.39394 5.24215C8.73611 5.40361 9.00557 5.62587 9.20232 5.90897C9.30357 6.05351 9.37989 6.20917 9.4313 6.37596C9.51362 6.64301 9.28021 6.87769 9.00076 6.87769Z M12.5323 11.9404C12.306 11.9404 12.108 11.7885 12.0493 11.57L10.4951 5.77435C10.4101 5.45741 10.6489 5.14613 10.977 5.14613C11.2072 5.14613 11.4075 5.30353 11.4619 5.52716L12.6419 10.378C12.6461 10.3954 12.6618 10.4077 12.6798 10.4077C12.6976 10.4077 12.7131 10.3956 12.7175 10.3783L13.9459 5.52348C14.002 5.30157 14.2017 5.14613 14.4306 5.14613H14.685C14.9139 5.14613 15.1136 5.30161 15.1697 5.52356L16.3981 10.3817C16.4025 10.3989 16.4181 10.4111 16.4359 10.4111C16.4539 10.4111 16.4695 10.3988 16.4737 10.3813L17.6506 5.52829C17.705 5.30404 17.9059 5.14613 18.1367 5.14613C18.4656 5.14613 18.7052 5.45821 18.6198 5.77585L17.0632 11.5702C17.0045 11.7886 16.8065 11.9404 16.5803 11.9404H16.3484C16.1227 11.9404 15.925 11.7893 15.8659 11.5715L14.5902 6.87611C14.5862 6.86149 14.573 6.85134 14.5578 6.85134C14.5427 6.85134 14.5294 6.86149 14.5254 6.87611L13.2498 11.5715C13.1906 11.7893 12.9929 11.9404 12.7673 11.9404H12.5323Z</StreamGeometry>
<StreamGeometry x:Key="taproot_short">M3.47161 0.790119C1.96222 0.790119 0.738617 1.87657 0.738617 3.21678C0.738617 4.55699 0.738617 13.7901 0.738617 13.7901C0.738617 15.1303 1.96222 16.2168 3.47161 16.2168L19.5 16.2168C21.0093 16.2168 22.233 14.4086 22.233 13.0684V3.21678C22.233 1.87657 21.0093 0.790115 19.5 0.790115L3.47161 0.790119ZM2 3.21678C2 2.49512 2.65886 1.91012 3.47161 1.91012L19.5 1.91011C20.3128 1.91011 20.9716 2.49512 20.9716 3.21678V13.7901C20.9716 14.5118 20.3128 15.0968 19.5 15.0968C13.8241 15.0968 9.1475 15.0968 3.47161 15.0968C2.65886 15.0968 2 14.5118 2 13.7901V3.21678Z M5.95459 5.90918C5.70352 5.90918 5.5 5.70565 5.5 5.45459C5.5 5.20353 5.70352 5 5.95459 5H10.5549C10.8059 5 11.0094 5.20353 11.0094 5.45459C11.0094 5.70565 10.8059 5.90918 10.5549 5.90918H9.28829C9.01215 5.90918 8.78829 6.13304 8.78829 6.40918V11.5C8.78829 11.7761 8.56443 12 8.28829 12H8.21768C7.94154 12 7.71768 11.7761 7.71768 11.5V6.40918C7.71768 6.13304 7.49382 5.90918 7.21768 5.90918H5.95459Z M12.7269 12C12.4508 12 12.2269 11.7761 12.2269 11.5V5.5C12.2269 5.22386 12.4508 5 12.7269 5H14.7644C15.3159 5 15.7736 5.09342 16.1374 5.28027C16.5035 5.46712 16.777 5.72575 16.9577 6.05615C17.1385 6.38428 17.2289 6.76367 17.2289 7.19434C17.2289 7.62272 17.1373 7.99984 16.9543 8.32568C16.7735 8.64925 16.5001 8.90104 16.1339 9.08105C15.7701 9.26107 15.3124 9.35107 14.7609 9.35107H13.2933C13.0422 9.35107 12.8387 9.14755 12.8387 8.89648C12.8387 8.64542 13.0422 8.4419 13.2933 8.4419H14.6636C15.0112 8.4419 15.2939 8.3929 15.5117 8.29492C15.7319 8.19694 15.8929 8.05453 15.9949 7.86768C16.0969 7.68083 16.1478 7.45638 16.1478 7.19434C16.1478 6.93001 16.0957 6.70101 15.9914 6.50733C15.8895 6.31364 15.7284 6.16553 15.5083 6.06299C15.2904 5.95817 15.0042 5.90576 14.6497 5.90576H13.801C13.5249 5.90576 13.301 6.12962 13.301 6.40576V11.5C13.301 11.7761 13.0771 12 12.801 12H12.7269ZM15.4473 8.8418C15.6287 8.8418 15.7959 8.94004 15.8841 9.09852L17.0861 11.2567C17.2717 11.59 17.0307 12 16.6492 12H16.5731C16.3902 12 16.2219 11.9001 16.1343 11.7396L14.9561 9.58138C14.7742 9.24818 15.0154 8.8418 15.395 8.8418H15.4473Z</StreamGeometry>

<ControlTemplate x:Key="wasabi_logo_text_dynamic">
<ControlTemplate x:Key="wasabi_logo_text_dynamic">
<StackPanel Margin="0,0,0,-5" TextElement.FontFamily="{StaticResource WasabiLogoTextFont}"
TextElement.FontWeight="Light" Orientation="Horizontal" ClipToBounds="False">
<TextBlock Text="WASABI" Classes="h6" Foreground="{DynamicResource TextForegroundColor}" ClipToBounds="False" />
Expand Down
18 changes: 16 additions & 2 deletions WalletWasabi.Fluent/Models/Wallets/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ReactiveUI;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Extensions;
using WalletWasabi.Hwi;
using WalletWasabi.Logging;

Expand All @@ -12,7 +13,7 @@ namespace WalletWasabi.Fluent.Models.Wallets;
public class Address : ReactiveObject, IAddress
{
private readonly Action<Address> _onHide;

public Address(KeyManager keyManager, HdPubKey hdPubKey, Action<Address> onHide)
{
KeyManager = keyManager;
Expand All @@ -32,6 +33,8 @@ public Address(KeyManager keyManager, HdPubKey hdPubKey, Action<Address> onHide)
public PubKey PubKey => HdPubKey.PubKey;
public KeyPath FullKeyPath => HdPubKey.FullKeyPath;
public string Text => BitcoinAddress.ToString();
public string ShortenedText => ShortenAddress(BitcoinAddress.ToString());
public ScriptType ScriptType => ScriptType.FromEnum(BitcoinAddress.ScriptPubKey.GetScriptType());

public void Hide()
{
Expand Down Expand Up @@ -74,12 +77,23 @@ public async Task ShowOnHwWalletAsync()
}
}

public static string ShortenAddress(string input)
{
// Don't shorten SegWit addresses
if (input.Length <= 47)
{
return input;
}

return $"{input[..21]}...{input[^20..]}";
}

public override int GetHashCode() => Text.GetHashCode();

public override bool Equals(object? obj)
{
return obj is IAddress address && Equals(address);
}

protected bool Equals(IAddress other) => Text.Equals(other.Text);
}
5 changes: 3 additions & 2 deletions WalletWasabi.Fluent/Models/Wallets/AddressesModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reactive.Linq;
using System.Reactive.Subjects;
using DynamicData;
using NBitcoin;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionProcessing;
using WalletWasabi.Fluent.Infrastructure;
Expand Down Expand Up @@ -45,9 +46,9 @@ public AddressesModel(Wallet wallet)

private IEnumerable<HdPubKey> GetUnusedKeys() => _wallet.KeyManager.GetKeys(x => x is { IsInternal: false, KeyState: KeyState.Clean, Labels.Count: > 0 });

public IAddress NextReceiveAddress(IEnumerable<string> destinationLabels)
public IAddress NextReceiveAddress(IEnumerable<string> destinationLabels, ScriptPubKeyType scriptPubKeyType)
{
var pubKey = _wallet.GetNextReceiveAddress(destinationLabels);
var pubKey = _wallet.GetNextReceiveAddress(destinationLabels, scriptPubKeyType);
var nextReceiveAddress = new Address(_wallet.KeyManager, pubKey, Hide);
_newAddressGenerated.OnNext(pubKey);

Expand Down
3 changes: 3 additions & 0 deletions WalletWasabi.Fluent/Models/Wallets/IAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ namespace WalletWasabi.Fluent.Models.Wallets;
public interface IAddress : IReactiveObject
{
string Text { get; }
string ShortenedText { get; }

LabelsArray Labels { get; }

ScriptType ScriptType { get; }

void Hide();

void SetLabels(LabelsArray labels);
Expand Down
27 changes: 27 additions & 0 deletions WalletWasabi.Fluent/Models/Wallets/ScriptType.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using NBitcoin;

namespace WalletWasabi.Fluent.Models.Wallets;

public record ScriptType(string Name, string ShortName)
Expand All @@ -6,6 +8,31 @@ public record ScriptType(string Name, string ShortName)
public static ScriptType SegWit = new("SegWit", "SW");
public static ScriptType Taproot = new("Taproot", "TR");

public static ScriptPubKeyType ToScriptPubKeyType(ScriptType scriptType)
{
if (scriptType == SegWit)
{
return ScriptPubKeyType.Segwit;
}

if (scriptType == Taproot)
{
return ScriptPubKeyType.TaprootBIP86;
}

throw new InvalidOperationException($"Cannot cast the ScriptType {scriptType.Name} to a ScriptPubKeyType");
}

public static ScriptType FromString(string str)
{
return str switch
{
"SegWit" => SegWit,
"Taproot" => Taproot,
_ => throw new InvalidOperationException($"Cannot cast the string {str} to a ScriptType")
};
}

public static ScriptType FromEnum(NBitcoin.ScriptType type)
{
return type switch
Expand Down
3 changes: 3 additions & 0 deletions WalletWasabi.Fluent/Models/Wallets/WalletModel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reactive.Linq;
Expand Down Expand Up @@ -85,6 +86,8 @@ public WalletModel(Wallet wallet, IAmountProvider amountProvider)

public Network Network => Wallet.Network;

public IEnumerable<ScriptPubKeyType> AvailableScriptPubKeyTypes => Wallet.KeyManager.AvailableScriptPubKeyTypes;

public IWalletTransactionsModel Transactions { get; }

public IObservable<Amount> Balances { get; }
Expand Down
1 change: 1 addition & 0 deletions WalletWasabi.Fluent/UiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using WalletWasabi.Fluent.Converters;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using WalletWasabi.Fluent.Models.Wallets;

namespace WalletWasabi.Fluent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@ public partial class AddressViewModel : ViewModelBase, IDisposable
private readonly CompositeDisposable _disposables = new();

[AutoNotify] private string _addressText;
[AutoNotify] private ScriptType _scriptType;
[AutoNotify] private LabelsArray _labels;

public AddressViewModel(UiContext context, AddressFunc onEdit, AddressAction onShow, IAddress address)
{
UiContext = context;
Address = address;
_addressText = address.Text;
_addressText = address.ShortenedText;

_scriptType = address.ScriptType;

this.WhenAnyValue(x => x.Address.Labels)
.BindTo(this, viewModel => viewModel.Labels)
.DisposeWith(_disposables);

CopyAddressCommand = ReactiveCommand.CreateFromTask(() => UiContext.Clipboard.SetTextAsync(AddressText));
CopyAddressCommand = ReactiveCommand.CreateFromTask(() => UiContext.Clipboard.SetTextAsync(Address.Text));
HideAddressCommand = ReactiveCommand.CreateFromTask(PromptHideAddressAsync);
EditLabelCommand = ReactiveCommand.CreateFromTask(() => onEdit(address));
NavigateCommand = ReactiveCommand.Create(() => onShow(address));
}

private IAddress Address { get; }
private bool AddressHasBeenShortened => Address.Text != AddressText;

public ICommand CopyAddressCommand { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public ReceiveAddressViewModel(UiContext uiContext, IWalletModel wallet, IAddres
UiContext = uiContext;
Model = model;
Address = model.Text;
ShortenedAddress = model.ShortenedText;
Labels = model.Labels;
ScriptType = model.ScriptType;
IsHardwareWallet = wallet.IsHardwareWallet;
IsAutoCopyEnabled = isAutoCopyEnabled;

Expand Down Expand Up @@ -53,9 +55,13 @@ public ReceiveAddressViewModel(UiContext uiContext, IWalletModel wallet, IAddres
public ICommand ShowOnHwWalletCommand { get; }

public string Address { get; }
public string ShortenedAddress { get; }
public bool AddressHasBeenShortened => Address != ShortenedAddress;

public LabelsArray Labels { get; }

public ScriptType ScriptType { get; }

public bool IsHardwareWallet { get; }

public IObservable<bool[,]> QrCode { get; }
Expand Down
Loading

0 comments on commit f3f072e

Please sign in to comment.