void startWallet_DoWork(System.Object sender, System.ComponentModel.DoWorkEventArgs e) { beginning(e); Types.AllData dataimport = new Types.AllData(); dataimport = api.getAllData(); //connections start.connections = dataimport.connectionCount; //balance info start.privatebalance = dataimport.privatebalance; start.transparentbalance = dataimport.transparentbalance; start.totalbalance = dataimport.totalbalance; start.unconfirmedbalance = dataimport.unconfirmedbalance; start.privatebalanceunconfirmed = dataimport.privatebalanceunconfirmed; start.transparentbalanceunconfirmed = dataimport.transparentbalanceunconfirmed; start.totalbalanceunconfirmed = dataimport.totalbalanceunconfirmed; //blockhash info start.bestHash = dataimport.bestblockhash; //bestblock time start.bestTime = dataimport.time; //transaction list start.listtransactions = dataimport.listtransactions; //Address List if (dataimport.addressbalance != null && dataimport.addressbalance.Count > 0) { start.walletDic = new Dictionary <String, String>(dataimport.addressbalance[0]); } }
public Types.AllData getAllData() { Types.AllData data = new Types.AllData(); try { //connections data.connectionCount = checkConnections(); //balances string rpcdata = getZTotalBalance(); dynamic parse = JsonConvert.DeserializeObject <Types.AllData>(rpcdata); data.privatebalance = parse.@private; data.transparentbalance = parse.transparent; data.totalbalance = parse.total; data.unconfirmedbalance = getUnconfirmedBalance(); rpcdata = getZTotalBalanceUnconfirmed(); parse = JsonConvert.DeserializeObject <Types.AllData>(rpcdata); data.privatebalanceunconfirmed = parse.@private; data.transparentbalanceunconfirmed = parse.transparent; data.totalbalanceunconfirmed = parse.total; //blockhash info rpcdata = getBestBlockhash(); parse = JsonConvert.DeserializeObject <Types.AllData>(rpcdata); data.bestblockhash = parse.bestblockhash; //bestblock time rpcdata = getBestTime(data.bestblockhash); parse = JsonConvert.DeserializeObject <Types.AllData>(rpcdata); //data.time = parse.time; data.besttime = parse.time; //address lists Dictionary <String, String> addressDictionary = new Dictionary <String, String>(); Dictionary <String, String> validatedAddressDictionary = new Dictionary <String, String>(); Dictionary <String, String> validatedZAddressDictionary = new Dictionary <String, String>(); List <Dictionary <String, String> > addressList = new List <Dictionary <String, String> >(); List <Dictionary <String, String> > ValidatedList = new List <Dictionary <String, String> >(); List <Dictionary <String, String> > ValidatedZList = new List <Dictionary <String, String> >(); //add t-addresses rpcdata = getTAddress(); parse = JsonConvert.DeserializeObject <List <String> >(rpcdata); for (int i = 0; i < parse.Count; i++) { addressDictionary.Add(parse[i], "0"); } //add unspent t-addresses rpcdata = getTAddressUnspent(); parse = JsonConvert.DeserializeObject <List <Types.AddressData> >(rpcdata); for (int i = 0; i < parse.Count; i++) { try { addressDictionary.Add(parse[i].address, "0"); } catch { } } addressList.Add(addressDictionary); //Validate wallet t-addresses have spend keys foreach (String a in addressList[0].Keys.ToList()) { try { String Validate = ValidateTAddress(a); dynamic ValidAddresses = JsonConvert.DeserializeObject <Types.ValidAddress>(Validate); if (ValidAddresses.isvalid == "true") { validatedAddressDictionary.Add(a, "0"); } } catch { } } //reset dictionaries addressDictionary = new Dictionary <String, String>(); addressList = new List <Dictionary <String, String> >(); //add z-addresses rpcdata = getZAddress(); parse = JsonConvert.DeserializeObject <List <String> >(rpcdata); for (int i = 0; i < parse.Count; i++) { try { addressDictionary.Add(parse[i], "0"); } catch { } } addressList.Add(addressDictionary); //Validate wallet z-addresses have spend keys foreach (String a in addressList[0].Keys.ToList()) { try { String Validate = ValidateZAddress(a); dynamic ValidAddresses = JsonConvert.DeserializeObject <Types.ValidAddress>(Validate); if (ValidAddresses.isvalid == "true") { validatedAddressDictionary.Add(a, "0"); validatedZAddressDictionary.Add(a, "0"); } } catch { } } ValidatedZList.Add(validatedZAddressDictionary); ValidatedList.Add(validatedAddressDictionary); foreach (String a in ValidatedList[0].Keys.ToList()) { //get current balance of the address String balance = Task.Run(() => getAddressBalance(a)).Result; //update balance ValidatedList[0][a] = balance; } data.addressbalance = ValidatedList; //t-address transaction list rpcdata = getListTransactions(); data.listtransactions = JsonConvert.DeserializeObject <List <Types.Transaction> >(rpcdata); //z-received by transactions foreach (String a in ValidatedZList[0].Keys.ToList()) { try { String ZTxidRPC = getZReceiveTransactions(a); dynamic ZTxid = JsonConvert.DeserializeObject <List <Types.Transaction> >(ZTxidRPC); for (int i = 0; i < ZTxid.Count; i++) { try { String ZTransactionsRPC = getTransaction(ZTxid[i].txid); dynamic ZTransactions = JsonConvert.DeserializeObject <Types.Transaction>(ZTransactionsRPC); ZTransactions.amount = ZTxid[i].amount; ZTransactions.address = "Z-Address ...." + a.Substring(a.Length - 6); data.listtransactions.Add(ZTransactions); } catch { } } } catch { } } data.listtransactions.Sort((x, y) => x.time.CompareTo(y.time)); } catch { } return(data); }