aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactiondesc.cpp
diff options
context:
space:
mode:
authorJaSK <temp@temp.temp>2014-03-29 05:15:28 +0100
committerJaSK <temp@temp.temp>2014-07-02 15:48:38 +0200
commitffd40da361639faeef405c7e4a504a340d77aa5b (patch)
tree66131441451335db0f91a7d19cfddb9665aa82f1 /src/qt/transactiondesc.cpp
parent2935b211033610d7ef0deef9bf1b344a5bac029f (diff)
downloadbitcoin-ffd40da361639faeef405c7e4a504a340d77aa5b.tar.xz
Watchonly balances are shown separately in gui.
Diffstat (limited to 'src/qt/transactiondesc.cpp')
-rw-r--r--src/qt/transactiondesc.cpp64
1 files changed, 45 insertions, 19 deletions
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index e48dbcac9d..76dc47318d 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -89,19 +89,27 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (nNet > 0)
{
// Credit
- if (CBitcoinAddress(rec->address).IsValid())
+ BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
- CTxDestination address = CBitcoinAddress(rec->address).Get();
- if (wallet->mapAddressBook.count(address))
+ if (wallet->IsMine(txout))
{
- strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
- strHTML += "<b>" + tr("To") + ":</b> ";
- strHTML += GUIUtil::HtmlEscape(rec->address);
- if (!wallet->mapAddressBook[address].name.empty())
- strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";
- else
- strHTML += " (" + tr("own address") + ")";
- strHTML += "<br>";
+ if (CBitcoinAddress(rec->address).IsValid())
+ {
+ CTxDestination address = CBitcoinAddress(rec->address).Get();
+ if (wallet->mapAddressBook.count(address))
+ {
+ strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
+ strHTML += "<b>" + tr("To") + ":</b> ";
+ strHTML += GUIUtil::HtmlEscape(rec->address);
+ std::string addressOwned = wallet->IsMine(txout) == MINE_SPENDABLE ? "own address" : "watch-only";
+ if (!wallet->mapAddressBook[address].name.empty())
+ strHTML += " (" + tr(addressOwned.c_str()) + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";
+ else
+ strHTML += " (" + tr(addressOwned.c_str()) + ")";
+ strHTML += "<br>";
+ }
+ }
+ break;
}
}
}
@@ -148,22 +156,33 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
}
else
{
- bool fAllFromMe = true;
+ isminetype fAllFromMe = MINE_SPENDABLE;
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
- fAllFromMe = fAllFromMe && wallet->IsMine(txin);
+ {
+ isminetype mine = wallet->IsMine(txin);
+ if(fAllFromMe > mine) fAllFromMe = mine;
+ }
- bool fAllToMe = true;
+ isminetype fAllToMe = MINE_SPENDABLE;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- fAllToMe = fAllToMe && wallet->IsMine(txout);
+ {
+ isminetype mine = wallet->IsMine(txout);
+ if(fAllToMe > mine) fAllToMe = mine;
+ }
if (fAllFromMe)
{
+ if(fAllFromMe == MINE_WATCH_ONLY)
+ strHTML += "<b>" + tr("From") + ":</b> " + tr("watch-only") + "<br>";
+
//
// Debit
//
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
- if (wallet->IsMine(txout))
+ // Ignore change
+ isminetype toSelf = wallet->IsMine(txout);
+ if ((toSelf == MINE_SPENDABLE) && (fAllFromMe == MINE_SPENDABLE))
continue;
if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty())
@@ -176,11 +195,17 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].name.empty())
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + " ";
strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());
+ if(toSelf == MINE_SPENDABLE)
+ strHTML += " (own address)";
+ else if(toSelf == MINE_WATCH_ONLY)
+ strHTML += " (watch-only)";
strHTML += "<br>";
}
}
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -txout.nValue) + "<br>";
+ if(toSelf)
+ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, txout.nValue) + "<br>";
}
if (fAllToMe)
@@ -188,8 +213,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
// Payment to self
int64_t nChange = wtx.GetChange();
int64_t nValue = nCredit - nChange;
- strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -nValue) + "<br>";
- strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nValue) + "<br>";
+ strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -nValue) + "<br>";
+ strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, nValue) + "<br>";
}
int64_t nTxFee = nDebit - wtx.GetValueOut();
@@ -286,7 +311,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += QString::fromStdString(CBitcoinAddress(address).ToString());
}
strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatWithUnit(unit, vout.nValue);
- strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) ? tr("true") : tr("false")) + "</li>";
+ strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) & MINE_SPENDABLE ? tr("true") : tr("false")) + "</li>";
+ strHTML = strHTML + " IsWatchOnly=" + (wallet->IsMine(vout) & MINE_WATCH_ONLY ? tr("true") : tr("false")) + "</li>";
}
}
}