Skip to content

Commit

Permalink
fixed tiny glitch and improved readability like laanwj suggested
Browse files Browse the repository at this point in the history
Rebased-from: a5c6c5d bitcoin#4045
  • Loading branch information
sdkfjlsfjlskdfjlsdjflsjf authored and wtogami committed Dec 23, 2014
1 parent c07f488 commit c3f005f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 49 deletions.
6 changes: 3 additions & 3 deletions src/qt/transactiondesc.cpp
Expand Up @@ -98,11 +98,11 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
strHTML += "<b>" + tr("To") + ":</b> ";
strHTML += GUIUtil::HtmlEscape(rec->address);
std::string addressOwned = wallet->IsMine(txout) == MINE_SPENDABLE ? "own address" : "watch-only";
QString addressOwned = wallet->IsMine(txout) == MINE_SPENDABLE ? tr("own address") : tr("watch-only");
if (!wallet->mapAddressBook[address].name.empty())
strHTML += " (" + tr(addressOwned.c_str()) + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";
strHTML += " (" + addressOwned + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";
else
strHTML += " (" + tr(addressOwned.c_str()) + ")";
strHTML += " (" + addressOwned + ")";
strHTML += "<br>";
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/rpcmisc.cpp
Expand Up @@ -170,9 +170,9 @@ Value validateaddress(const Array& params, bool fHelp)
ret.push_back(Pair("address", currentAddress));
#ifdef ENABLE_WALLET
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : MINE_NO;
ret.push_back(Pair("ismine", mine == MINE_SPENDABLE));
ret.push_back(Pair("ismine", (mine & MINE_SPENDABLE) ? true : false));
if (mine != MINE_NO) {
ret.push_back(Pair("watchonly", mine == MINE_WATCH_ONLY));
ret.push_back(Pair("iswatchonly", (mine & MINE_WATCH_ONLY) ? true: false));
Object detail = boost::apply_visitor(DescribeAddressVisitor(mine), dest);
ret.insert(ret.end(), detail.begin(), detail.end());
}
Expand Down
70 changes: 29 additions & 41 deletions src/rpcwallet.cpp
Expand Up @@ -616,14 +616,12 @@ Value getbalance(const Array& params, bool fHelp)
return ValueFromAmount(pwalletMain->GetBalance());

int nMinDepth = 1;
isminefilter filter = MINE_SPENDABLE;
if (params.size() > 1)
{
nMinDepth = params[1].get_int();
if(params.size() > 2)
if(params[2].get_bool())
filter = filter | MINE_WATCH_ONLY;
}
isminefilter filter = MINE_SPENDABLE;
if(params.size() > 2)
if(params[2].get_bool())
filter = filter | MINE_WATCH_ONLY;

if (params[0].get_str() == "*") {
// Calculate total balance a different way from GetBalance()
Expand Down Expand Up @@ -1244,26 +1242,19 @@ Value listtransactions(const Array& params, bool fHelp)
);

string strAccount = "*";
if (params.size() > 0)
strAccount = params[0].get_str();
int nCount = 10;
if (params.size() > 1)
nCount = params[1].get_int();
int nFrom = 0;
if (params.size() > 2)
nFrom = params[2].get_int();
isminefilter filter = MINE_SPENDABLE;
if (params.size() > 0)
{
strAccount = params[0].get_str();
if (params.size() > 1)
{
nCount = params[1].get_int();
if (params.size() > 2)
{
nFrom = params[2].get_int();
if(params.size() > 3)
{
if(params[3].get_bool())
filter = filter | MINE_WATCH_ONLY;
}
}
}
}
if(params.size() > 3)
if(params[3].get_bool())
filter = filter | MINE_WATCH_ONLY;

if (nCount < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
if (nFrom < 0)
Expand Down Expand Up @@ -1331,14 +1322,12 @@ Value listaccounts(const Array& params, bool fHelp)
);

int nMinDepth = 1;
isminefilter includeWatchonly = MINE_SPENDABLE;
if (params.size() > 0)
{
nMinDepth = params[0].get_int();
if(params.size() > 1)
if(params[1].get_bool())
includeWatchonly = includeWatchonly | MINE_WATCH_ONLY;
}
isminefilter includeWatchonly = MINE_SPENDABLE;
if(params.size() > 1)
if(params[1].get_bool())
includeWatchonly = includeWatchonly | MINE_WATCH_ONLY;

map<string, int64_t> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) {
Expand Down Expand Up @@ -1422,6 +1411,7 @@ Value listsinceblock(const Array& params, bool fHelp)
CBlockIndex *pindex = NULL;
int target_confirms = 1;
isminefilter filter = MINE_SPENDABLE;

if (params.size() > 0)
{
uint256 blockId = 0;
Expand All @@ -1430,22 +1420,20 @@ Value listsinceblock(const Array& params, bool fHelp)
std::map<uint256, CBlockIndex*>::iterator it = mapBlockIndex.find(blockId);
if (it != mapBlockIndex.end())
pindex = it->second;
}

if (params.size() > 1)
{
target_confirms = params[1].get_int();

if (target_confirms < 1)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
if (params.size() > 1)
{
target_confirms = params[1].get_int();

if(params.size() > 2)
{
if(params[2].get_bool())
filter = filter | MINE_WATCH_ONLY;
}
}
if (target_confirms < 1)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter");
}

if(params.size() > 2)
if(params[2].get_bool())
filter = filter | MINE_WATCH_ONLY;

int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1;

Array transactions;
Expand Down
6 changes: 3 additions & 3 deletions src/wallet.cpp
Expand Up @@ -781,7 +781,8 @@ void CWalletTx::GetAmounts(list<pair<CTxDestination, int64_t> >& listReceived,
// Sent/received.
BOOST_FOREACH(const CTxOut& txout, vout)
{
bool fIsMine;
isminetype fIsMine = pwallet->IsMine(txout);

// Only need to handle txouts if AT LEAST one of these is true:
// 1) they debit from us (sent)
// 2) the output is to us (received)
Expand All @@ -790,9 +791,8 @@ void CWalletTx::GetAmounts(list<pair<CTxDestination, int64_t> >& listReceived,
// Don't report 'change' txouts
if (pwallet->IsChange(txout))
continue;
fIsMine = (pwallet->IsMine(txout) & filter);
}
else if (!(fIsMine = (pwallet->IsMine(txout) & filter)))
else if (!(fIsMine & filter))
continue;

// In either case, we need to get the destination address
Expand Down

0 comments on commit c3f005f

Please sign in to comment.