-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dead balance APIs. the remaining 2 already support bech32 address
- Loading branch information
1 parent
e6685f3
commit 204badc
Showing
5 changed files
with
81 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 38 additions & 38 deletions
76
WatchOnlyBitcoinWallet/Services/BalanceServices/BlockExplorer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Response> UpdateBalancesAsync(List<Models.BitcoinAddress> addrList) | ||
{ | ||
Response resp = new Response(); | ||
//namespace WatchOnlyBitcoinWallet.Services.BalanceServices | ||
//{ | ||
// public class BlockExplorer : BalanceApi | ||
// { | ||
// public override async Task<Response> UpdateBalancesAsync(List<Models.BitcoinAddress> 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<Response> UpdateTransactionListAsync(List<Models.BitcoinAddress> addrList) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
// public override Task<Response> UpdateTransactionListAsync(List<Models.BitcoinAddress> addrList) | ||
// { | ||
// throw new NotImplementedException(); | ||
// } | ||
|
||
} | ||
} | ||
// } | ||
//} |
66 changes: 33 additions & 33 deletions
66
WatchOnlyBitcoinWallet/Services/BalanceServices/BlockchainInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Response> UpdateBalancesAsync(List<BitcoinAddress> addrList) | ||
{ | ||
Response resp = new Response(); | ||
foreach (var addr in addrList) | ||
{ | ||
string url = "https://blockchain.info/address/" + addr.Address + "?format=json&limit=0"; | ||
Response<JObject> 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<Response> UpdateBalancesAsync(List<BitcoinAddress> addrList) | ||
// { | ||
// Response resp = new Response(); | ||
// foreach (var addr in addrList) | ||
// { | ||
// string url = "https://blockchain.info/address/" + addr.Address + "?format=json&limit=0"; | ||
// Response<JObject> 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<Response> UpdateTransactionListAsync(List<BitcoinAddress> addrList) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
// public override Task<Response> UpdateTransactionListAsync(List<BitcoinAddress> addrList) | ||
// { | ||
// throw new System.NotImplementedException(); | ||
// } | ||
|
||
} | ||
} | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters