diff --git a/WatchOnlyBitcoinWallet/Properties/AssemblyInfo.cs b/WatchOnlyBitcoinWallet/Properties/AssemblyInfo.cs index 69de664..fe056c2 100644 --- a/WatchOnlyBitcoinWallet/Properties/AssemblyInfo.cs +++ b/WatchOnlyBitcoinWallet/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.2.0.0")] -[assembly: AssemblyFileVersion("3.2.0.0")] +[assembly: AssemblyVersion("3.2.1.0")] +[assembly: AssemblyFileVersion("3.2.1.0")] diff --git a/WatchOnlyBitcoinWallet/Services/Api.cs b/WatchOnlyBitcoinWallet/Services/Api.cs index aa6e3b6..dcc484c 100644 --- a/WatchOnlyBitcoinWallet/Services/Api.cs +++ b/WatchOnlyBitcoinWallet/Services/Api.cs @@ -16,8 +16,6 @@ public enum PriceServiceNames } public enum BalanceServiceNames { - BlockchainInfo, - BlockExplorer, BlockCypher, Blockonomics } diff --git a/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockExplorer.cs b/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockExplorer.cs index 3c87d2a..6a42be8 100644 --- a/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockExplorer.cs +++ b/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockExplorer.cs @@ -1,43 +1,43 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; +//using System; +//using System.Collections.Generic; +//using System.Net.Http; +//using System.Threading.Tasks; -namespace WatchOnlyBitcoinWallet.Services.BalanceServices -{ - public class BlockExplorer : BalanceApi - { - public override async Task UpdateBalancesAsync(List addrList) - { - Response resp = new Response(); +//namespace WatchOnlyBitcoinWallet.Services.BalanceServices +//{ +// public class BlockExplorer : BalanceApi +// { +// public override async Task UpdateBalancesAsync(List addrList) +// { +// Response resp = new Response(); - using (HttpClient client = new HttpClient()) - { - foreach (var addr in addrList) - { - try - { - string result = await client.GetStringAsync("https://blockexplorer.com/api/addr/" + addr.Address + "/balance"); - decimal bal = Int64.Parse(result) * Satoshi; - addr.Difference = bal - addr.Balance; - addr.Balance = bal; - } - catch (Exception ex) - { - string errMsg = (ex.InnerException == null) ? ex.Message : ex.Message + " " + ex.InnerException; - resp.Errors.Add(errMsg); - break; - } - } - } +// using (HttpClient client = new HttpClient()) +// { +// foreach (var addr in addrList) +// { +// try +// { +// string result = await client.GetStringAsync("https://blockexplorer.com/api/addr/" + addr.Address + "/balance"); +// decimal bal = Int64.Parse(result) * Satoshi; +// addr.Difference = bal - addr.Balance; +// addr.Balance = bal; +// } +// catch (Exception ex) +// { +// string errMsg = (ex.InnerException == null) ? ex.Message : ex.Message + " " + ex.InnerException; +// resp.Errors.Add(errMsg); +// break; +// } +// } +// } - return resp; - } +// return resp; +// } - public override Task UpdateTransactionListAsync(List addrList) - { - throw new NotImplementedException(); - } +// public override Task UpdateTransactionListAsync(List addrList) +// { +// throw new NotImplementedException(); +// } - } -} \ No newline at end of file +// } +//} \ No newline at end of file diff --git a/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockchainInfo.cs b/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockchainInfo.cs index 1270917..91c72c4 100644 --- a/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockchainInfo.cs +++ b/WatchOnlyBitcoinWallet/Services/BalanceServices/BlockchainInfo.cs @@ -1,36 +1,36 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using WatchOnlyBitcoinWallet.Models; +//using Newtonsoft.Json.Linq; +//using System; +//using System.Collections.Generic; +//using System.Threading.Tasks; +//using WatchOnlyBitcoinWallet.Models; -namespace WatchOnlyBitcoinWallet.Services.BalanceServices -{ - public class BlockchainInfo : BalanceApi - { - public override async Task UpdateBalancesAsync(List addrList) - { - Response resp = new Response(); - foreach (var addr in addrList) - { - string url = "https://blockchain.info/address/" + addr.Address + "?format=json&limit=0"; - Response apiResp = await SendApiRequestAsync(url); - if (apiResp.Errors.Any()) - { - resp.Errors.AddRange(apiResp.Errors); - break; - } - decimal bal = (Int64)apiResp.Result["final_balance"] * Satoshi; - addr.Difference = bal - addr.Balance; - addr.Balance = bal; - } - return resp; - } +//namespace WatchOnlyBitcoinWallet.Services.BalanceServices +//{ +// public class BlockchainInfo : BalanceApi +// { +// public override async Task UpdateBalancesAsync(List addrList) +// { +// Response resp = new Response(); +// foreach (var addr in addrList) +// { +// string url = "https://blockchain.info/address/" + addr.Address + "?format=json&limit=0"; +// Response apiResp = await SendApiRequestAsync(url); +// if (apiResp.Errors.Any()) +// { +// resp.Errors.AddRange(apiResp.Errors); +// break; +// } +// decimal bal = (Int64)apiResp.Result["final_balance"] * Satoshi; +// addr.Difference = bal - addr.Balance; +// addr.Balance = bal; +// } +// return resp; +// } - public override Task UpdateTransactionListAsync(List addrList) - { - throw new System.NotImplementedException(); - } +// public override Task UpdateTransactionListAsync(List addrList) +// { +// throw new System.NotImplementedException(); +// } - } -} \ No newline at end of file +// } +//} \ No newline at end of file diff --git a/WatchOnlyBitcoinWallet/ViewModels/MainWindowViewModel.cs b/WatchOnlyBitcoinWallet/ViewModels/MainWindowViewModel.cs index 18f7deb..654034d 100644 --- a/WatchOnlyBitcoinWallet/ViewModels/MainWindowViewModel.cs +++ b/WatchOnlyBitcoinWallet/ViewModels/MainWindowViewModel.cs @@ -210,12 +210,6 @@ private async void GetBalance() BalanceApi api = null; switch (SettingsInstance.SelectedBalanceApi) { - case BalanceServiceNames.BlockchainInfo: - api = new BlockchainInfo(); - break; - case BalanceServiceNames.BlockExplorer: - api = new BlockExplorer(); - break; case BalanceServiceNames.BlockCypher: api = new BlockCypher(); break; @@ -223,54 +217,21 @@ private async void GetBalance() api = new Blockonomics(); break; default: - api = new BlockchainInfo(); + api = new BlockCypher(); break; } - // Not all exchanges support Bech32 addresses! - // The following "if" is to solve that. - bool hasSegWit = AddressList.Any(x => x.Address.StartsWith("bc1", System.StringComparison.InvariantCultureIgnoreCase)); - if (hasSegWit && !SettingsInstance.SelectedBalanceApi.Equals(BalanceServiceNames.Blockonomics)) + Response resp = await api.UpdateBalancesAsync(AddressList.ToList()); + if (resp.Errors.Any()) { - BalanceApi segApi = new Blockonomics(); - List legacyAddrs = new List(AddressList.Where(x => - !x.Address.StartsWith("bc1", System.StringComparison.OrdinalIgnoreCase))); - List segWitAddrs = new List(AddressList.Where(x => - x.Address.StartsWith("bc1", System.StringComparison.OrdinalIgnoreCase))); - - Response respSW = await segApi.UpdateBalancesAsync(segWitAddrs); - if (respSW.Errors.Any()) - { - Errors = "SegWit API error: " + respSW.Errors.GetErrors(); - Status = "Error in SegWit API! Continue updating legacy balances..."; - } - Response resp = await api.UpdateBalancesAsync(legacyAddrs); - if (resp.Errors.Any()) - { - Errors = resp.Errors.GetErrors(); - Status = "Encountered an error!"; - } - else - { - DataManager.WriteFile(AddressList, DataManager.FileType.Wallet); - RaisePropertyChanged("BitcoinBalance"); - Status = "Balance Update Success!"; - } + Errors = resp.Errors.GetErrors(); + Status = "Encountered an error!"; } else { - Response resp = await api.UpdateBalancesAsync(AddressList.ToList()); - if (resp.Errors.Any()) - { - Errors = resp.Errors.GetErrors(); - Status = "Encountered an error!"; - } - else - { - DataManager.WriteFile(AddressList, DataManager.FileType.Wallet); - RaisePropertyChanged("BitcoinBalance"); - Status = "Balance Update Success!"; - } + DataManager.WriteFile(AddressList, DataManager.FileType.Wallet); + RaisePropertyChanged("BitcoinBalance"); + Status = "Balance Update Success!"; } IsReceiving = false;