Exemple #1
0
        private async void KeyTransfer()
        {
            try
            {
                KeyTransferWindow keyTransfer = new KeyTransferWindow(tcBitcoin, SelectedKey);

                if (keyTransfer.ShowDialog() == true)
                {
                    Cursor = Cursors.Wait;
                    SpendTx spendTx = await tcBitcoin.KeyTransferTx(SelectedKey, GetKey(keyTransfer.KeyNameTo),
                                                                    keyTransfer.TransferAmount, keyTransfer.MinerRate, keyTransfer.TxMessage, keyTransfer.CashCodeFrom, keyTransfer.CashCodeTo);

                    if (!spendTx.IsSatisfied)
                    {
                        MessageBox.Show(Properties.Resources.UnsatisfiedPayment, Title, MessageBoxButton.OK, MessageBoxImage.Error);
                        tcBitcoin.KeyTransferCancel(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.KeyTransferNode(spendTx, keyTransfer.KeyNameTo, keyTransfer.CashCodeFrom, keyTransfer.CashCodeTo))
                                {
                                    Refresh();
                                    await RefreshBalance();
                                }
                            }
                        }
                        else
                        {
                            tcBitcoin.KeyTransferCancel(spendTx);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }