Skip to content

Commit

Permalink
Added MINE_ALL = (spendable|watchonly)
Browse files Browse the repository at this point in the history
Rebased-from: 519dd1c bitcoin#4045
  • Loading branch information
sdkfjlsfjlskdfjlsdjflsjf authored and wtogami committed Sep 19, 2014
1 parent 0dcb3bb commit 43491b2
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 @@ -52,8 +52,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 @@ -130,7 +130,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 @@ -219,10 +219,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 @@ -272,10 +272,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 @@ -32,7 +32,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 @@ -198,6 +198,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 @@ -1187,7 +1187,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 @@ -1837,7 +1837,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 @@ -312,7 +312,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);
}
int64_t GetDebit(const CTransaction& tx, const isminefilter& filter) const
{
Expand Down Expand Up @@ -645,7 +645,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 @@ -767,7 +767,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 43491b2

Please sign in to comment.