private async void OnInit(object sender, EventArgs args)
        {
            Initializing -= OnInit;

            while (Global.Wallet.State < WalletState.Initialized)
            {
                await Task.Delay(200);
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                CoinList = new CoinListViewModel();
                Observable.FromEventPattern(Global.Wallet.TransactionProcessor, nameof(Global.Wallet.TransactionProcessor.WalletRelevantTransactionProcessed))
                .Throttle(TimeSpan.FromSeconds(0.1))
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(_ =>
                {
                    Balance         = Global.Wallet.Coins.TotalAmount().ToString();
                    HasPrivateCoins = Enumerable.Where(
                        Global.Wallet.Coins,
                        c => c.Unspent && !c.SpentAccordingToBackend && c.AnonymitySet > 1
                        ).Sum(c => (long?)c.Amount) > 0;
                });

                Observable.FromEventPattern(Global.Wallet, nameof(Global.Wallet.NewBlockProcessed))
                .Merge(Observable.FromEventPattern(Global.Wallet.TransactionProcessor, nameof(Global.Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)))
                .Throttle(TimeSpan.FromSeconds(3))
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(async _ => await TryRewriteTableAsync());

                CoinJoinViewModel   = new CoinJoinViewModel(CoinList);
                SendAmountViewModel = new SendAmountViewModel(CoinList);
            });
        }
예제 #2
0
        public FeeViewModel(SendAmountViewModel sendAmountViewModel)
            : base(Locator.Current.GetService <IViewStackService>())
        {
            SendAmountViewModel = sendAmountViewModel;

            NavBackCommand = ReactiveCommand.CreateFromObservable <Unit, Unit>(_ =>
            {
                return(ViewStackService.PopModal());
            });
        }
예제 #3
0
        public SendWhoViewModel(SendAmountViewModel savm)
            : base(Locator.Current.GetService <IViewStackService>())
        {
            Global  = Locator.Current.GetService <Global>();
            Memo    = "";
            Address = "";

            SendAmountViewModel = savm;

            var canPromptPassword = this.WhenAnyValue(x => x.Memo, x => x.Address, x => x.IsBusy,
                                                      (memo, addr, isBusy) =>
            {
                BitcoinAddress address;
                try
                {
                    address = BitcoinAddress.Create(addr.Trim(), Global.Network);
                }
                catch (FormatException)
                {
                    // SetWarningMessage("Invalid address.");
                    return(false);
                }
                return(!isBusy && memo.Length > 0 && address is BitcoinAddress);
            });

            _promptViewModel = new PasswordPromptViewModel("SEND");
            _promptViewModel.ValidatePasswordCommand.Subscribe(async validPassword =>
            {
                if (validPassword != null)
                {
                    await ViewStackService.PopModal();
                    await BuildTransaction(validPassword);
                    await ViewStackService.PushPage(new SentViewModel());
                }
            });
            PromptCommand = ReactiveCommand.CreateFromObservable(() =>
            {
                ViewStackService.PushModal(_promptViewModel).Subscribe();
                return(Observable.Return(Unit.Default));
            }, canPromptPassword);
        }