Esempio n. 1
0
 void OnClearAddress(SendItemInfo sendItemInfo)
 {
     if (sendItemInfo == null)
     {
         return;
     }
     SendItems.Remove(sendItemInfo);
     if (!SendItems.Any())
     {
         SendItems.Add(new SendItemInfo());
     }
 }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }