Merge branch 'master' into sprint

This commit is contained in:
Rick Falkvinge
2016-04-26 14:37:22 +02:00
5 changed files with 57 additions and 11 deletions
+4
View File
@@ -725,4 +725,8 @@
<value>Flags</value>
<comment>As in a table column header</comment>
</data>
<data name="Global_Total" xml:space="preserve">
<value>Total</value>
<comment>Used as footer in tables, summarizing something</comment>
</data>
</root>
@@ -775,4 +775,11 @@
<data name="BitcoinHotwallet_PageTitle" xml:space="preserve">
<value>Bitcoin Hotwallet</value>
</data>
<data name="BitcoinHotWallet_TransactionHash" xml:space="preserve">
<value>Transaction Hash</value>
</data>
<data name="BitcoinHotWallet_UnspentTransaction" xml:space="preserve">
<value>Unspent TxOut</value>
<comment>The local translation of a bitcoin UTXO (Unspent Transaction Output).</comment>
</data>
</root>
+5 -5
View File
@@ -8,14 +8,14 @@
$('#tableHotwallet').treegrid(
{
onBeforeExpand: function (foo) {
$('span.profitlossdata-collapsed-' + foo.id).fadeOut('fast', function () {
$('span.profitlossdata-expanded-' + foo.id).fadeIn('slow');
$('span.bitcoinhotwalletdata-collapsed-' + foo.id).fadeOut('fast', function () {
$('span.bitcoinhotwalletdata-expanded-' + foo.id).fadeIn('slow');
});
},
onBeforeCollapse: function (foo) {
$('span.profitlossdata-expanded-' + foo.id).fadeOut('fast', function () {
$('span.profitlossdata-collapsed-' + foo.id).fadeIn('slow');
$('span.bitcoinhotwalletdata-expanded-' + foo.id).fadeOut('fast', function () {
$('span.bitcoinhotwalletdata-collapsed-' + foo.id).fadeIn('slow');
});
},
@@ -51,7 +51,7 @@
animate="true"
fitColumns="true"
showFooter="true"
idField="id" treeField="name">
idField="id" treeField="derivePath">
<thead>
<tr>
<th field="derivePath" width="108"><asp:Literal ID="LiteralHeaderDerivationPath" runat="server"/></th>
@@ -36,7 +36,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
{
this.LabelContentHeader.Text = Resources.Pages.Ledgers.BitcoinHotwallet_Header;
this.LiteralHeaderDerivationPath.Text = Resources.Pages.Ledgers.BitcoinHotwallet_DerivationPath;
this.LiteralHeaderAddress.Text = Resources.Pages.Ledgers.BitcoinHotwallet_Address;
this.LiteralHeaderAddress.Text = Resources.Pages.Ledgers.BitcoinHotwallet_Address + @" / " + Resources.Pages.Ledgers.BitcoinHotWallet_TransactionHash;
this.LiteralHeaderMicrocoins.Text = Resources.Pages.Ledgers.BitcoinHotwallet_BalanceMicrocoins;
this.LiteralHeaderFiatValue.Text = String.Format(Resources.Pages.Ledgers.BitcoinHotwallet_ValueFiat, CurrentOrganization.Currency.DisplayCode);
}
@@ -43,21 +43,49 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
foreach (HotBitcoinAddress address in addresses)
{
HotBitcoinAddressUnspents unspents = HotBitcoinAddressUnspents.ForAddress (address);
Int64 satoshisUnspentAddress = 0;
StringBuilder childResult = new StringBuilder(16384);
foreach (HotBitcoinAddressUnspent unspent in unspents)
{
childResult.Append ("{");
childResult.AppendFormat(
"\"id\":\"UTXO{0}\"," +
"\"derivePath\":\"{1}\"," +
"\"address\":\"{2}\"," +
"\"balanceMicrocoins\":\"{3}\"," +
"\"balanceFiat\":\"{4}\"",
unspent.Identity,
Resources.Pages.Ledgers.BitcoinHotWallet_UnspentTransaction,
unspent.TransactionHash,
(unspent.AmountSatoshis / 100.0).ToString("N2"),
(unspent.AmountSatoshis / 100.0 * conversionRate).ToString("N2")
);
satoshisUnspentAddress += unspent.AmountSatoshis;
childResult.Append("},");
}
if (unspents.Count > 0)
{
childResult.Remove (childResult.Length - 1, 1); // remove last comma
}
result.Append("{");
result.AppendFormat (
"\"id\":\"{0}\"," +
"\"derivePath\":\"{1}\"," +
"\"address\":\"{2}\"," +
"\"balanceMicrocoins\":\"{3}\"," +
"\"balanceFiat\":\"{4}\"",
"\"balanceFiat\":\"{4}\",",
address.Identity,
address.DerivationPath,
address.Address,
(address.BalanceSatoshis/100.0).ToString ("N2"),
(address.BalanceSatoshis/100.0*conversionRate).ToString ("N2")
JsonExpandingString (address.Identity, satoshisUnspentAddress),
JsonExpandingString (address.Identity, (Int64) (satoshisUnspentAddress * conversionRate))
);
result.Append ("\"state\":\"closed\",\"children\":[" + childResult.ToString() + "]");
result.Append("},");
satoshisTotal += address.BalanceSatoshis;
satoshisTotal += satoshisUnspentAddress;
}
if (addresses.Count > 0)
@@ -69,7 +97,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
result.Append("{");
result.AppendFormat("\"derivePath\":\"TOTAL\",\"balanceMicrocoins\":\"{0}\",\"balanceFiat\":\"{1:N2}\"",
result.AppendFormat("\"derivePath\":\"" + Resources.Global.Global_Total + "\",\"balanceMicrocoins\":\"{0}\",\"balanceFiat\":\"{1}\"",
(satoshisTotal / 100.0).ToString("N2"), (satoshisTotal / 100.0 * conversionRate).ToString("N2"));
result.Append("}]}"); // on separate line to suppress warning
@@ -78,6 +106,13 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
}
private string JsonExpandingString(int addressId, Int64 currencyValue)
{
return string.Format(CultureInfo.CurrentCulture,
"<span class=\\\"bitcoinhotwalletdata-collapsed-{0}\\\"><strong>&Sigma;</strong> {1:N2}</span><span class=\\\"bitcoinhotwalletdata-expanded-{0}\\\" style=\\\"display:none\\\">&nbsp;</span>",
addressId, currencyValue / 100.00);
}
}
}