mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 19:53:27 +01:00
Watchonly balances are shown separately in gui.
This commit is contained in:
@@ -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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user