X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Ftransactiondesc.cpp;h=286cddf2a920492076d78e1a34854c4fd13c7d6f;hb=ed6d0b5f852dc5f1c9407abecb5a9c6a7e42b4b2;hp=6ca3ac8c4b4e40672dac7839d5a8065c722db156;hpb=c5aa1b139a983613b1d5acc8f57804a9c66d4ff1;p=novacoin.git diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 6ca3ac8..286cddf 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -1,31 +1,17 @@ -#include +#include "transactiondesc.h" #include "guiutil.h" #include "bitcoinunits.h" -#include "headers.h" -#include "qtui.h" +#include "main.h" +#include "wallet.h" +#include "db.h" +#include "ui_interface.h" #include -#include // 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", "
\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()) @@ -50,8 +36,9 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { QString strHTML; - CRITICAL_BLOCK(wallet->cs_wallet) + { + LOCK(wallet->cs_wallet); strHTML.reserve(4000); strHTML += ""; @@ -86,7 +73,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { // Online transaction if (!wtx.mapValue["from"].empty()) - strHTML += tr("From: ") + HtmlEscape(wtx.mapValue["from"]) + "
"; + strHTML += tr("From: ") + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "
"; } else { @@ -99,15 +86,15 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) 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("From: ") + tr("unknown") + "
"; strHTML += tr("To: "); - 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 += "
"; @@ -129,8 +116,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strAddress = wtx.mapValue["to"]; strHTML += tr("To: "); if (wallet->mapAddressBook.count(strAddress) && !wallet->mapAddressBook[strAddress].empty()) - strHTML += HtmlEscape(wallet->mapAddressBook[strAddress]) + " "; - strHTML += HtmlEscape(strAddress) + "
"; + strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[strAddress]) + " "; + strHTML += GUIUtil::HtmlEscape(strAddress) + "
"; } // @@ -184,12 +171,12 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { // Offline transaction CBitcoinAddress address; - if (ExtractAddress(txout.scriptPubKey, 0, address)) + if (ExtractAddress(txout.scriptPubKey, address)) { strHTML += tr("To: "); 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 += "
"; } } @@ -230,9 +217,11 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) // Message // if (!wtx.mapValue["message"].empty()) - strHTML += QString("
") + tr("Message:") + "
" + HtmlEscape(wtx.mapValue["message"], true) + "
"; + strHTML += QString("
") + tr("Message:") + "
" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "
"; if (!wtx.mapValue["comment"].empty()) - strHTML += QString("
") + tr("Comment:") + "
" + HtmlEscape(wtx.mapValue["comment"], true) + "
"; + strHTML += QString("
") + tr("Comment:") + "
" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "
"; + + strHTML += QString("") + tr("Transaction ID:") + " " + wtx.GetHash().ToString().c_str() + "
"; if (wtx.IsCoinBase()) strHTML += QString("
") + 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.") + "
"; @@ -251,14 +240,15 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strHTML += "Credit: " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,wallet->GetCredit(txout)) + "
"; strHTML += "
Transaction:
"; - strHTML += HtmlEscape(wtx.ToString(), true); + strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true); CTxDB txdb("r"); // To fetch source txouts strHTML += "
Inputs:"; strHTML += "
    "; - CRITICAL_BLOCK(wallet->cs_wallet) + { + LOCK(wallet->cs_wallet); BOOST_FOREACH(const CTxIn& txin, wtx.vin) { COutPoint prevout = txin.prevout; @@ -271,10 +261,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strHTML += "
  • "; 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);