Skip to content

Commit

Permalink
Merge branch 'fix-creditstakestoaccounts'
Browse files Browse the repository at this point in the history
  • Loading branch information
dooglus committed Sep 29, 2015
2 parents 6723832 + 7c55bf2 commit fcdf335
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ Value listaccounts(const Array& params, bool fHelp)
string strSentAccount;
list<pair<CTxDestination, int64_t> > listReceived;
list<pair<CTxDestination, int64_t> > listSent;
CTxDestination td;

// don't count proof-of-work rewards in account balances
if (wtx.IsCoinBase())
Expand All @@ -1297,13 +1298,13 @@ Value listaccounts(const Array& params, bool fHelp)

// count staking reward in the appropriate account
if (wtx.IsCoinStake()) {
if (fCreditStakesToAccounts && listSent.size()) {
CTxDestination td(listSent.front().first);
if (pwalletMain->mapAddressBook.count(td))
mapAccountBalances[pwalletMain->mapAddressBook[td]] -= nFee;
else
mapAccountBalances[""] -= nFee;
} else
if (fCreditStakesToAccounts && // if we're crediting stakes to the account that owns the staking address,
wtx.vout.size() > 1 && // and we have a staking address
IsMine(*pwalletMain, wtx.vout[1].scriptPubKey) && // and we own it
ExtractDestination(wtx.vout[1].scriptPubKey, td) && // and we can figure out the address
pwalletMain->mapAddressBook.count(td) ) // and it's in our address book
mapAccountBalances[pwalletMain->mapAddressBook[td]] -= nFee; // then credit the reward to its account
else
mapAccountBalances[""] -= nFee;
continue;
}
Expand Down

0 comments on commit fcdf335

Please sign in to comment.