public SendViewModel(Wallet wallet)
        {
            _to              = "";
            _wallet          = wallet;
            _transactionInfo = new TransactionInfo();

            SuggestionLabels = new SuggestionLabelsViewModel(3);

            IsQrButtonVisible = WebcamQrReader.IsOsPlatformSupported;

            ExchangeRate = _wallet.Synchronizer.UsdExchangeRate;

            SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

            EnableBack = false;

            this.ValidateProperty(x => x.To, ValidateToField);
            this.ValidateProperty(x => x.AmountBtc, ValidateAmount);

            this.WhenAnyValue(x => x.To)
            .Skip(1)
            .Subscribe(ParseToField);

            this.WhenAnyValue(x => x.PayJoinEndPoint)
            .Subscribe(endPoint =>
            {
                if (endPoint is { })
                {
                    _transactionInfo.PayJoinClient = GetPayjoinClient(endPoint);
                    IsPayJoin = true;
                }
Example #2
0
        public ReceiveViewModel(Wallet wallet)
        {
            _wallet = wallet;
            SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

            EnableBack = false;

            SuggestionLabels = new SuggestionLabelsViewModel(3);

            NextCommand = ReactiveCommand.Create(OnNext, SuggestionLabels.WhenAnyValue(x => x.Labels.Count).Select(c => c > 0));

            ShowExistingAddressesCommand = ReactiveCommand.Create(OnShowExistingAddresses);
        }
Example #3
0
    public LabelEntryDialogViewModel(Wallet wallet, TransactionInfo info)
    {
        _wallet          = wallet;
        SuggestionLabels = new SuggestionLabelsViewModel(wallet.KeyManager, Intent.Send, 3)
        {
            Labels = { info.UserLabels.Labels }
        };

        SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

        var nextCommandCanExecute =
            Observable
            .Merge(SuggestionLabels.WhenAnyValue(x => x.Labels.Count).Select(_ => Unit.Default))
            .Merge(SuggestionLabels.WhenAnyValue(x => x.IsCurrentTextValid).Select(_ => Unit.Default))
            .Select(_ => SuggestionLabels.Labels.Any() || SuggestionLabels.IsCurrentTextValid);

        NextCommand = ReactiveCommand.Create(OnNext, nextCommandCanExecute);
    }
Example #4
0
    public ReceiveViewModel(Wallet wallet)
    {
        _wallet = wallet;
        SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

        EnableBack = false;

        SuggestionLabels = new SuggestionLabelsViewModel(wallet.KeyManager, Intent.Receive, 3);

        var nextCommandCanExecute =
            SuggestionLabels
            .WhenAnyValue(x => x.Labels.Count).Select(_ => Unit.Default)
            .Merge(SuggestionLabels.WhenAnyValue(x => x.IsCurrentTextValid).Select(_ => Unit.Default))
            .Select(_ => SuggestionLabels.Labels.Count > 0 || SuggestionLabels.IsCurrentTextValid);

        NextCommand = ReactiveCommand.Create(OnNext, nextCommandCanExecute);

        ShowExistingAddressesCommand = ReactiveCommand.Create(OnShowExistingAddresses);
    }
Example #5
0
    public AddressLabelEditViewModel(ReceiveAddressesViewModel owner, HdPubKey hdPubKey, KeyManager keyManager)
    {
        SuggestionLabels = new SuggestionLabelsViewModel(keyManager, Intent.Receive, 3, hdPubKey.Label);

        SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true);

        var canExecute =
            this.WhenAnyValue(x => x.SuggestionLabels.Labels.Count, x => x.IsCurrentTextValid)
            .Select(tup =>
        {
            var(labelsCount, isCurrentTextValid) = tup;
            return(labelsCount > 0 || isCurrentTextValid);
        });

        NextCommand = ReactiveCommand.Create(
            () =>
        {
            hdPubKey.SetLabel(new SmartLabel(SuggestionLabels.Labels), kmToFile: keyManager);
            owner.InitializeAddresses();
            Navigate().Back();
        },
            canExecute);
    }