private void AddAddress(object sender, RoutedEventArgs e) { string currentAddress = txtAddr.Text; int[] currentPublicKey = CryptoCurrency.ByteArrayToIntArray(CryptoCurrency.StringToByteArray(txtPubKey.Text)); float currentAmount; if (!float.TryParse(txtAmount.Text, out currentAmount)) { MessageBox.Show("Amount must be a float", "Error"); return; } Outputs.Add(new Output(currentAddress, currentPublicKey, currentAmount)); lvOutput.ItemsSource = null; lvOutput.ItemsSource = Outputs; txtAddr.Text = ""; txtAmount.Text = ""; txtPubKey.Text = ""; }
public static List <Input> GetTotal(float amount, Span <float> change) { XDocument doc = XDocument.Load(filePath); List <XElement> elements = new List <XElement>(doc.Element("UserInfo").Element("Keys").Elements("Key")); List <Input> inputs = new List <Input>(); int index = 0; float total = 0; while (index < elements.Count && total < amount) { XElement temp = elements[index].Element("Address"); XElement privateKey = elements[index].Element("PrivateKey"); if (temp.Attribute("unSpend").Value == "true") { if (temp.Attribute("isConfirm").Value == "true") { total += float.Parse(temp.Attribute("amount").Value); inputs.Add(new Input(temp.Value, CryptoCurrency.ByteArrayToIntArray(CryptoCurrency.Sign(temp.Value, CryptoCurrency.StringToByteArray(privateKey.Value))))); } } index++; } change[0] = total - amount; return(inputs); }