removed default argument values for ismine filter

pull/4045/head
JaSK 11 years ago
parent d5087d1ba0
commit 80dda36a07

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

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

@ -557,7 +557,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
} }
int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth, const isminefilter& filter = MINE_SPENDABLE) int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth, const isminefilter& filter)
{ {
int64_t nBalance = 0; int64_t nBalance = 0;
@ -582,7 +582,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
return nBalance; return nBalance;
} }
int64_t GetAccountBalance(const string& strAccount, int nMinDepth, const isminefilter& filter = MINE_SPENDABLE) int64_t GetAccountBalance(const string& strAccount, int nMinDepth, const isminefilter& filter)
{ {
CWalletDB walletdb(pwalletMain->strWalletFile); CWalletDB walletdb(pwalletMain->strWalletFile);
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter); return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
@ -786,7 +786,7 @@ Value sendfrom(const Array& params, bool fHelp)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
// Check funds // Check funds
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
if (nAmount > nBalance) if (nAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
@ -863,7 +863,7 @@ Value sendmany(const Array& params, bool fHelp)
EnsureWalletIsUnlocked(); EnsureWalletIsUnlocked();
// Check funds // Check funds
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
if (totalAmount > nBalance) if (totalAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
@ -1129,7 +1129,7 @@ static void MaybePushAddress(Object & entry, const CTxDestination &dest)
entry.push_back(Pair("address", addr.ToString())); entry.push_back(Pair("address", addr.ToString()));
} }
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret, const isminefilter& filter=MINE_SPENDABLE) void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret, const isminefilter& filter)
{ {
int64_t nFee; int64_t nFee;
string strSentAccount; string strSentAccount;
@ -1552,13 +1552,13 @@ Value gettransaction(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
const CWalletTx& wtx = pwalletMain->mapWallet[hash]; const CWalletTx& wtx = pwalletMain->mapWallet[hash];
int64_t nCredit = wtx.GetCredit(); int64_t nCredit = wtx.GetCredit(filter);
int64_t nDebit = wtx.GetDebit(); int64_t nDebit = wtx.GetDebit(filter);
int64_t nNet = nCredit - nDebit; int64_t nNet = nCredit - nDebit;
int64_t nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0); int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe()) if (wtx.IsFromMe(filter))
entry.push_back(Pair("fee", ValueFromAmount(nFee))); entry.push_back(Pair("fee", ValueFromAmount(nFee)));
WalletTxToJSON(wtx, entry); WalletTxToJSON(wtx, entry);

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

@ -288,12 +288,12 @@ public:
std::set<CTxDestination> GetAccountAddresses(std::string strAccount) const; std::set<CTxDestination> GetAccountAddresses(std::string strAccount) const;
isminetype IsMine(const CTxIn& txin) const; isminetype IsMine(const CTxIn& txin) const;
int64_t GetDebit(const CTxIn& txin, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const; int64_t GetDebit(const CTxIn& txin, const isminefilter& filter) const;
isminetype IsMine(const CTxOut& txout) const isminetype IsMine(const CTxOut& txout) const
{ {
return ::IsMine(*this, txout.scriptPubKey); return ::IsMine(*this, txout.scriptPubKey);
} }
int64_t GetCredit(const CTxOut& txout, const isminefilter& filter=(MINE_WATCH_ONLY|MINE_SPENDABLE)) const int64_t GetCredit(const CTxOut& txout, const isminefilter& filter) const
{ {
if (!MoneyRange(txout.nValue)) if (!MoneyRange(txout.nValue))
throw std::runtime_error("CWallet::GetCredit() : value out of range"); throw std::runtime_error("CWallet::GetCredit() : value out of range");
@ -313,9 +313,9 @@ public:
return true; return true;
return false; return false;
} }
bool IsFromMe(const CTransaction& tx) const bool IsFromMe(const CTransaction& tx) const // should probably be renamed to IsRelevantToMe
{ {
return (GetDebit(tx) > 0); return (GetDebit(tx, MINE_SPENDABLE|MINE_WATCH_ONLY) > 0);
} }
bool IsConflicting(const CTransaction& tx) const bool IsConflicting(const CTransaction& tx) const
{ {
@ -324,7 +324,7 @@ public:
return true; return true;
return false; return false;
} }
int64_t GetDebit(const CTransaction& tx, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const int64_t GetDebit(const CTransaction& tx, const isminefilter& filter) const
{ {
int64_t nDebit = 0; int64_t nDebit = 0;
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
@ -335,7 +335,7 @@ public:
} }
return nDebit; return nDebit;
} }
int64_t GetCredit(const CTransaction& tx, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const int64_t GetCredit(const CTransaction& tx, const isminefilter& filter) const
{ {
int64_t nCredit = 0; int64_t nCredit = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout) BOOST_FOREACH(const CTxOut& txout, tx.vout)
@ -614,7 +614,8 @@ public:
MarkDirty(); MarkDirty();
} }
int64_t GetDebit(const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const // filter decides which addresses will count towards the debit
int64_t GetDebit(const isminefilter& filter) const
{ {
if (vin.empty()) if (vin.empty())
return 0; return 0;
@ -654,7 +655,7 @@ public:
// GetBalance can assume transactions in mapWallet won't change // GetBalance can assume transactions in mapWallet won't change
if (fUseCache && fCreditCached) if (fUseCache && fCreditCached)
return nCreditCached; return nCreditCached;
nCreditCached = pwallet->GetCredit(*this); nCreditCached = pwallet->GetCredit(*this, MINE_SPENDABLE|MINE_WATCH_ONLY);
fCreditCached = true; fCreditCached = true;
return nCreditCached; return nCreditCached;
} }
@ -756,12 +757,12 @@ public:
} }
void GetAmounts(std::list<std::pair<CTxDestination, int64_t> >& listReceived, void GetAmounts(std::list<std::pair<CTxDestination, int64_t> >& listReceived,
std::list<std::pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, std::string& strSentAccount, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const; std::list<std::pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, std::string& strSentAccount, const isminefilter& filter) const;
void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived, void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived,
int64_t& nSent, int64_t& nFee, const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const; int64_t& nSent, int64_t& nFee, const isminefilter& filter) const;
bool IsFromMe(const isminefilter& filter=(MINE_SPENDABLE|MINE_WATCH_ONLY)) const bool IsFromMe(const isminefilter& filter) const
{ {
return (GetDebit(filter) > 0); return (GetDebit(filter) > 0);
} }
@ -776,7 +777,7 @@ public:
return true; return true;
if (nDepth < 0) if (nDepth < 0)
return false; return false;
if (!bSpendZeroConfChange || !IsFromMe()) // using wtx's cached debit if (!bSpendZeroConfChange || !IsFromMe(MINE_SPENDABLE|MINE_WATCH_ONLY)) // using wtx's cached debit
return false; return false;
// Trusted if all inputs are from us and are in the mempool: // Trusted if all inputs are from us and are in the mempool:

Loading…
Cancel
Save