示例#1
0
 void OnGetMsgDataRequest(SendMsgData <SendItemInfo> data)
 {
     if (data == null || data.Token == null)
     {
         return;
     }
     SendItems.Clear();
     SendItems.Add(data.Token);
 }
示例#2
0
 void OnClearAddress(SendItemInfo sendItemInfo)
 {
     if (sendItemInfo == null)
     {
         return;
     }
     SendItems.Remove(sendItemInfo);
     if (!SendItems.Any())
     {
         SendItems.Add(new SendItemInfo());
     }
 }
示例#3
0
        private void Sending_Runner(object state)
        {
            BTData result;

            while (true)
            {
                if (SendItems.TryDequeue(out result))
                {
                    Send(result.Data);
                }
            }
        }
示例#4
0
        void JumpToConfirmPage()
        {
            var result = FiiiCoinService.Default.EstimateTxFeeForSendMany(Initializer.Default.DefaultAccount.Address, SendItems);

            if (result.IsFail)
            {
                ShowMessage(result.GetErrorMsg());
                return;
            }

            var feeValue = result.Value.TotalFee;

            SendMsgData <ConfirmSendData> data = new SendMsgData <ConfirmSendData>();
            var             amountAll          = SendItems.Sum(x => x.Amount);
            ConfirmSendData sendData           = new ConfirmSendData
            {
                Amount = amountAll / Math.Pow(10, 8),
            };

            sendData.Fee = feeValue / Math.Pow(10, 8);

            var tags = SendItems.Select(x =>
            {
                if (string.IsNullOrEmpty(x.Tag.Trim()))
                {
                    return(x.Address);
                }
                else
                {
                    return(x.Tag);
                }
            });

            sendData.ToAddress = string.Join(";", SendItems.Select(x => x.Tag));

            if (!SendItems.Any(x => x.IsContainFee))
            {
                sendData.ArrivalAmount = sendData.Amount;
            }
            else
            {
                sendData.ArrivalAmount = (amountAll - feeValue) / Math.Pow(10, 8);
            }
            data.Token = sendData;
            data.SetCallBack(() =>
            {
                SendDataToService();
            });

            SendMessenger(Pages.ConfirmSendPage, data);
            UpdatePage(Pages.ConfirmSendPage);
        }
示例#5
0
        void OnAllClick(SendItemInfo sendItemInfo)
        {
            if (sendItemInfo == null)
            {
                return;
            }
            var allamount = SendItems.Except(new List <SendItemInfo> {
                sendItemInfo
            }).Sum(x => x.Amount);
            var result = OverMoney - allamount;

            sendItemInfo.PayAmountStr = (result / Math.Pow(10, 8)).ToString("0.00000000");
        }
示例#6
0
        bool ValidateData(ItemsControl items)
        {
            if (!Validator.IsValid(items))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue("Error_Amount"));
                return(false);
            }

            if (_regexRule == null)
            {
                _regexRule = new RegexRule();
            }
            if (!SendItems.Any(x => _regexRule.MatchAll(x.Address, _addressPattern)))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(ValidationType.Error_Address.ToString()));
                return(false);
            }

            if (SendItems.Any(x => string.IsNullOrEmpty(x.PayAmountStr)))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue("Error_Amount"));
                return(false);
            }

            //if (SendItems.Any(x => x.PayAmount < Fee))
            //{
            //    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_SendOverMinFee));
            //    return false;
            //}

            var allAmount = SendItems.Sum(x => x.Amount);

            if (allAmount > OverMoney)
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_SendOverMax));
                return(false);
            }

            return(true);
        }
示例#7
0
 public Bill()
 {
     InitializeComponent();
     Sender  = new SendItems(GetItems);
     Sender2 = new SendPrice(GetTotalPrice);
 }
示例#8
0
 void OnClear()
 {
     SendItems.Clear();
     SendItems.Add(new SendItemInfo());
 }
示例#9
0
 void OnAdd()
 {
     SendItems.Add(new SendItemInfo());
 }
