removed default argument values for ismine filter
This commit is contained in:
parent
d5087d1ba0
commit
80dda36a07
5 changed files with 32 additions and 31 deletions
|
@ -54,8 +54,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();
|
||||
int64_t nDebit = wtx.GetDebit();
|
||||
int64_t nCredit = wtx.GetCredit(MINE_SPENDABLE|MINE_WATCH_ONLY);
|
||||
int64_t nDebit = wtx.GetDebit(MINE_SPENDABLE|MINE_WATCH_ONLY);
|
||||
int64_t nNet = nCredit - nDebit;
|
||||
|
||||
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
|
||||
|
@ -139,7 +139,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
|||
//
|
||||
int64_t nUnmatured = 0;
|
||||
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> ";
|
||||
if (wtx.IsInMainChain())
|
||||
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)
|
||||
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)
|
||||
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>";
|
||||
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
|
||||
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)
|
||||
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 += GUIUtil::HtmlEscape(wtx.ToString(), true);
|
||||
|
|
|
@ -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();
|
||||
int64_t nDebit = wtx.GetDebit(MINE_SPENDABLE|MINE_WATCH_ONLY);
|
||||
int64_t nNet = nCredit - nDebit;
|
||||
uint256 hash = wtx.GetHash();
|
||||
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;
|
||||
|
||||
|
@ -582,7 +582,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
|
|||
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);
|
||||
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
||||
|
@ -786,7 +786,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
|||
EnsureWalletIsUnlocked();
|
||||
|
||||
// Check funds
|
||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
|
||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
|
||||
if (nAmount > nBalance)
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
|
||||
|
||||
|
@ -863,7 +863,7 @@ Value sendmany(const Array& params, bool fHelp)
|
|||
EnsureWalletIsUnlocked();
|
||||
|
||||
// Check funds
|
||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
|
||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
|
||||
if (totalAmount > nBalance)
|
||||
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()));
|
||||
}
|
||||
|
||||
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;
|
||||
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");
|
||||
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
|
||||
|
||||
int64_t nCredit = wtx.GetCredit();
|
||||
int64_t nDebit = wtx.GetDebit();
|
||||
int64_t nCredit = wtx.GetCredit(filter);
|
||||
int64_t nDebit = wtx.GetDebit(filter);
|
||||
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)));
|
||||
if (wtx.IsFromMe())
|
||||
if (wtx.IsFromMe(filter))
|
||||
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
|
||||
|
||||
WalletTxToJSON(wtx, entry);
|
||||
|
|
|
@ -1216,7 +1216,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
|
|||
|
||||
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;
|
||||
|
||||
int i = output.i;
|
||||
|
@ -1845,7 +1845,7 @@ std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
|
|||
continue;
|
||||
|
||||
int nDepth = pcoin->GetDepthInMainChain();
|
||||
if (nDepth < (pcoin->IsFromMe() ? 0 : 1))
|
||||
if (nDepth < (pcoin->IsFromMe(MINE_SPENDABLE|MINE_WATCH_ONLY) ? 0 : 1))
|
||||
continue;
|
||||
|
||||
for (unsigned int i = 0; i < pcoin->vout.size(); i++)
|
||||
|
|
25
src/wallet.h
25
src/wallet.h
|
@ -288,12 +288,12 @@ public:
|
|||
std::set<CTxDestination> GetAccountAddresses(std::string strAccount) 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
|
||||
{
|
||||
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))
|
||||
throw std::runtime_error("CWallet::GetCredit() : value out of range");
|
||||
|
@ -313,9 +313,9 @@ public:
|
|||
return true;
|
||||
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
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ public:
|
|||
return true;
|
||||
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;
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
|
@ -335,7 +335,7 @@ public:
|
|||
}
|
||||
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;
|
||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
||||
|
@ -614,7 +614,8 @@ public:
|
|||
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())
|
||||
return 0;
|
||||
|
@ -654,7 +655,7 @@ public:
|
|||
// GetBalance can assume transactions in mapWallet won't change
|
||||
if (fUseCache && fCreditCached)
|
||||
return nCreditCached;
|
||||
nCreditCached = pwallet->GetCredit(*this);
|
||||
nCreditCached = pwallet->GetCredit(*this, MINE_SPENDABLE|MINE_WATCH_ONLY);
|
||||
fCreditCached = true;
|
||||
return nCreditCached;
|
||||
}
|
||||
|
@ -756,12 +757,12 @@ public:
|
|||
}
|
||||
|
||||
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,
|
||||
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);
|
||||
}
|
||||
|
@ -776,7 +777,7 @@ public:
|
|||
return true;
|
||||
if (nDepth < 0)
|
||||
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;
|
||||
|
||||
// Trusted if all inputs are from us and are in the mempool:
|
||||
|
|
Loading…
Reference in a new issue