Skip to content

Commit

Permalink
Added MINE_ALL = (spendable|watchonly)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkfjlsfjlskdfjlsdjflsjf committed Jul 2, 2014
1 parent 23b0506 commit 519dd1c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()) + ")";
Expand Down Expand Up @@ -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>";
}
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++)
Expand Down
6 changes: 3 additions & 3 deletions src/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class CWallet : public CCryptoKeyStore, public CWalletInterface
}
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
{
Expand Down Expand Up @@ -655,7 +655,7 @@ class CWalletTx : public CMerkleTx
// 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;
}
Expand Down Expand Up @@ -777,7 +777,7 @@ class CWalletTx : public CMerkleTx
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:
Expand Down

0 comments on commit 519dd1c

Please sign in to comment.