#include "headers.h"
#include "qtui.h"
-#include <QtGlobal>
#include <QString>
-#include <QTextDocument> // For Qt::escape
using namespace std;
-QString TransactionDesc::HtmlEscape(const QString& str, bool fMultiLine)
-{
- QString escaped = Qt::escape(str);
- if(fMultiLine)
- {
- escaped = escaped.replace("\n", "<br>\n");
- }
- return escaped;
-}
-
-QString TransactionDesc::HtmlEscape(const std::string& str, bool fMultiLine)
-{
- return HtmlEscape(QString::fromStdString(str), fMultiLine);
-}
-
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
{
if (!wtx.IsFinal())
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
- qint64 nTime = wtx.GetTxTime();
- qint64 nCredit = wtx.GetCredit();
- qint64 nDebit = wtx.GetDebit();
- qint64 nNet = nCredit - nDebit;
+ int64 nTime = wtx.GetTxTime();
+ int64 nCredit = wtx.GetCredit();
+ int64 nDebit = wtx.GetDebit();
+ int64 nNet = nCredit - nDebit;
strHTML += tr("<b>Status:</b> ") + FormatTxStatus(wtx);
int nRequests = wtx.GetRequestCount();
{
// Online transaction
if (!wtx.mapValue["from"].empty())
- strHTML += tr("<b>From:</b> ") + HtmlEscape(wtx.mapValue["from"]) + "<br>";
+ strHTML += tr("<b>From:</b> ") + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
}
else
{
if (wallet->IsMine(txout))
{
CBitcoinAddress address;
- if (ExtractAddress(txout.scriptPubKey, wallet, address))
+ if (ExtractAddress(txout.scriptPubKey, address) && wallet->HaveKey(address))
{
if (wallet->mapAddressBook.count(address))
{
strHTML += tr("<b>From:</b> ") + tr("unknown") + "<br>";
strHTML += tr("<b>To:</b> ");
- strHTML += HtmlEscape(address.ToString());
+ strHTML += GUIUtil::HtmlEscape(address.ToString());
if (!wallet->mapAddressBook[address].empty())
- strHTML += tr(" (yours, label: ") + HtmlEscape(wallet->mapAddressBook[address]) + ")";
+ strHTML += tr(" (yours, label: ") + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";
else
strHTML += tr(" (yours)");
strHTML += "<br>";
strAddress = wtx.mapValue["to"];
strHTML += tr("<b>To:</b> ");
if (wallet->mapAddressBook.count(strAddress) && !wallet->mapAddressBook[strAddress].empty())
- strHTML += HtmlEscape(wallet->mapAddressBook[strAddress]) + " ";
- strHTML += HtmlEscape(strAddress) + "<br>";
+ strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[strAddress]) + " ";
+ strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>";
}
//
//
// Coinbase
//
- qint64 nUnmatured = 0;
+ int64 nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout);
strHTML += tr("<b>Credit:</b> ");
{
// Offline transaction
CBitcoinAddress address;
- if (ExtractAddress(txout.scriptPubKey, 0, address))
+ if (ExtractAddress(txout.scriptPubKey, address))
{
strHTML += tr("<b>To:</b> ");
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
- strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " ";
- strHTML += HtmlEscape(address.ToString());
+ strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " ";
+ strHTML += GUIUtil::HtmlEscape(address.ToString());
strHTML += "<br>";
}
}
if (fAllToMe)
{
// Payment to self
- qint64 nChange = wtx.GetChange();
- qint64 nValue = nCredit - nChange;
+ int64 nChange = wtx.GetChange();
+ int64 nValue = nCredit - nChange;
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
strHTML += tr("<b>Credit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "<br>";
}
- qint64 nTxFee = nDebit - wtx.GetValueOut();
+ int64 nTxFee = nDebit - wtx.GetValueOut();
if (nTxFee > 0)
strHTML += tr("<b>Transaction fee:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-nTxFee) + "<br>";
}
// Message
//
if (!wtx.mapValue["message"].empty())
- strHTML += QString("<br><b>") + tr("Message:") + "</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";
+ strHTML += QString("<br><b>") + tr("Message:") + "</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "<br>";
if (!wtx.mapValue["comment"].empty())
- strHTML += QString("<br><b>") + tr("Comment:") + "</b><br>" + HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
+ strHTML += QString("<br><b>") + tr("Comment:") + "</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
+
+ strHTML += QString("<b>") + tr("Transaction ID:") + "</b> " + wtx.GetHash().ToString().c_str() + "<br>";
if (wtx.IsCoinBase())
strHTML += QString("<br>") + tr("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";
strHTML += "<b>Credit:</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,wallet->GetCredit(txout)) + "<br>";
strHTML += "<br><b>Transaction:</b><br>";
- strHTML += HtmlEscape(wtx.ToString(), true);
+ strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);
CTxDB txdb("r"); // To fetch source txouts
strHTML += "<li>";
const CTxOut &vout = prev.vout[prevout.n];
CBitcoinAddress address;
- if (ExtractAddress(vout.scriptPubKey, 0, address))
+ if (ExtractAddress(vout.scriptPubKey, address))
{
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
- strHTML += HtmlEscape(wallet->mapAddressBook[address]) + " ";
+ strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " ";
strHTML += QString::fromStdString(address.ToString());
}
strHTML = strHTML + " Amount=" + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,vout.nValue);