public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info, TransactionBroadcaster broadcaster,
                                           BuildTransactionResult transaction)
        {
            var destinationAmount = transaction.CalculateDestinationAmount().ToDecimal(MoneyUnit.BTC);

            var fee = transaction.Fee;

            BtcAmountText = $"{destinationAmount} bitcoins ";

            FiatAmountText = $"(≈{(destinationAmount * wallet.Synchronizer.UsdExchangeRate).FormattedFiat()} USD) ";

            Labels = info.Labels.Labels.ToArray();

            AddressText = info.Address.ToString();

            ConfirmationTimeText = $"Approximately {TextHelpers.TimeSpanToFriendlyString(info.ConfirmationTimeSpan)} ";

            BtcFeeText = $"{fee.ToDecimal(MoneyUnit.Satoshi)} satoshis ";

            FiatFeeText =
                $"(≈{(fee.ToDecimal(MoneyUnit.BTC) * wallet.Synchronizer.UsdExchangeRate).FormattedFiat()} USD)";

            NextCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var transactionAuthorizationInfo = new TransactionAuthorizationInfo(transaction);
                var authDialog       = AuthorizationHelpers.GetAuthorizationDialog(wallet, transactionAuthorizationInfo);
                var authDialogResult = await NavigateDialog(authDialog, authDialog.DefaultTarget);

                if (authDialogResult.Result)
                {
                    IsBusy = true;

                    // Dequeue any coin-joining coins.
                    await wallet.ChaumianClient.DequeueAllCoinsFromMixAsync(DequeueReason.TransactionBuilding);

                    await broadcaster.SendTransactionAsync(transactionAuthorizationInfo.Transaction);
                    Navigate().Clear();

                    IsBusy = false;
                }
                else if (authDialogResult.Kind == DialogResultKind.Normal)
                {
                    await ShowErrorAsync("Authorization", "The Authorization has failed, please try again.", "");
                }
            });
        }
        private async Task <bool> AuthorizeAsync(TransactionAuthorizationInfo transactionAuthorizationInfo)
        {
            if (!_wallet.KeyManager.IsHardwareWallet && string.IsNullOrEmpty(_wallet.Kitchen.SaltSoup()))             // Do not show auth dialog when password is empty
            {
                return(true);
            }

            var authDialog       = AuthorizationHelpers.GetAuthorizationDialog(_wallet, transactionAuthorizationInfo);
            var authDialogResult = await NavigateDialogAsync(authDialog, authDialog.DefaultTarget);

            if (!authDialogResult.Result && authDialogResult.Kind == DialogResultKind.Normal)
            {
                await ShowErrorAsync("Authorization", "The Authorization has failed, please try again.", "");
            }

            return(authDialogResult.Result);
        }
Ejemplo n.º 3
0
        private async Task OnNext(Wallet wallet, TransactionBroadcaster broadcaster, BuildTransactionResult transaction)
        {
            var transactionAuthorizationInfo = new TransactionAuthorizationInfo(transaction);
            var authDialog       = AuthorizationHelpers.GetAuthorizationDialog(wallet, transactionAuthorizationInfo);
            var authDialogResult = await NavigateDialog(authDialog, authDialog.DefaultTarget);

            if (authDialogResult.Result)
            {
                IsBusy = true;

                // Dequeue any coin-joining coins.
                await wallet.ChaumianClient.DequeueAllCoinsFromMixAsync(DequeueReason.TransactionBuilding);

                await broadcaster.SendTransactionAsync(transactionAuthorizationInfo.Transaction);

                Navigate().Clear();

                IsBusy = false;
            }
            else if (authDialogResult.Kind == DialogResultKind.Normal)
            {
                await ShowErrorAsync("Authorization", "The Authorization has failed, please try again.", "");
            }
        }