Testing part 5

This commit is contained in:
Rick Falkvinge
2017-11-20 18:46:08 +01:00
parent e67373cafd
commit 811d2b2c6b
5 changed files with 43 additions and 22 deletions
+9
View File
@@ -726,6 +726,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to Funds Received ({0}).
/// </summary>
internal static string Donate_FundsReceivedLabel {
get {
return ResourceManager.GetString("Donate_FundsReceivedLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Received {0} microcoins (&quot;bits&quot;). Thank you!.
/// </summary>
@@ -642,4 +642,8 @@
<data name="CreateOutboundInvoice_SuccessMessage" xml:space="preserve">
<value>Outbound Invoice #{0:N0} filed.</value>
</data>
<data name="Donate_FundsReceivedLabel" xml:space="preserve">
<value>Funds Received ({0})</value>
<comment>The {0} will be replaced with currency name.</comment>
</data>
</root>
+16 -9
View File
@@ -21,13 +21,19 @@
});
socket.on(eventToListenTo, function(data) {
console.log(data);
console.log("txid: " + data.txid);
var utxoCount = data.vout.length;
for (var index = 0; index < utxoCount; index++)
{
for (var address in data.vout[index]) {
console.log(" - address " + address + " gets " + data.vout[index][address]);
for (var outAddress in data.vout[index]) {
if (outAddress == pageDonationAddress) {
var donatedSatoshis = data.vout[index][outAddress];
donatedFunds += (donatedSatoshis * conversionRateSatoshisToCents / 100.0);
odoDonatedCents.innerHTML = donatedFunds; // looks weird but $('#id') not used with odo
// do an Ajax call as well here
}
}
}
});
@@ -38,14 +44,13 @@
// This function is detected called by the Master Page; it is not
// called from this page or anything visible here
// console.log("address: " + address);
// console.log("hash: " + hash);
// console.log("satoshis: " + satoshis);
// console.log("cents: " + cents);
// console.log("currencyCode: " + currencyCode);
if (address == addressUsed) {
if (address == pageDonationAddress) {
// We have received a donation at this address
donatedFunds += (cents / 100.0);
@@ -74,8 +79,9 @@
var donatedFunds = 0.001; // the 0.1 cents are necessary for an odometer workaround
var addressUsed = '<asp:Literal runat="server" ID="LiteralBitcoinAddress" />';
var guid = '<asp:Literal runat="server" ID="LiteralGuid" />';
var pageDonationAddress = SwarmopsJS.unescape(<%=this.BitcoinCashAddressUsed %>);
var guid = SwarmopsJS.unescape('<%=this.TransactionGuid%>');
var conversionRateSatoshisToCents = <%= this.ConversionRateSatoshisToCents %>;
var completed = false;
</script>
@@ -85,7 +91,8 @@
<div class="box" style="background-image: url(/Images/Other/coins-background-istockphoto.jpg); background-size: 700px">
<div class="content">
<div class="odometer-wrapper">
<div class="elementFloatFar odometer odometer-currency" id="odoDonatedCents">0.001</div><div class="odometer-label">Received funds (CUR)</div>
<div class="elementFloatFar odometer odometer-currency" id="odoDonatedCents">0.001</div>
<div class="odometer-label"><asp:Label runat="server" ID="LabelReceivedFunds"/></div>
</div>
</div>
</div>
+12 -2
View File
@@ -54,10 +54,14 @@ namespace Swarmops.Frontend.Pages.v5.Financial
HotBitcoinAddress address = HotBitcoinAddress.Create (this.CurrentOrganization, BitcoinChain.Cash,
BitcoinUtility.BitcoinDonationsIndex, this.CurrentUser.Identity);
this.LiteralBitcoinAddress.Text = address.Address;
string guid = Guid.NewGuid().ToString ("N");
GuidCache.Set (guid, address.Address);
this.LiteralGuid.Text = guid;
this.TransactionGuid = guid;
// Calculate conversion rate (satoshi-cents to unit-cents, so we're good, even if the conversion rate
// is calculated on microbitcoin to whole units)
this.ConversionRateSatoshisToCents = Currency.BitcoinCash.GetConversionRate(CurrentOrganization.Currency);
// Add subscription to address
/* --- RETIRED CODE -- THIS WAS NOT RELIABLE -- DONE CLIENT SIDE INSTEAD
@@ -79,6 +83,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.BoxTitle.Text = Resources.Pages.Financial.Donate_PageTitle;
this.LabelExplainBitcoinDonation.Text = String.Format (Resources.Pages.Financial.Donate_Explain,
CurrentOrganization.Name, address.Address);
this.LabelReceivedFunds.Text = String.Format(Resources.Pages.Financial.Donate_FundsReceivedLabel,
CurrentOrganization.Currency.DisplayCode);
this.ImageBitcoinQr.ImageUrl =
"https://chart.googleapis.com/chart?cht=qr&chs=400x400&chl=bitcoincash:" +
@@ -87,6 +93,10 @@ namespace Swarmops.Frontend.Pages.v5.Financial
CurrentOrganization.Name))); // URI scheme doesn't like &, =
}
public string BitcoinCashAddressUsed { get; private set; }
public string TransactionGuid { get; private set; }
public double ConversionRateSatoshisToCents { get; private set; }
[WebMethod]
static public AjaxCallResult ProcessTransactionReceived (string guid, string txHash)
{
+2 -11
View File
@@ -13,22 +13,13 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
public partial class Donate {
/// <summary>
/// LiteralBitcoinAddress control.
/// LabelReceivedFunds control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal LiteralBitcoinAddress;
/// <summary>
/// LiteralGuid control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal LiteralGuid;
protected global::System.Web.UI.WebControls.Label LabelReceivedFunds;
/// <summary>
/// PanelEnabled control.