Switching Insight to Bitpay

This commit is contained in:
Rick Falkvinge
2018-05-19 14:15:16 +02:00
parent 537ab515bc
commit 7cd9f15adc
2 changed files with 23 additions and 5 deletions
+15 -2
View File
@@ -7,6 +7,7 @@ using Swarmops.Common.Enums;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Swarm;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support.BackendServices;
// This is a console environment for debugging the logic and database layers.
@@ -54,7 +55,7 @@ namespace Swarmops.DebugConsole
}
}
// 0.5) Re-register the initial Sandbox Echo address
// 0.5) Re-register the initial Sandbox Echo addressbl
HotBitcoinAddress.Create(organization, BitcoinChain.Cash,
BitcoinUtility.BitcoinEchoTestIndex, 1);
@@ -76,7 +77,19 @@ namespace Swarmops.DebugConsole
if (beforeCheckCount != correctedCount)
{
Console.WriteLine(" - Unspent count was corrected: ");
Console.WriteLine(" - Unspent count was corrected: was {0}, changed to {1}", beforeCheckCount, correctedCount);
}
if (
address.DerivationPath.StartsWith(BitcoinUtility.BitcoinEchoTestIndex.ToString() + " "))
{
// This is an address that should be echoed back, all of it
foreach (HotBitcoinAddressUnspent unspent in unspents2)
{
ReturnBitcoinEchoUtxoOrder backendOrder = new ReturnBitcoinEchoUtxoOrder(unspent);
backendOrder.Create(organization, testPerson);
}
}
}
+8 -3
View File
@@ -348,8 +348,10 @@ namespace Swarmops.Logic.Financial
// TODO: SELECT BLOCK EXPLORER AND ITS ACCOMPANYING ADDRESS FORMAT
bool dummy1, dummy2;
unspentArray = JArray.Parse(
new WebClient().DownloadString("https://bitcoincash.blockexplorer.com/api/addr/" + secretKey.PubKey.GetAddress(Network.Main) + "/utxo"));
new WebClient().DownloadString("https://bch-insight.bitpay.com/api/addr/" + BitcoinCashAddressConversion.LegacyAddressToCashAddress(secretKey.PubKey.GetAddress(Network.Main).ToString(), out dummy1, out dummy2).Substring("bitcoincash:".Length) + "/utxo")));
foreach (JObject unspentJson in unspentArray.Children())
{
@@ -487,12 +489,15 @@ namespace Swarmops.Logic.Financial
case BitcoinChain.Cash:
bool dummy1, dummy2;
string cashAddress = BitcoinCashAddressConversion.LegacyAddressToCashAddress(address, out dummy1, out dummy2);
// TODO: SELECTION OF BLOCK EXPLORER, ADDRESS STRING FORMAT TO GO WITH IT
addressInfoResult =
JObject.Parse(
new WebClient().DownloadString(
"https://bitcoincash.blockexplorer.com/api/addr/" + address));
"https://bch-insight.bitpay.com/api/addr/" + cashAddress));
JArray unspentArray;
@@ -504,7 +509,7 @@ namespace Swarmops.Logic.Financial
try
{
unspentArray = JArray.Parse(
new WebClient().DownloadString("https://bitcoincash.blockexplorer.com/api/addr/" + address + "/utxo"));
new WebClient().DownloadString("https://bch-insight.bitpay.com/api/addr/" + cashAddress + "/utxo"));
}
catch (WebException webException)