From 24dbd17338ecb4c8dcb7833688a42928d394cb53 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 23 Nov 2017 16:35:10 +0100 Subject: [PATCH] Math fix IV --- .../Pages.Admin.designer.cs | 2 +- Site/App_GlobalResources/Pages.Admin.resx | 2 +- Site/Pages/v5/Admin/BitcoinEchoTest.aspx | 58 +++++++++++-------- Site/Pages/v5/Admin/BitcoinEchoTest.aspx.cs | 12 +++- 4 files changed, 47 insertions(+), 27 deletions(-) diff --git a/Site/App_GlobalResources/Pages.Admin.designer.cs b/Site/App_GlobalResources/Pages.Admin.designer.cs index ebf8bead..9673a9bc 100644 --- a/Site/App_GlobalResources/Pages.Admin.designer.cs +++ b/Site/App_GlobalResources/Pages.Admin.designer.cs @@ -61,7 +61,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to <strong>DUST COLLECTED</strong><br/><br/>The amount sent is smaller than the expected fee for returning it to you, which is {0} satoshis ({1} {2:N2}). The money you sent is now so-called "dust" on the bitcoin network, and won't be moved again.<br/><br/>Send a higher amount to perform an echo test.. + /// Looks up a localized string similar to <strong>DUST COLLECTED</strong><br/><br/>The amount sent is smaller than the expected fee for returning it to you, which is {0:N2} microcoins. The money you sent is now so-called "dust" on the bitcoin network, and won't be moved again.<br/><br/>Send a higher amount to perform an echo test.. /// internal static string BitcoinEchoTest_DustCollected { get { diff --git a/Site/App_GlobalResources/Pages.Admin.resx b/Site/App_GlobalResources/Pages.Admin.resx index 70716530..3db3f9e3 100644 --- a/Site/App_GlobalResources/Pages.Admin.resx +++ b/Site/App_GlobalResources/Pages.Admin.resx @@ -371,6 +371,6 @@ Government - <strong>DUST COLLECTED</strong><br/><br/>The amount sent is smaller than the expected fee for returning it to you, which is {0} satoshis ({1} {2:N2}). The money you sent is now so-called "dust" on the bitcoin network, and won't be moved again.<br/><br/>Send a higher amount to perform an echo test. + <strong>DUST COLLECTED</strong><br/><br/>The amount sent is smaller than the expected fee for returning it to you, which is {0:N2} microcoins. The money you sent is now so-called "dust" on the bitcoin network, and won't be moved again.<br/><br/>Send a higher amount to perform an echo test. \ No newline at end of file diff --git a/Site/Pages/v5/Admin/BitcoinEchoTest.aspx b/Site/Pages/v5/Admin/BitcoinEchoTest.aspx index 37bfa918..d58e21e7 100644 --- a/Site/Pages/v5/Admin/BitcoinEchoTest.aspx +++ b/Site/Pages/v5/Admin/BitcoinEchoTest.aspx @@ -31,35 +31,45 @@ if (outAddress == addressUsed) { - $('#paraStatus').text(verifyingText); var donatedSatoshis = data.vout[index][outAddress]; - console.log(donatedSatoshis); - sentFunds += Math.floor(donatedSatoshis * conversionRateSatoshisToCents) / 100.0; - odoSentCents.innerHTML = sentFunds; // looks weird but $('#id') not used with odo - var json = {}; - json.guid = guid; - json.txHash = data.txid; + if (donatedSatoshis > minerFeeSatoshis) { - SwarmopsJS.ajaxCall('/Pages/v5/Admin/BitcoinEchoTest.aspx/ProcessTransactionReceived', - json, - function (data) { - if (data.Success) { - var minerFeeCents = (Math.floor(minerFeeSatoshis * conversionRateSatoshisToCents) / 100.0); - minerFees -= minerFeeCents; - console.log(donatedSatoshis); - console.log("Miner fee is " + minerFeeSatoshis + " satoshis, translating to " + minerFeeCents + " cents"); - returnedFunds += Math.floor((donatedSatoshis - minerFeeSatoshis) * conversionRateSatoshisToCents) / 100.0; + $('#paraStatus').text(verifyingText); + console.log(donatedSatoshis); + sentFunds += Math.floor(donatedSatoshis * conversionRateSatoshisToCents) / 100.0; + odoSentCents.innerHTML = sentFunds; // looks weird but $('#id') not used with odo - odoMinerFeeCents.innerHTML = minerFees; - odoReturnedCents.innerHTML = returnedFunds; + var json = {}; + json.guid = guid; + json.txHash = data.txid; + + + SwarmopsJS.ajaxCall('/Pages/v5/Admin/BitcoinEchoTest.aspx/ProcessTransactionReceived', + json, + function(data) { + if (data.Success) { + var minerFeeCents = (Math.floor(minerFeeSatoshis * conversionRateSatoshisToCents) / 100.0); + minerFees -= minerFeeCents; + console.log(donatedSatoshis); + console.log("Miner fee is " + minerFeeSatoshis + " satoshis, translating to " + minerFeeCents + " cents"); + returnedFunds += Math.floor((donatedSatoshis - minerFeeSatoshis) * conversionRateSatoshisToCents) / 100.0; + + odoMinerFeeCents.innerHTML = minerFees; + odoReturnedCents.innerHTML = returnedFunds; + + $('#paraStatus').text(data.DisplayMessage); + $('#paraIntro').fadeOut().slideUp(); + $('#divQr').fadeOut().slideUp(); + completed = true; + } + }); + } else { + // Dust collected + + alertify.dialog(SwarmopsJS.unescape('<%=Localized_DustCollected%>')); + } - $('#paraStatus').text(data.DisplayMessage); - $('#paraIntro').fadeOut().slideUp(); - $('#divQr').fadeOut().slideUp(); - completed = true; - } - }); } } diff --git a/Site/Pages/v5/Admin/BitcoinEchoTest.aspx.cs b/Site/Pages/v5/Admin/BitcoinEchoTest.aspx.cs index fe18d3a7..773ccca8 100644 --- a/Site/Pages/v5/Admin/BitcoinEchoTest.aspx.cs +++ b/Site/Pages/v5/Admin/BitcoinEchoTest.aspx.cs @@ -31,7 +31,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin // This page is copied from Donate, with the echo payout added to the end this.PageTitle = Resources.Pages.Admin.BitcoinEchoTest_PageTitle; - this.InfoBoxLiteral = Resources.Pages.Admin.BitcoinEchoTest_Info; + this.InfoBoxLiteral = String.Format(Resources.Pages.Admin.BitcoinEchoTest_Info, BitcoinUtility.EchoFeeSatoshis / 100.0); this.LabelStatus.Text = Resources.Pages.Admin.BitcoinEchoTest_StatusInitial; this.SuppressStatisticHeaders = true; @@ -184,5 +184,15 @@ namespace Swarmops.Frontend.Pages.v5.Admin get { return CommonV5.JavascriptEscape(Resources.Pages.Financial.Donate_TransactionDetected); } } + public string Localized_DustCollected + { + get + { + return + CommonV5.JavascriptEscape(String.Format(Resources.Pages.Admin.BitcoinEchoTest_DustCollected, + BitcoinUtility.EchoFeeSatoshis/100.0)); + } + } + } } \ No newline at end of file