Changeset View
Changeset View
Standalone View
Standalone View
src/qt/transactiondesc.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, | ||||
LOCK2(cs_main, wallet->cs_wallet); | LOCK2(cs_main, wallet->cs_wallet); | ||||
strHTML.reserve(4000); | strHTML.reserve(4000); | ||||
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>"; | strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>"; | ||||
int64_t nTime = wtx.GetTxTime(); | int64_t nTime = wtx.GetTxTime(); | ||||
Amount nCredit = wtx.GetCredit(ISMINE_ALL); | Amount nCredit = wtx.GetCredit(ISMINE_ALL); | ||||
Amount nDebit = wtx.GetDebit(ISMINE_ALL); | Amount nDebit = wtx.GetDebit(ISMINE_ALL); | ||||
CAmount nNet = (nCredit - nDebit).GetSatoshis(); | Amount nNet = nCredit - nDebit; | ||||
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx); | strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx); | ||||
int nRequests = wtx.GetRequestCount(); | int nRequests = wtx.GetRequestCount(); | ||||
if (nRequests != -1) { | if (nRequests != -1) { | ||||
if (nRequests == 0) | if (nRequests == 0) | ||||
strHTML += tr(", has not been successfully broadcast yet"); | strHTML += tr(", has not been successfully broadcast yet"); | ||||
else if (nRequests > 0) | else if (nRequests > 0) | ||||
strHTML += tr(", broadcast through %n node(s)", "", nRequests); | strHTML += tr(", broadcast through %n node(s)", "", nRequests); | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | if (wtx.IsCoinBase() && nCredit == Amount(0)) { | ||||
// Coinbase | // Coinbase | ||||
// | // | ||||
Amount nUnmatured(0); | Amount nUnmatured(0); | ||||
for (const CTxOut &txout : wtx.tx->vout) { | for (const CTxOut &txout : wtx.tx->vout) { | ||||
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL); | nUnmatured += wallet->GetCredit(txout, ISMINE_ALL); | ||||
} | } | ||||
strHTML += "<b>" + tr("Credit") + ":</b> "; | strHTML += "<b>" + tr("Credit") + ":</b> "; | ||||
if (wtx.IsInMainChain()) | if (wtx.IsInMainChain()) | ||||
strHTML += BitcoinUnits::formatHtmlWithUnit( | strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured) + | ||||
unit, nUnmatured.GetSatoshis()) + | |||||
" (" + tr("matures in %n more block(s)", "", | " (" + tr("matures in %n more block(s)", "", | ||||
wtx.GetBlocksToMaturity()) + | wtx.GetBlocksToMaturity()) + | ||||
")"; | ")"; | ||||
else | else | ||||
strHTML += "(" + tr("not accepted") + ")"; | strHTML += "(" + tr("not accepted") + ")"; | ||||
strHTML += "<br>"; | strHTML += "<br>"; | ||||
} else if (nNet > 0) { | } else if (nNet > 0) { | ||||
// | // | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (wtx.IsCoinBase() && nCredit == Amount(0)) { | ||||
if (toSelf == ISMINE_SPENDABLE) | if (toSelf == ISMINE_SPENDABLE) | ||||
strHTML += " (own address)"; | strHTML += " (own address)"; | ||||
else if (toSelf & ISMINE_WATCH_ONLY) | else if (toSelf & ISMINE_WATCH_ONLY) | ||||
strHTML += " (watch-only)"; | strHTML += " (watch-only)"; | ||||
strHTML += "<br>"; | strHTML += "<br>"; | ||||
} | } | ||||
} | } | ||||
strHTML += "<b>" + tr("Debit") + ":</b> " + | strHTML += | ||||
BitcoinUnits::formatHtmlWithUnit( | "<b>" + tr("Debit") + ":</b> " + | ||||
unit, -txout.nValue.GetSatoshis()) + | BitcoinUnits::formatHtmlWithUnit(unit, -1 * txout.nValue) + | ||||
"<br>"; | "<br>"; | ||||
if (toSelf) | if (toSelf) | ||||
strHTML += "<b>" + tr("Credit") + ":</b> " + | strHTML += | ||||
BitcoinUnits::formatHtmlWithUnit( | "<b>" + tr("Credit") + ":</b> " + | ||||
unit, txout.nValue.GetSatoshis()) + | BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) + | ||||
"<br>"; | "<br>"; | ||||
} | } | ||||
if (fAllToMe) { | if (fAllToMe) { | ||||
// Payment to self | // Payment to self | ||||
Amount nChange = wtx.GetChange(); | Amount nChange = wtx.GetChange(); | ||||
Amount nValue = nCredit - nChange; | Amount nValue = nCredit - nChange; | ||||
strHTML += "<b>" + tr("Total debit") + ":</b> " + | strHTML += "<b>" + tr("Total debit") + ":</b> " + | ||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit(unit, -1 * nValue) + | ||||
unit, -nValue.GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
strHTML += "<b>" + tr("Total credit") + ":</b> " + | strHTML += "<b>" + tr("Total credit") + ":</b> " + | ||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit(unit, nValue) + | ||||
unit, nValue.GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
} | } | ||||
Amount nTxFee = nDebit - wtx.tx->GetValueOut(); | Amount nTxFee = nDebit - wtx.tx->GetValueOut(); | ||||
if (nTxFee > Amount(0)) | if (nTxFee > Amount(0)) | ||||
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + | strHTML += "<b>" + tr("Transaction fee") + ":</b> " + | ||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit(unit, -1 * nTxFee) + | ||||
unit, -nTxFee.GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
} else { | } else { | ||||
// | // | ||||
// Mixed debit transaction | // Mixed debit transaction | ||||
// | // | ||||
for (const CTxIn &txin : wtx.tx->vin) { | for (const CTxIn &txin : wtx.tx->vin) { | ||||
if (wallet->IsMine(txin)) | if (wallet->IsMine(txin)) | ||||
strHTML += | strHTML += | ||||
"<b>" + tr("Debit") + ":</b> " + | "<b>" + tr("Debit") + ":</b> " + | ||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit( | ||||
unit, | unit, -1 * wallet->GetDebit(txin, ISMINE_ALL)) + | ||||
-wallet->GetDebit(txin, ISMINE_ALL).GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
} | } | ||||
for (const CTxOut &txout : wtx.tx->vout) { | for (const CTxOut &txout : wtx.tx->vout) { | ||||
if (wallet->IsMine(txout)) | if (wallet->IsMine(txout)) | ||||
strHTML += "<b>" + tr("Credit") + ":</b> " + | strHTML += "<b>" + tr("Credit") + ":</b> " + | ||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit( | ||||
unit, wallet->GetCredit(txout, ISMINE_ALL) | unit, wallet->GetCredit(txout, ISMINE_ALL)) + | ||||
.GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
strHTML += "<b>" + tr("Net amount") + ":</b> " + | strHTML += "<b>" + tr("Net amount") + ":</b> " + | ||||
BitcoinUnits::formatHtmlWithUnit(unit, nNet, true) + "<br>"; | BitcoinUnits::formatHtmlWithUnit(unit, nNet, true) + "<br>"; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, | ||||
// | // | ||||
// Debug view | // Debug view | ||||
// | // | ||||
if (fDebug) { | if (fDebug) { | ||||
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>"; | strHTML += "<hr><br>" + tr("Debug information") + "<br><br>"; | ||||
for (const CTxIn &txin : wtx.tx->vin) { | for (const CTxIn &txin : wtx.tx->vin) { | ||||
if (wallet->IsMine(txin)) | if (wallet->IsMine(txin)) | ||||
strHTML += | strHTML += "<b>" + tr("Debit") + ":</b> " + | ||||
"<b>" + tr("Debit") + ":</b> " + | |||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit( | ||||
unit, | unit, -1 * wallet->GetDebit(txin, ISMINE_ALL)) + | ||||
-wallet->GetDebit(txin, ISMINE_ALL).GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
} | } | ||||
for (const CTxOut &txout : wtx.tx->vout) { | for (const CTxOut &txout : wtx.tx->vout) { | ||||
if (wallet->IsMine(txout)) | if (wallet->IsMine(txout)) | ||||
strHTML += | strHTML += "<b>" + tr("Credit") + ":</b> " + | ||||
"<b>" + tr("Credit") + ":</b> " + | |||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit( | ||||
unit, | unit, wallet->GetCredit(txout, ISMINE_ALL)) + | ||||
wallet->GetCredit(txout, ISMINE_ALL).GetSatoshis()) + | |||||
"<br>"; | "<br>"; | ||||
} | } | ||||
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>"; | strHTML += "<br><b>" + tr("Transaction") + ":</b><br>"; | ||||
strHTML += GUIUtil::HtmlEscape(wtx.tx->ToString(), true); | strHTML += GUIUtil::HtmlEscape(wtx.tx->ToString(), true); | ||||
strHTML += "<br><b>" + tr("Inputs") + ":</b>"; | strHTML += "<br><b>" + tr("Inputs") + ":</b>"; | ||||
strHTML += "<ul>"; | strHTML += "<ul>"; | ||||
Show All 11 Lines | if (fDebug) { | ||||
strHTML += GUIUtil::HtmlEscape( | strHTML += GUIUtil::HtmlEscape( | ||||
wallet->mapAddressBook[address].name) + | wallet->mapAddressBook[address].name) + | ||||
" "; | " "; | ||||
} | } | ||||
strHTML += | strHTML += | ||||
QString::fromStdString(EncodeDestination(address)); | QString::fromStdString(EncodeDestination(address)); | ||||
} | } | ||||
strHTML = strHTML + " " + tr("Amount") + "=" + | strHTML = strHTML + " " + tr("Amount") + "=" + | ||||
BitcoinUnits::formatHtmlWithUnit( | BitcoinUnits::formatHtmlWithUnit(unit, vout.nValue); | ||||
unit, vout.nValue.GetSatoshis()); | |||||
strHTML = | strHTML = | ||||
strHTML + " IsMine=" + | strHTML + " IsMine=" + | ||||
(wallet->IsMine(vout) & ISMINE_SPENDABLE ? tr("true") | (wallet->IsMine(vout) & ISMINE_SPENDABLE ? tr("true") | ||||
: tr("false")) + | : tr("false")) + | ||||
"</li>"; | "</li>"; | ||||
strHTML = | strHTML = | ||||
strHTML + " IsWatchOnly=" + | strHTML + " IsWatchOnly=" + | ||||
(wallet->IsMine(vout) & ISMINE_WATCH_ONLY ? tr("true") | (wallet->IsMine(vout) & ISMINE_WATCH_ONLY ? tr("true") | ||||
Show All 11 Lines |