Пример #1
0
        private async void MiscellaneousPayment()
        {
            try
            {
                PayOutWindow payOut = new PayOutWindow(tcBitcoin, SelectedKey);

                if (payOut.ShowDialog() == true)
                {
                    Cursor = Cursors.Wait;
                    SpendTx spendTx = await tcBitcoin.PayOutTx(SelectedKey, payOut.PaymentAddress,
                                                               payOut.AmountToPay, payOut.MinerRate, payOut.TxMessage);

                    if (!spendTx.IsSatisfied)
                    {
                        MessageBox.Show(Properties.Resources.UnsatisfiedPayment, payOut.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                        tcBitcoin.PayOutCancel(spendTx);
                    }
                    else
                    {
                        Cursor = Cursors.Arrow;
                        SpendConfirmWindow spendDialog = new SpendConfirmWindow(spendTx);

                        if (spendDialog.ShowDialog() == true)
                        {
                            Cursor = Cursors.Wait;

                            bool broadcast = await spendTx.Send();

                            if (broadcast)
                            {
                                if (tcBitcoin.PayOutMiscNode(spendTx, payOut.AccountCode, payOut.CashCode, payOut.TaxCode, payOut.PaymentReference))
                                {
                                    Refresh();
                                    await RefreshBalance();
                                }
                            }
                            else
                            {
                                tcBitcoin.PayOutCancel(spendTx);
                            }
                        }
                        else
                        {
                            tcBitcoin.PayOutCancel(spendTx);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }