src/wallet/rpcwallet.cpp
void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
{
    CAmount nFee;
    std::string strSentAccount;
    std::list<COutputEntry> listReceived;
    std::list<COutputEntry> listSent;

    wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter);

    bool fAllAccounts = (strAccount == std::string("*"));
    bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);

    // Sent
    if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
    {
        for (const COutputEntry& s : listSent)
        {
            UniValue entry(UniValue::VOBJ);
            if (involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) {
                entry.pushKV("involvesWatchonly", true);
            }
            entry.pushKV("account", strSentAccount);
            MaybePushAddress(entry, s.destination);
            entry.pushKV("category", "send");
            entry.pushKV("amount", ValueFromAmount(-s.amount));
            if (pwallet->mapAddressBook.count(s.destination)) {
                entry.pushKV("label", pwallet->mapAddressBook[s.destination].name);
            }
            entry.pushKV("vout", s.vout);
            entry.pushKV("fee", ValueFromAmount(-nFee));
            if (fLong)
                WalletTxToJSON(wtx, entry);
            entry.pushKV("abandoned", wtx.isAbandoned());
            ret.push_back(entry);
        }
    }

    // Received
    if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
    {
        for (const COutputEntry& r : listReceived)
        {
            std::string account;
            if (pwallet->mapAddressBook.count(r.destination)) {
                account = pwallet->mapAddressBook[r.destination].name;
            }
            if (fAllAccounts || (account == strAccount))
            {
                UniValue entry(UniValue::VOBJ);
                if (involvesWatchonly || (::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) {
                    entry.pushKV("involvesWatchonly", true);
                }
                entry.pushKV("account", account);
                MaybePushAddress(entry, r.destination);
                if (wtx.IsCoinBase())
                {
                    if (wtx.GetDepthInMainChain() < 1)
                        entry.pushKV("category", "orphan");
                    else if (wtx.GetBlocksToMaturity() > 0)
                        entry.pushKV("category", "immature");
                    else
                        entry.pushKV("category", "generate");
                }
                else
                {
                    entry.pushKV("category", "receive");
                }
                entry.pushKV("amount", ValueFromAmount(r.amount));
                if (pwallet->mapAddressBook.count(r.destination)) {
                    entry.pushKV("label", account);
                }
                entry.pushKV("vout", r.vout);
                if (fLong)
                    WalletTxToJSON(wtx, entry);
                ret.push_back(entry);
            }
        }
    }
}
/**
 * List transactions based on the given criteria.
 *
 * @param  pwallet    The wallet.
 * @param  wtx        The wallet transaction.
 * @param  strAccount The account, if any, or "*" for all.
 * @param  nMinDepth  The minimum confirmation depth.
 * @param  fLong      Whether to include the JSON version of the transaction.
 * @param  ret        The UniValue into which the result is stored.
 * @param  filter     The "is mine" filter bool.
 */
List transactions based on the given criteria.
@param  pwallet    The wallet.
@param  wtx        The wallet transaction.
@param  strAccount The account, if any, or "*" for all.
@param  nMinDepth  The minimum confirmation depth.
@param  fLong      Whether to include the JSON version of the transaction.
@param  ret        The UniValue into which the result is stored.
@param  filter     The "is mine" filter bool.
List transactions based on the given criteria . @param pwallet The wallet . @param wtx The wallet transaction . @param strAccount The account if any or " * " for all . @param nMinDepth The minimum confirmation depth . @param fLong Whether to include the JSON version of the transaction . @param ret The UniValue into which the result is stored . @param filter The " is mine " filter bool .
void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
{
    CAmount nFee;
    std::string strSentAccount;
    std::list<COutputEntry> listReceived;
    std::list<COutputEntry> listSent;
    wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter);
    bool fAllAccounts = (strAccount == std::string("*"));
    bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);
    if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
    {
        for (const COutputEntry& s : listSent)
        {
            UniValue entry(UniValue::VOBJ);
            if (involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) {
                entry.pushKV("involvesWatchonly", true);
            }
            entry.pushKV("account", strSentAccount);
            MaybePushAddress(entry, s.destination);
            entry.pushKV("category", "send");
            entry.pushKV("amount", ValueFromAmount(-s.amount));
            if (pwallet->mapAddressBook.count(s.destination)) {
                entry.pushKV("label", pwallet->mapAddressBook[s.destination].name);
            }
            entry.pushKV("vout", s.vout);
            entry.pushKV("fee", ValueFromAmount(-nFee));
            if (fLong)
                WalletTxToJSON(wtx, entry);
            entry.pushKV("abandoned", wtx.isAbandoned());
            ret.push_back(entry);
        }
    }
    if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
    {
        for (const COutputEntry& r : listReceived)
        {
            std::string account;
            if (pwallet->mapAddressBook.count(r.destination)) {
                account = pwallet->mapAddressBook[r.destination].name;
            }
            if (fAllAccounts || (account == strAccount))
            {
                UniValue entry(UniValue::VOBJ);
                if (involvesWatchonly || (::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) {
                    entry.pushKV("involvesWatchonly", true);
                }
                entry.pushKV("account", account);
                MaybePushAddress(entry, r.destination);
                if (wtx.IsCoinBase())
                {
                    if (wtx.GetDepthInMainChain() < 1)
                        entry.pushKV("category", "orphan");
                    else if (wtx.GetBlocksToMaturity() > 0)
                        entry.pushKV("category", "immature");
                    else
                        entry.pushKV("category", "generate");
                }
                else
                {
                    entry.pushKV("category", "receive");
                }
                entry.pushKV("amount", ValueFromAmount(r.amount));
                if (pwallet->mapAddressBook.count(r.destination)) {
                    entry.pushKV("label", account);
                }
                entry.pushKV("vout", r.vout);
                if (fLong)
                    WalletTxToJSON(wtx, entry);
                ret.push_back(entry);
            }
        }
    }
}
void ListTransactions ( CWallet * const pwallet , const CWalletTx & wtx , const std :: string & strAccount , int nMinDepth , bool fLong , UniValue & ret , const isminefilter & filter ) { CAmount nFee ; std :: string strSentAccount ; std :: list < COutputEntry > listReceived ; std :: list < COutputEntry > listSent ; wtx . GetAmounts ( listReceived , listSent , nFee , strSentAccount , filter ) ; bool fAllAccounts = ( strAccount == std :: string ( " " ) ) ; bool involvesWatchonly = wtx . IsFromMe ( ISMINE_WATCH_ONLY ) ; if ( ( ! listSent . empty ( ) || nFee != 0 ) && ( fAllAccounts || strAccount == strSentAccount ) ) { for ( const COutputEntry & s : listSent ) { UniValue entry ( UniValue :: VOBJ ) ; if ( involvesWatchonly || ( :: IsMine ( * pwallet , s . destination ) & ISMINE_WATCH_ONLY ) ) { entry . pushKV ( " " , true ) ; } entry . pushKV ( " " , strSentAccount ) ; MaybePushAddress ( entry , s . destination ) ; entry . pushKV ( " " , " " ) ; entry . pushKV ( " " , ValueFromAmount ( - s . amount ) ) ; if ( pwallet -> mapAddressBook . count ( s . destination ) ) { entry . pushKV ( " " , pwallet -> mapAddressBook [ s . destination ] . name ) ; } entry . pushKV ( " " , s . vout ) ; entry . pushKV ( " " , ValueFromAmount ( - nFee ) ) ; if ( fLong ) WalletTxToJSON ( wtx , entry ) ; entry . pushKV ( " " , wtx . isAbandoned ( ) ) ; ret . push_back ( entry ) ; } } if ( listReceived . size ( ) > 0 && wtx . GetDepthInMainChain ( ) >= nMinDepth ) { for ( const COutputEntry & r : listReceived ) { std :: string account ; if ( pwallet -> mapAddressBook . count ( r . destination ) ) { account = pwallet -> mapAddressBook [ r . destination ] . name ; } if ( fAllAccounts || ( account == strAccount ) ) { UniValue entry ( UniValue :: VOBJ ) ; if ( involvesWatchonly || ( :: IsMine ( * pwallet , r . destination ) & ISMINE_WATCH_ONLY ) ) { entry . pushKV ( " " , true ) ; } entry . pushKV ( " " , account ) ; MaybePushAddress ( entry , r . destination ) ; if ( wtx . IsCoinBase ( ) ) { if ( wtx . GetDepthInMainChain ( ) < 1 ) entry . pushKV ( " " , " " ) ; else if ( wtx . GetBlocksToMaturity ( ) > 0 ) entry . pushKV ( " " , " " ) ; else entry . pushKV ( " " , " " ) ; } else { entry . pushKV ( " " , " " ) ; } entry . pushKV ( " " , ValueFromAmount ( r . amount ) ) ; if ( pwallet -> mapAddressBook . count ( r . destination ) ) { entry . pushKV ( " " , account ) ; } entry . pushKV ( " " , r . vout ) ; if ( fLong ) WalletTxToJSON ( wtx , entry ) ; ret . push_back ( entry ) ; } } } }
List transactions based on the given criteria.
List transactions based on the given criteria .
// Sent // Received