blockexplorer.com's cash explorer has stopped working

This commit is contained in:
Rick Falkvinge
2019-03-04 06:37:37 +01:00
parent 138093141c
commit d163901bd7
4 changed files with 13 additions and 11 deletions
+8 -4
View File
@@ -597,7 +597,7 @@ namespace Swarmops.Logic.Financial
case BitcoinChain.Cash:
client.UploadValues("https://bitcoincash.blockexplorer.com/api/tx/send",
client.UploadValues("https://bch-insight.bitpay.com/api/tx/send",
new NameValueCollection()
{
{"rawtx", transaction.ToHex()}
@@ -664,7 +664,7 @@ namespace Swarmops.Logic.Financial
try
{
string legacyAddress = BitcoinCashAddressConversion.CashAddressToLegacyAddresss(address, out dummy1,
string legacyAddress = BitcoinCashAddressConversion.CashAddressToLegacyAddress(address, out dummy1,
out dummy2);
// If this doesn't throw, we have a valid legacy address
@@ -688,7 +688,7 @@ namespace Swarmops.Logic.Financial
try
{
BitcoinCashAddressConversion.CashAddressToLegacyAddresss(address, out dummy1, out dummy2);
BitcoinCashAddressConversion.CashAddressToLegacyAddress(address, out dummy1, out dummy2);
// If this doesn't throw, we already have a valid bitcoincash address
// Just strip the prefix if there is one
@@ -820,9 +820,10 @@ namespace Swarmops.Logic.Financial
public static void CheckColdStorageCash(FinancialAccount account, string bitcoinMachineAddress, Dictionary<string, int> addressAccountLookup)
{
string bitcoinCashAddress = EnsureCashAddressWithoutPrefix(bitcoinMachineAddress);
JObject addressData = JObject.Parse(
new WebClient().DownloadString("https://bitcoincash.blockexplorer.com/api/txs/?address=" + bitcoinMachineAddress));
new WebClient().DownloadString("https://bch-insight.bitpay.com/api/txs/?address=" + bitcoinCashAddress));
List<BlockchainTransaction> transactionList = new List<BlockchainTransaction>();
@@ -1271,6 +1272,9 @@ namespace Swarmops.Logic.Financial
JObject feeData = JObject.Parse(
new WebClient().DownloadString("https://bitcoinlegacy.blockexplorer.com/api/utils/estimatefee?nbBlocks=" + blocksWait.ToString(CultureInfo.InvariantCulture)));
double feeWholeCoins = Double.Parse((string)feeData[blocksWait.ToString(CultureInfo.InvariantCulture)], NumberStyles.AllowDecimalPoint); // rounding errors are okay, don't use Formatting fn
// TODO: I saw this function return -1 once, just once. Will need to catch that.
satoshisPerThousandBytes = Convert.ToInt64(feeWholeCoins * _satoshisPerBitcoin);
}
+2 -4
View File
@@ -108,10 +108,8 @@ namespace Swarmops.Logic.Support
newRow.Address = (string) json["scriptPubKey"]["addresses"][0];
}
if (newRow.Address.StartsWith("bitcoincash:")) // make sure we're using the same machine readable format
{
newRow.Address = BitcoinUtility.EnsureLegacyAddress(newRow.Address);
}
// Ensure we have a protocol-level address
newRow.Address = BitcoinUtility.EnsureLegacyAddress(newRow.Address);
string valueSatoshisString = (string) json["valueSat"];
if (!string.IsNullOrEmpty(valueSatoshisString))
+1 -1
View File
@@ -181,7 +181,7 @@ namespace Swarmops.Logic.Support
}
return ret.ToString();
}
public static string CashAddressToLegacyAddresss(string cashAddress, out bool isP2PKH, out bool mainnet) {
public static string CashAddressToLegacyAddress(string cashAddress, out bool isP2PKH, out bool mainnet) {
cashAddress = cashAddress.ToLower();
if (cashAddress.Length != 54 && cashAddress.Length != 42 && cashAddress.Length != 50) {
if (cashAddress.StartsWith("bchreg:"))
+2 -2
View File
@@ -2,7 +2,7 @@
<%@ Import Namespace="Swarmops.Logic.Support" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
<script src="https://bitcoincash.blockexplorer.com/socket.io/socket.io.js"></script>
<script src="https://bch-insight.bitpay.com/socket.io/socket.io.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
@@ -14,7 +14,7 @@
eventToListenTo = 'tx';
room = 'inv';
var socket = io("https://bitcoincash.blockexplorer.com/");
var socket = io("https://bch-insight.bitpay.com/");
socket.on('connect', function() {
// Join the room.
socket.emit('subscribe', room);