示例#10
0
        bool ValidateData(ItemsControl items)
        {
            //if (!AmountMonitor.Default.IsSyncComplete)
            //{
            //    ShowMessage(LanguageService.Default.GetLanguageValue("Error_Sync"));
            //    return false;
            //}

            if (!Validator.IsValid(items))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue("Error_Amount"));
                return(false);
            }

            if (_regexRule == null)
            {
                _regexRule = new RegexRule();
            }
            if (SendItems.Any(x => string.IsNullOrEmpty(x.Address) || !_regexRule.MatchAll(x.Address.Trim(), _addressPattern)))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(ValidationType.Error_Address.ToString()));
                return(false);
            }

            if (SendItems.Any(x => string.IsNullOrEmpty(x.PayAmountStr)))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue("Error_Amount"));
                return(false);
            }

            var sendAmount = SendItems.Sum(x => x.Amount);

            //需要重新选择UTXO
            if (StaticViewModel.GlobalViewModel.IsEnableProfessional)
            {
                var utxo = StaticViewModel.GlobalViewModel.ProfessionalSetting.UTXO;

                if (utxo == null)
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue("Error_Utxo"));
                    return(false);
                }

                var amount = StaticViewModel.GlobalViewModel.ProfessionalSetting.UTXO.Sum(x => x.Amount);

                if (amount < sendAmount)
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue("Error_Utxo"));
                    return(false);
                }
            }
            else
            {
                if (sendAmount > OverMoney)
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_SendOverMax));
                    return(false);
                }
            }

            SendItems.ToList().ForEach(x => x.Address = x.Address.Trim());

            return(true);
        }
示例#11
0
        void JumpToConfirmPage()
        {
            long feeValue = 0L;

            if (!StaticViewModel.GlobalViewModel.IsEnableProfessional)
            {
                var result = OmniCoinService.Default.EstimateTxFeeForSendMany(Initializer.Default.DefaultAccount.Address, SendItems);
                if (result.IsFail)
                {
                    ShowMessage(result.GetErrorMsg());
                    return;
                }
                feeValue = result.Value.TotalFee;
            }
            else
            {
                var professionalSetting = StaticViewModel.GlobalViewModel.ProfessionalSetting;
                var result = OmniCoinService.Default.EstimateRawTransaction(
                    professionalSetting.UTXO.Select(x => new DTO.SendRawTransactionInputsIM {
                    TxId = x.Txid, Vout = x.Vout
                }).ToList(),
                    SendItems,
                    professionalSetting.ChangeAddress.Address,
                    Convert.ToInt64(Fee * Math.Pow(10, 8)));
                if (result.IsFail)
                {
                    ShowMessage(result.GetErrorMsg());
                    return;
                }
                feeValue = result.Value.TotalFee;
            }



            SendMsgData <ConfirmSendData> data = new SendMsgData <ConfirmSendData>();
            var             amountAll          = SendItems.Sum(x => x.Amount);
            ConfirmSendData sendData           = new ConfirmSendData
            {
                Amount = amountAll / Math.Pow(10, 8),
            };

            sendData.Fee = feeValue / Math.Pow(10, 8);

            var tags = SendItems.Select(x =>
            {
                if (string.IsNullOrEmpty(x.Tag.Trim()))
                {
                    return(x.Address);
                }
                else
                {
                    return(x.Tag);
                }
            });

            sendData.ToAddress = string.Join(";", SendItems.Select(x => x.Tag));

            if (!SendItems.Any(x => x.IsContainFee))
            {
                sendData.ArrivalAmount = sendData.Amount;
            }
            else
            {
                if (!StaticViewModel.GlobalViewModel.IsEnableProfessional)
                {
                    sendData.ArrivalAmount = (amountAll - feeValue) / Math.Pow(10, 8);
                }
                else
                {
                    sendData.ArrivalAmount = amountAll / Math.Pow(10, 8);
                }
            }
            data.Token = sendData;
            data.SetCallBack(() =>
            {
                SendDataToService();
            });

            SendMessenger(Pages.ConfirmSendPage, data);
            UpdatePage(Pages.ConfirmSendPage);
        }