From 7cd9f15adcbcf858f0d4b09f54e55a1c575d077a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 19 May 2018 14:15:16 +0200 Subject: [PATCH] Switching Insight to Bitpay --- DebugConsole/Program.cs | 17 +++++++++++++++-- Logic/Financial/BitcoinUtility.cs | 11 ++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/DebugConsole/Program.cs b/DebugConsole/Program.cs index 0d2d5003..150601e4 100644 --- a/DebugConsole/Program.cs +++ b/DebugConsole/Program.cs @@ -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); + } } } diff --git a/Logic/Financial/BitcoinUtility.cs b/Logic/Financial/BitcoinUtility.cs index ee615cc8..aee72575 100644 --- a/Logic/Financial/BitcoinUtility.cs +++ b/Logic/Financial/BitcoinUtility.cs @@ -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)