Added MINE_ALL = (spendable|watchonly)

This commit is contained in:
JaSK 2014-06-20 05:02:14 +02:00
parent 23b0506c91
commit 519dd1c89a
5 changed files with 14 additions and 13 deletions

View File

@ -55,8 +55,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
int64_t nTime = wtx.GetTxTime();
int64_t nCredit = wtx.GetCredit(MINE_SPENDABLE|MINE_WATCH_ONLY);
int64_t nDebit = wtx.GetDebit(MINE_SPENDABLE|MINE_WATCH_ONLY);
int64_t nCredit = wtx.GetCredit(MINE_ALL);
int64_t nDebit = wtx.GetDebit(MINE_ALL);
int64_t nNet = nCredit - nDebit;
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
@ -133,7 +133,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
int64_t nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout, MINE_SPENDABLE|MINE_WATCH_ONLY);
nUnmatured += wallet->GetCredit(txout, MINE_ALL);
strHTML += "<b>" + tr("Credit") + ":</b> ";
if (wtx.IsInMainChain())
strHTML += BitcoinUnits::formatWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
@ -222,10 +222,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if (wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin, MINE_SPENDABLE|MINE_WATCH_ONLY)) + "<br>";
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin, MINE_ALL)) + "<br>";
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if (wallet->IsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout, MINE_SPENDABLE|MINE_WATCH_ONLY)) + "<br>";
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout, MINE_ALL)) + "<br>";
}
}
@ -275,10 +275,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if(wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin, MINE_SPENDABLE|MINE_WATCH_ONLY)) + "<br>";
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, -wallet->GetDebit(txin, MINE_ALL)) + "<br>";
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if(wallet->IsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout, MINE_SPENDABLE|MINE_WATCH_ONLY)) + "<br>";
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(unit, wallet->GetCredit(txout, MINE_ALL)) + "<br>";
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);

View File

@ -33,7 +33,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
QList<TransactionRecord> parts;
int64_t nTime = wtx.GetTxTime();
int64_t nCredit = wtx.GetCredit(true);
int64_t nDebit = wtx.GetDebit(MINE_SPENDABLE|MINE_WATCH_ONLY);
int64_t nDebit = wtx.GetDebit(MINE_ALL);
int64_t nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;

View File

@ -200,6 +200,7 @@ enum isminetype
MINE_NO = 0,
MINE_WATCH_ONLY = 1,
MINE_SPENDABLE = 2,
MINE_ALL = MINE_WATCH_ONLY | MINE_SPENDABLE
};
/** used for bitflags of isminetype */
typedef uint8_t isminefilter;

View File

@ -1216,7 +1216,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
const CWalletTx *pcoin = output.tx;
if (output.nDepth < (pcoin->IsFromMe(MINE_SPENDABLE|MINE_WATCH_ONLY) ? nConfMine : nConfTheirs))
if (output.nDepth < (pcoin->IsFromMe(MINE_ALL) ? nConfMine : nConfTheirs))
continue;
int i = output.i;
@ -1845,7 +1845,7 @@ std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
continue;
int nDepth = pcoin->GetDepthInMainChain();
if (nDepth < (pcoin->IsFromMe(MINE_SPENDABLE|MINE_WATCH_ONLY) ? 0 : 1))
if (nDepth < (pcoin->IsFromMe(MINE_ALL) ? 0 : 1))
continue;
for (unsigned int i = 0; i < pcoin->vout.size(); i++)

View File

@ -315,7 +315,7 @@ public:
}
bool IsFromMe(const CTransaction& tx) const // should probably be renamed to IsRelevantToMe
{
return (GetDebit(tx, MINE_SPENDABLE|MINE_WATCH_ONLY) > 0);
return (GetDebit(tx, MINE_ALL) > 0);
}
bool IsConflicting(const CTransaction& tx) const
{
@ -655,7 +655,7 @@ public:
// GetBalance can assume transactions in mapWallet won't change
if (fUseCache && fCreditCached)
return nCreditCached;
nCreditCached = pwallet->GetCredit(*this, MINE_SPENDABLE|MINE_WATCH_ONLY);
nCreditCached = pwallet->GetCredit(*this, MINE_ALL);
fCreditCached = true;
return nCreditCached;
}
@ -777,7 +777,7 @@ public:
return true;
if (nDepth < 0)
return false;
if (!bSpendZeroConfChange || !IsFromMe(MINE_SPENDABLE|MINE_WATCH_ONLY)) // using wtx's cached debit
if (!bSpendZeroConfChange || !IsFromMe(MINE_ALL)) // using wtx's cached debit
return false;
// Trusted if all inputs are from us and are in the mempool: