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

Introduce Label class (MempoolStore Breakdown Part 3) #2201

Merged
merged 16 commits into from Sep 9, 2019
@@ -159,7 +159,7 @@ public string ToolTip

public string AmountBtc => Model.Amount.ToString(false, true);

public string Label => Model.Label;
public string Label => Model.Label.ToString();

public int Height => Model.Height;

@@ -177,7 +177,7 @@ private List<(DateTimeOffset dateTime, Height height, Money amount, string label
}
else
{
txRecordList.Add((dateTime, coin.Height, coin.Amount, coin.Label, coin.TransactionId));
txRecordList.Add((dateTime, coin.Height, coin.Amount, coin.Label.ToString(), coin.TransactionId));
}

if (coin.SpenderTransactionId != null)
@@ -13,6 +13,7 @@
using WalletWasabi.Gui.Tabs.WalletManager;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.KeyManagement;
using WalletWasabi.Models;

namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -43,8 +44,9 @@ public ReceiveTabViewModel(WalletViewModel walletViewModel)

GenerateCommand = ReactiveCommand.Create(() =>
{
Label = Label.Trim(',', ' ').Trim();
if (string.IsNullOrWhiteSpace(Label))
var label = new Label(Label);
Label = label.ToString();
if (label.IsEmpty)
{
LabelRequiredNotificationVisible = true;
LabelRequiredNotificationOpacity = 1;
@@ -60,8 +62,7 @@ public ReceiveTabViewModel(WalletViewModel walletViewModel)

Dispatcher.UIThread.PostLogException(() =>
{
var label = Label;
HdPubKey newKey = Global.WalletService.GetReceiveKey(label, Addresses.Select(x => x.Model).Take(7)); // Never touch the first 7 keys.
HdPubKey newKey = Global.WalletService.GetReceiveKey(new Label(Label), Addresses.Select(x => x.Model).Take(7)); // Never touch the first 7 keys.

AddressViewModel found = Addresses.FirstOrDefault(x => x.Model == newKey);
if (found != default)
@@ -164,7 +165,7 @@ private void InitializeAddresses()
}

foreach (HdPubKey key in walletService.KeyManager.GetKeys(x =>
x.HasLabel
!x.Label.IsEmpty
&& !x.IsInternal
&& x.KeyState == KeyState.Clean)
.Reverse())
@@ -233,8 +234,8 @@ private void UpdateSuggestions(string words)
}

var labels = Global.WalletService.GetLabels();
IEnumerable<string> suggestedWords = labels.Where(w => w.StartsWith(lastWord, StringComparison.InvariantCultureIgnoreCase))
.Union(labels.Where(w => w.Contains(lastWord, StringComparison.InvariantCultureIgnoreCase)))
IEnumerable<string> suggestedWords = labels.Where(w => w.StartsWith(lastWord, StringComparison.OrdinalIgnoreCase))
.Union(labels.Where(w => w.Contains(lastWord, StringComparison.OrdinalIgnoreCase)))
.Except(enteredWordList)
.Take(3);

@@ -222,9 +222,10 @@ public SendTabViewModel(WalletViewModel walletViewModel, bool isTransactionBuild

OnAddressPasteCommand = ReactiveCommand.Create((BitcoinUrlBuilder url) =>
{
if (!string.IsNullOrWhiteSpace(url.Label))
var label = new Label(url.Label);
if (!label.IsEmpty)
{
Label = url.Label;
Label = label.ToString();
}

if (url.Amount != null)
@@ -241,8 +242,9 @@ public SendTabViewModel(WalletViewModel walletViewModel, bool isTransactionBuild
IsBusy = true;
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusBarStatus.BuildingTransaction);

Label = Label.Trim(',', ' ').Trim();
if (!IsMax && string.IsNullOrWhiteSpace(Label))
var label = new Label(Label);
Label = label.ToString();
if (!IsMax && label.IsEmpty)
{
SetWarningMessage($"{nameof(Label)} is required.");
return;
@@ -298,7 +300,6 @@ public SendTabViewModel(WalletViewModel walletViewModel, bool isTransactionBuild
bool useCustomFee = !IsSliderFeeUsed;
var feeStrategy = FeeStrategy.CreateFromFeeRate(FeeRate);

var label = Label;
var intent = new PaymentIntent(address, moneyRequest, label);
try
{
@@ -10,6 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.KeyManagement;
using WalletWasabi.Models;

namespace WalletWasabi.Gui.ViewModels
{
@@ -33,7 +34,7 @@ public AddressViewModel(HdPubKey model, Global global)
Model = model;
ClipboardNotificationVisible = false;
ClipboardNotificationOpacity = 0;
_label = model.Label;
_label = model.Label.ToString();

this.WhenAnyValue(x => x.IsExpanded)
.ObserveOn(RxApp.TaskpoolScheduler)
@@ -70,7 +71,7 @@ public AddressViewModel(HdPubKey model, Global global)

if (hdPubKey != default)
{
hdPubKey.SetLabel(newLabel, kmToFile: keyManager);
hdPubKey.SetLabel(new Label(newLabel), kmToFile: keyManager);
}
}
});
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.