public SendViewModel(Wallet wallet, IObservable <Unit> balanceChanged, ObservableCollection <HistoryItemViewModelBase> history)
    {
        _to              = "";
        _wallet          = wallet;
        _transactionInfo = new TransactionInfo(wallet.KeyManager.MinAnonScoreTarget);
        _coinJoinManager = Services.HostedServices.GetOrDefault <CoinJoinManager>();

        IsQrButtonVisible = WebcamQrReader.IsOsPlatformSupported;

        ExchangeRate = _wallet.Synchronizer.UsdExchangeRate;

        Balance = new WalletBalanceTileViewModel(wallet, balanceChanged, history);

        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;
            }
示例#2
0
        protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
        {
            Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");

            Observable.Merge(
                Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default))
            .Throttle(TimeSpan.FromSeconds(0.1))
            .Merge(uiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
            .Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(
                _ =>
            {
                try
                {
                    var balance = Wallet.Coins.TotalAmount();
                    Title       = $"{WalletName} ({(uiConfig.PrivacyMode ? "#########" : balance.ToString(false))} BTC)";

                    TitleTip = balance.ToUsdString(Wallet.Synchronizer.UsdExchangeRate, uiConfig.PrivacyMode);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
            })
            .DisposeWith(Disposables);

            History        = new HistoryViewModel(wallet, uiConfig);
            BalanceTile    = new WalletBalanceTileViewModel(wallet);
            WalletPieChart = new WalletPieChartTileViewModel(wallet);
        }
示例#3
0
        protected WalletViewModel(UiConfig uiConfig, Wallet wallet) : base(wallet)
        {
            Disposables = Disposables is null
                                ? new CompositeDisposable()
                                : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it.");

            var balanceChanged =
                Observable.FromEventPattern(Wallet.TransactionProcessor, nameof(Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default)
                .Throttle(TimeSpan.FromSeconds(0.1))
                .Merge(Observable.FromEventPattern(Wallet, nameof(Wallet.NewFilterProcessed)).Select(_ => Unit.Default))
                .Merge(uiConfig.WhenAnyValue(x => x.PrivacyMode).Select(_ => Unit.Default))
                .Merge(Wallet.Synchronizer.WhenAnyValue(x => x.UsdExchangeRate).Select(_ => Unit.Default))
                .ObserveOn(RxApp.MainThreadScheduler);

            History          = new HistoryViewModel(wallet, uiConfig, balanceChanged);
            BalanceTile      = new WalletBalanceTileViewModel(wallet, balanceChanged);
            BalanceChartTile = new WalletBalanceChartTileViewModel(History.Transactions);
            WalletPieChart   = new WalletPieChartTileViewModel(wallet, balanceChanged);
        }