diff --git a/Backend/Backend.csproj b/Backend/Backend.csproj index 7afe2779..dd659c1e 100644 --- a/Backend/Backend.csproj +++ b/Backend/Backend.csproj @@ -63,6 +63,10 @@ ..\packages\Mono.Posix-4.5.4.5.0\lib\net45\Mono.Posix.dll True + + ..\packages\NBitcoin.3.0.0.84\lib\net45\NBitcoin.dll + True + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True diff --git a/Backend/BackendLoop.cs b/Backend/BackendLoop.cs index aeee8a1f..c4e2887f 100644 --- a/Backend/BackendLoop.cs +++ b/Backend/BackendLoop.cs @@ -19,7 +19,9 @@ using Swarmops.Utility; using Swarmops.Utility.BotCode; using Swarmops.Utility.Communications; using Swarmops.Utility.Mail; +using WebSocketSharp; using WebSocketSharp.Server; +using Satoshis=NBitcoin.Money; namespace Swarmops.Backend { @@ -204,112 +206,128 @@ namespace Swarmops.Backend _socketServer.AddWebSocketService("/Backend"); _socketServer.Start(); - // Begin maintenance loop + // Initialize socket client to Blockchain.Info (pending our own services) - DateTime cycleStartTime = DateTime.UtcNow; - DateTime cycleEndTime; - - int lastSecond = cycleStartTime.Second; - int lastMinute = cycleStartTime.Minute; - int lastHour = cycleStartTime.Hour; - - bool exitFlag = false; - - while (!exitFlag) // exit is handled by signals handling at end of loop + using ( + _blockChainInfoSocket = + new WebSocket("wss://ws.blockchain.info/inv?api_code=" + SystemSettings.BlockchainSwarmopsApiKey)) { - BotLog.Write (0, "MainCycle", "Cycle Start"); - cycleStartTime = DateTime.UtcNow; - cycleEndTime = cycleStartTime.AddSeconds(10); + // Begin maintenance loop - try + DateTime cycleStartTime = DateTime.UtcNow; + DateTime cycleEndTime; + + int lastSecond = cycleStartTime.Second; + int lastMinute = cycleStartTime.Minute; + int lastHour = cycleStartTime.Hour; + + bool exitFlag = false; + + _blockChainInfoSocket.OnOpen += new EventHandler(OnBlockchainOpen); + _blockChainInfoSocket.OnError += new EventHandler(OnBlockchainError); + _blockChainInfoSocket.OnClose += new EventHandler(OnBlockchainClose); + _blockChainInfoSocket.OnMessage += new EventHandler(OnBlockchainMessage); + + _blockChainInfoSocket.Connect(); + + while (!exitFlag) // exit is handled by signals handling at end of loop { - OnEveryTenSeconds(); + BotLog.Write(0, "MainCycle", "Cycle Start"); - if (cycleStartTime.Second < lastSecond) + cycleStartTime = DateTime.UtcNow; + cycleEndTime = cycleStartTime.AddSeconds(10); + + try { - OnEveryMinute(); + OnEveryTenSeconds(); - if (cycleStartTime.Minute%5 == 0) + if (cycleStartTime.Second < lastSecond) { - OnEveryFiveMinutes(); + OnEveryMinute(); + + if (cycleStartTime.Minute%5 == 0) + { + OnEveryFiveMinutes(); + } + } + + if (cycleStartTime.Minute < lastMinute) + { + OnEveryHour(); + + if (DateTime.Now.Hour == 10 && DateTime.Today.DayOfWeek == DayOfWeek.Tuesday) + { + OnTuesdayMorning(); + } + + if (DateTime.Now.Hour == 7 && DateTime.Today.DayOfWeek == DayOfWeek.Monday) + { + OnMondayMorning(); + } + } + + if (cycleStartTime.Hour >= 12 && lastHour < 12) + { + OnNoon(); + } + + if (cycleStartTime.Hour < lastHour) + { + OnMidnight(); } } - if (cycleStartTime.Minute < lastMinute) + catch (Exception e) { - OnEveryHour(); + // Note each "OnEvery..." catches its own errors and sends Exception mails, + // so that failure in one should not stop the others from running. This particular + // code should never run. - if (DateTime.Now.Hour == 10 && DateTime.Today.DayOfWeek == DayOfWeek.Tuesday) + ExceptionMail.Send(new Exception("Failed in swarmops-backend main loop", e), true); + } + + lastSecond = cycleStartTime.Second; + lastMinute = cycleStartTime.Minute; + lastHour = cycleStartTime.Hour; + + // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime) + + DateTime utcNow = DateTime.UtcNow; + while (utcNow < cycleEndTime && !exitFlag) + { + int signalIndex = 250; + + // Block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. + // However, we can't do that in a development environment - it won't have the + // Mono.Posix assembly, and won't understand UnixSignals. So people running this in + // a dev environment will need to stop it manually. + + if (!Debugger.IsAttached) { - OnTuesdayMorning(); + signalIndex = UnixSignal.WaitAny(killSignals, 250); + } + else + { + TimeSpan timeLeft = (cycleEndTime - utcNow); + + BotLog.Write(0, "MainCycle Debug", + string.Format(CultureInfo.InvariantCulture, + "Waiting for {0:F2} more seconds for cycle end", + timeLeft.TotalMilliseconds/1000.0)); + Thread.Sleep(250); } - if (DateTime.Now.Hour == 7 && DateTime.Today.DayOfWeek == DayOfWeek.Monday) + if (signalIndex < 250) { - OnMondayMorning(); + exitFlag = true; + Console.WriteLine("Caught signal " + killSignals[signalIndex].Signum + ", exiting"); + BotLog.Write(0, "MainCycle", + "EXIT SIGNAL (" + killSignals[signalIndex].Signum + "), terminating backend"); } + + utcNow = DateTime.UtcNow; } - - if (cycleStartTime.Hour >= 12 && lastHour < 12) - { - OnNoon(); - } - - if (cycleStartTime.Hour < lastHour) - { - OnMidnight(); - } - } - - catch (Exception e) - { - // Note each "OnEvery..." catches its own errors and sends Exception mails, - // so that failure in one should not stop the others from running. This particular - // code should never run. - - ExceptionMail.Send (new Exception ("Failed in swarmops-backend main loop", e), true); - } - - lastSecond = cycleStartTime.Second; - lastMinute = cycleStartTime.Minute; - lastHour = cycleStartTime.Hour; - - // Wait for a maximum of ten seconds (the difference between cycleStartTime and cycleEndTime) - - DateTime utcNow = DateTime.UtcNow; - while (utcNow < cycleEndTime && !exitFlag) - { - int signalIndex = 250; - - // Block until a SIGINT or SIGTERM signal is generated, or 1/4 second has passed. - // However, we can't do that in a development environment - it won't have the - // Mono.Posix assembly, and won't understand UnixSignals. So people running this in - // a dev environment will need to stop it manually. - - if (!Debugger.IsAttached) - { - signalIndex = UnixSignal.WaitAny(killSignals, 250); - } - else - { - TimeSpan timeLeft = (cycleEndTime - utcNow); - - BotLog.Write(0, "MainCycle Debug", - string.Format(CultureInfo.InvariantCulture, "Waiting for {0:F2} more seconds for cycle end", - timeLeft.TotalMilliseconds / 1000.0)); - Thread.Sleep(250); - } - - if (signalIndex < 250) - { - exitFlag = true; - Console.WriteLine ("Caught signal " + killSignals[signalIndex].Signum + ", exiting"); - BotLog.Write (0, "MainCycle", - "EXIT SIGNAL (" + killSignals[signalIndex].Signum + "), terminating backend"); - } - - utcNow = DateTime.UtcNow; } } @@ -612,7 +630,7 @@ namespace Swarmops.Backend { TraceAndReport (e); } - + try { BotLog.DeleteOld (14); // delete logs older than 14 days @@ -825,13 +843,162 @@ namespace Swarmops.Backend private static void BroadcastTimestamp() { JObject json = new JObject(); - json["messageType"] = "Heartbeat"; + json["MessageType"] = "Heartbeat"; json["Timestamp"] = DateTime.UtcNow.ToUnix(); _socketServer.WebSocketServices.Broadcast(json.ToString()); } + // ------------------------------- BLOCKCHAIN.INFO WEB SOCKET INTERFACE CODE ------------------------- + + public static void OnBlockchainOpen(object sender, EventArgs args) + { + Console.WriteLine(" - Socket to Blockchain open and active"); + // TODO: Subscribe to all active addresses + } + + public static void OnBlockchainError(object sender, ErrorEventArgs args) + { + Console.WriteLine(" - ERROR on Blockchain socket: " + args.Message); + } + + public static void OnBlockchainClose(object sender, CloseEventArgs args) + { + Console.WriteLine(" - Socket to Blockchain CLOSED"); + } + + public static void OnBlockchainMessage(object sender, MessageEventArgs args) + { + Console.WriteLine(" - Blockchain says: " + args.Data); + + JObject json = JObject.Parse(args.Data); + string op = (string) json["op"]; + + switch (op) + { + case "utx": + // transaction received on an address we sub to + ProcessBitcoinTransaction(json); + break; + default: + Console.WriteLine(" -- unknown/unhandled op: '{0}'", op); + break; + } + + // A LOT OF TODO HERE + + + } + + + internal static void ProcessBitcoinTransaction(JObject blockchainTransaction) + { + /* Format: + + { + "op": "utx", + "x": { + "lock_time": 0, + "ver": 1, + "size": 192, + "inputs": [ + { + "sequence": 4294967295, + "prev_out": { + "spent": true, + "tx_index": 99005468, + "type": 0, + "addr": "1BwGf3z7n2fHk6NoVJNkV32qwyAYsMhkWf", + "value": 65574000, + "n": 0, + "script": "76a91477f4c9ee75e449a74c21a4decfb50519cbc245b388ac" + }, + "script": "483045022100e4ff962c292705f051c2c2fc519fa775a4d8955bce1a3e29884b2785277999ed02200b537ebd22a9f25fbbbcc9113c69c1389400703ef2017d80959ef0f1d685756c012102618e08e0c8fd4c5fe539184a30fe35a2f5fccf7ad62054cad29360d871f8187d" + } + ], + "time": 1440086763, + "tx_index": 99006637, + "vin_sz": 1, + "hash": "0857b9de1884eec314ecf67c040a2657b8e083e1f95e31d0b5ba3d328841fc7f", + "vout_sz": 1, + "relayed_by": "127.0.0.1", + "out": [ + { + "spent": false, + "tx_index": 99006637, + "type": 0, + "addr": "1A828tTnkVFJfSvLCqF42ohZ51ksS3jJgX", + "value": 65564000, + "n": 0, + "script": "76a914640cfdf7b79d94d1c980133e3587bd6053f091f388ac" + } + ] + } + } + */ + + Console.WriteLine(" - block received"); + + if (_transactionCache == null) + { + _transactionCache = new SerializableDictionary(); + } + + _transactionCache[(string) (blockchainTransaction["x"]["hash"])] = (JObject) blockchainTransaction["x"]; + + foreach (JObject outpoint in blockchainTransaction["x"]["out"]) + { + Satoshis satoshis = Int64.Parse((string) outpoint["value"]); + string addressString = (string) outpoint["addr"]; + + HotBitcoinAddress hotAddress = null; + + try + { + hotAddress = HotBitcoinAddress.FromAddress(addressString); + } + catch (ArgumentException) + { + // Ignore this - it means the addressString isn't ours + throw; + } + + if (hotAddress != null) + { + JObject json = new JObject(); + json["MessageType"] = "BitcoinReceived"; + json["Address"] = addressString; + + Currency currency = hotAddress.Organization.Currency; + json["OrganizationId"] = hotAddress.OrganizationId.ToString(); + json["Currency"] = currency.Code; + Swarmops.Logic.Financial.Money organizationCents = new Money(satoshis, Currency.Bitcoin).ToCurrency(currency); + json["Satoshis"] = satoshis.ToString(); + json["Cents"] = organizationCents.Cents.ToString(); + json["CentsFormatted"] = String.Format("N2", organizationCents.Cents/100.0); + + _socketServer.WebSocketServices.Broadcast(json.ToString()); + + // TODO: Examine what address this is, handle accordingly + } + } + + } + + + public static void AddBitcoinAddress(string address) + { + JObject json = new JObject(); + json["op"] = "addr_sub"; + json["addr"] = address; + + _blockChainInfoSocket.Send(json.ToString()); + } + + + private static WebSocket _blockChainInfoSocket; private static WebSocketServer _socketServer; + private static SerializableDictionary _transactionCache; // Need mechanism to clear this over time } } \ No newline at end of file diff --git a/Backend/SocketServices/BackendServices.cs b/Backend/SocketServices/BackendServices.cs index e61e9cb4..da965d0f 100644 --- a/Backend/SocketServices/BackendServices.cs +++ b/Backend/SocketServices/BackendServices.cs @@ -22,7 +22,7 @@ namespace Swarmops.Backend.SocketServices // Basically just echo whatever's sent here JObject json = JObject.Parse(e.Data); - string serverRequest = (string)json["serverRequest"]; + string serverRequest = (string)json["BackendRequest"]; if (string.IsNullOrEmpty(serverRequest)) { @@ -35,6 +35,9 @@ namespace Swarmops.Backend.SocketServices case "UpdateQueueCounts": //Sessions.Broadcast(Program.GetQueueInfoJson()); break; + case "AddBitcoinAddress": + BackendLoop.AddBitcoinAddress((string) json["Address"]); + break; default: // do nothing; break; diff --git a/Backend/packages.config b/Backend/packages.config index f035528a..71c2fbf1 100644 --- a/Backend/packages.config +++ b/Backend/packages.config @@ -1,6 +1,7 @@  + \ No newline at end of file diff --git a/FrontSocket/Frontend-Socket.csproj b/FrontSocket/Frontend-Socket.csproj index d585daa2..a89d54fa 100644 --- a/FrontSocket/Frontend-Socket.csproj +++ b/FrontSocket/Frontend-Socket.csproj @@ -38,6 +38,10 @@ ..\packages\Mono.Posix-4.5.4.5.0\lib\net45\Mono.Posix.dll True + + ..\packages\NBitcoin.3.0.0.84\lib\net45\NBitcoin.dll + True + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True diff --git a/FrontSocket/FrontendLoop.cs b/FrontSocket/FrontendLoop.cs index 4f83fd68..f2e12c1a 100644 --- a/FrontSocket/FrontendLoop.cs +++ b/FrontSocket/FrontendLoop.cs @@ -86,13 +86,13 @@ namespace Swarmops.Frontend.Socket Console.WriteLine("Connecting backend socket " + backendSocketUri); - using (var socketClient = new WebSocket(backendSocketUri)) + using (_backendSocket = new WebSocket(backendSocketUri)) { - socketClient.OnMessage += new EventHandler(OnBackendMessage); - socketClient.OnOpen += new EventHandler(OnBackendOpen); - socketClient.OnClose += new EventHandler(OnBackendClose); - socketClient.OnError += new EventHandler(OnBackendError); - socketClient.Connect(); + _backendSocket.OnMessage += new EventHandler(OnBackendMessage); + _backendSocket.OnOpen += new EventHandler(OnBackendOpen); + _backendSocket.OnClose += new EventHandler(OnBackendClose); + _backendSocket.OnError += new EventHandler(OnBackendError); + _backendSocket.Connect(); while (!exitFlag) // exit is handled by signals handling at end of loop { @@ -197,6 +197,8 @@ namespace Swarmops.Frontend.Socket private static WebSocketServer _socketServer; + private static WebSocket _backendSocket; + private static bool _isSandbox = false; private static int _sandboxDummy1 = 500; private static int _sandboxDummy2 = 50000; @@ -211,9 +213,9 @@ namespace Swarmops.Frontend.Socket _sandboxDummy2 += new Random().Next(1000) - 200; JObject data = new JObject(); - data["messageType"] = "SandboxUpdate"; - data["local"] = _sandboxDummy1.ToString(CultureInfo.InvariantCulture); - data["profit"] = _sandboxDummy2.ToString(CultureInfo.InvariantCulture); + data["MessageType"] = "SandboxUpdate"; + data["Local"] = _sandboxDummy1.ToString(CultureInfo.InvariantCulture); + data["Profit"] = _sandboxDummy2.ToString(CultureInfo.InvariantCulture); _socketServer.WebSocketServices.Broadcast(data.ToString()); } @@ -273,6 +275,18 @@ namespace Swarmops.Frontend.Socket + public static void AddBitcoinAddress(string address) + { + JObject json = new JObject(); + json["BackendRequest"] = "AddBitcoinAddress"; + json["Address"] = address; + + _backendSocket.Send(json.ToString()); + } + + + + // --------------------------------- LEGACY CODE BELOW THIS MARK ------------------------------- diff --git a/FrontSocket/FrontendServices.cs b/FrontSocket/FrontendServices.cs index 827d74c9..9ca41dc7 100644 --- a/FrontSocket/FrontendServices.cs +++ b/FrontSocket/FrontendServices.cs @@ -23,7 +23,7 @@ namespace Swarmops.Frontend.Socket // Basically just echo whatever's sent here JObject json = JObject.Parse (e.Data); - string serverRequest = (string) json["serverRequest"]; + string serverRequest = (string) json["ServerRequest"]; if (string.IsNullOrEmpty (serverRequest)) { @@ -33,8 +33,8 @@ namespace Swarmops.Frontend.Socket switch (serverRequest) { - case "UpdateQueueCounts": - // Sessions.Broadcast (FrontendLoop.GetQueueInfoJson()); + case "AddBitcoinAddress": + FrontendLoop.AddBitcoinAddress((string) json["Address"]); break; case "Ping": // TODO: Request heartbeat from backend @@ -67,7 +67,7 @@ namespace Swarmops.Frontend.Socket { base.OnClose (e); - Sessions.Broadcast("{\"messageType\":\"EditorCount\"," + String.Format("\"editorCount\":\"{0}\"", Sessions.ActiveIDs.ToArray().Length) + '}'); + // Sessions.Broadcast("{\"messageType\":\"EditorCount\"," + String.Format("\"editorCount\":\"{0}\"", Sessions.ActiveIDs.ToArray().Length) + '}'); } private Authority _authority = null; diff --git a/FrontSocket/packages.config b/FrontSocket/packages.config index 3d24f69b..621bfc9b 100644 --- a/FrontSocket/packages.config +++ b/FrontSocket/packages.config @@ -1,6 +1,7 @@  + \ No newline at end of file diff --git a/Site/Automation/Json-PositionsTree.aspx b/Site/Automation/Json-PositionsTree.aspx index 308f9fd0..f236ea22 100644 --- a/Site/Automation/Json-PositionsTree.aspx +++ b/Site/Automation/Json-PositionsTree.aspx @@ -1 +1 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-PositionsTree.aspx.cs" Inherits="Swarmops.Frontend.Automation.Json_PositionsTree" %> +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Json-PositionsTree.aspx.cs" CodeBehind="Json-PositionsTree.aspx.cs" Inherits="Swarmops.Frontend.Automation.Json_PositionsTree" %> diff --git a/Site/Default.aspx b/Site/Default.aspx index df31ebff..560a7d06 100644 --- a/Site/Default.aspx +++ b/Site/Default.aspx @@ -1,18 +1,17 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" Inherits="Swarmops.Frontend.Default" CodeFile="Default.aspx.cs" %> - - -
-
12342500
Current Participants (Testing new code)
+
+
12342500
Current Participants (Testing new code)
-
125498
Active Participants Last 30 Days (Testing new code)
+
+
125498
Active Participants Last 30 Days (Testing new code)

@@ -23,9 +22,13 @@
-
-
0.001
Annual Profit To Date (Testing new code)
-
+
+
+
+
0.001
Annual Profit To Date (Testing new code)
+
+
+

diff --git a/Site/Master-v5.master b/Site/Master-v5.master index 2c45594f..350fbe5e 100644 --- a/Site/Master-v5.master +++ b/Site/Master-v5.master @@ -24,7 +24,8 @@ - + + @@ -45,6 +46,7 @@ + diff --git a/Site/Pages/v5/Financial/Donate.aspx b/Site/Pages/v5/Financial/Donate.aspx index a1d2ab02..cd5f8952 100644 --- a/Site/Pages/v5/Financial/Donate.aspx +++ b/Site/Pages/v5/Financial/Donate.aspx @@ -5,80 +5,55 @@ +
+
+
+
0.001
Annual Profit To Date (Testing new code)
+
+
+
+ +

@@ -92,6 +67,7 @@

Contact the administrator for <%=this.CurrentOrganization.Name %> and ask them to enable the bitcoin hotwallet.

+
diff --git a/Site/Pages/v5/Financial/Donate.aspx.cs b/Site/Pages/v5/Financial/Donate.aspx.cs index c5cdfc23..b5efd6a3 100644 --- a/Site/Pages/v5/Financial/Donate.aspx.cs +++ b/Site/Pages/v5/Financial/Donate.aspx.cs @@ -21,6 +21,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial protected void Page_Load (object sender, EventArgs e) { this.PageAccessRequired = new Access (this.CurrentOrganization, AccessAspect.Participant); + this.IsDashboard = true; // prevents encaps and enables odometer /* TEMP TEMP TEMP - REMOVE THIS CODE */ /* @@ -38,13 +39,11 @@ namespace Swarmops.Frontend.Pages.v5.Financial this.PageTitle = Resources.Pages.Financial.Donate_PageTitle; this.InfoBoxLiteral = Resources.Pages.Financial.Donate_Info; this.LabelStatus.Text = Resources.Pages.Financial.Donate_StatusInitial; - this.LiteralTxDetected.Text = JavascriptEscape (Resources.Pages.Financial.Donate_TransactionDetected); if (this.CurrentOrganization.FinancialAccounts.AssetsBitcoinHot == null) { this.PanelDisabled.Visible = true; this.PanelEnabled.Visible = false; - this.LiteralEnable.Text = @"false"; } HotBitcoinAddress address = HotBitcoinAddress.Create (this.CurrentOrganization, @@ -88,7 +87,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial } [WebMethod] - static public AjaxCallResult CheckTransactionReceived (string guid, string txHash) + static public AjaxCallResult ProcessTransactionReceived (string guid, string txHash) { AuthenticationData authData = GetAuthenticationDataAndCulture(); // just to make sure we're called properly diff --git a/Site/Pages/v5/Financial/Donate.aspx.designer.cs b/Site/Pages/v5/Financial/Donate.aspx.designer.cs index f6a64b91..4a4050b7 100644 --- a/Site/Pages/v5/Financial/Donate.aspx.designer.cs +++ b/Site/Pages/v5/Financial/Donate.aspx.designer.cs @@ -12,15 +12,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial { public partial class Donate { - /// - /// LiteralTxDetected control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal LiteralTxDetected; - /// /// LiteralBitcoinAddress control. /// @@ -39,15 +30,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial { /// protected global::System.Web.UI.WebControls.Literal LiteralGuid; - /// - /// LiteralEnable control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal LiteralEnable; - /// /// PanelEnabled control. /// diff --git a/Site/Scripts/Swarmops-v5.js b/Site/Scripts/Swarmops-v5.js index b28f6445..d22160e2 100644 --- a/Site/Scripts/Swarmops-v5.js +++ b/Site/Scripts/Swarmops-v5.js @@ -31,15 +31,26 @@ function _masterInitializeSocket(authenticationTicket) { var message = $.parseJSON(data.data); - if (message.messageType == "Heartbeat") { + if (message.MessageType == "Heartbeat") { alertify.log("Master socket heartbeat: " + message.Timestamp); - } - else if (message.messageType == "SandboxUpdate") { + } + else if (message.MessageType == "BitcoinReceived") { + var handled = false; + + if (pageBitcoinReceived != undefined) { + handled = pageBitcoinReceived(message.Address, message.Hash, message.Satoshis, message.Cents, message.Currency); + } + + if (!handled) { + alertify.log("Bitcoin received: " + message.Currecy + " " + message.CentsFormatted); + } + } + else if (message.MessageType == "SandboxUpdate") { if (odoLocalParticipation != undefined) { // Real ugly accessing specific page elements here, but it's temporary - odoLocalParticipation.innerHTML = message.local; - odoGlobalParticipation.innerHTML = 12345678 + message.local * 5; - odoActiveParticipation.innerHTML = 123412 + message.local * 5; - odoProfitLossToDate.innerHTML = (message.profit / 100.0) + 0.001; + odoLocalParticipation.innerHTML = message.Local; + odoGlobalParticipation.innerHTML = 12345678 + message.Local * 5; + odoActiveParticipation.innerHTML = 123412 + message.Local * 5; + odoProfitLossToDate.innerHTML = (message.Profit / 100.0) + 0.001; } } };