Skip to content

Commit eca0b1e

Browse files
committed
Includes: MOVEONLY: move more method definitions out of wallet.h
1 parent 26c16d9 commit eca0b1e

File tree

2 files changed

+76
-60
lines changed

2 files changed

+76
-60
lines changed

src/wallet/wallet.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,18 @@ CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
817817
return 0;
818818
}
819819

820+
isminetype CWallet::IsMine(const CTxOut& txout) const
821+
{
822+
return ::IsMine(*this, txout.scriptPubKey);
823+
}
824+
825+
CAmount CWallet::GetCredit(const CTxOut& txout, const isminefilter& filter) const
826+
{
827+
if (!MoneyRange(txout.nValue))
828+
throw std::runtime_error("CWallet::GetCredit(): value out of range");
829+
return ((IsMine(txout) & filter) ? txout.nValue : 0);
830+
}
831+
820832
bool CWallet::IsChange(const CTxOut& txout) const
821833
{
822834
// TODO: fix handling of 'change' outputs. The assumption is that any
@@ -839,6 +851,62 @@ bool CWallet::IsChange(const CTxOut& txout) const
839851
return false;
840852
}
841853

854+
CAmount CWallet::GetChange(const CTxOut& txout) const
855+
{
856+
if (!MoneyRange(txout.nValue))
857+
throw std::runtime_error("CWallet::GetChange(): value out of range");
858+
return (IsChange(txout) ? txout.nValue : 0);
859+
}
860+
861+
bool CWallet::IsMine(const CTransaction& tx) const
862+
{
863+
BOOST_FOREACH(const CTxOut& txout, tx.vout)
864+
if (IsMine(txout))
865+
return true;
866+
return false;
867+
}
868+
869+
bool CWallet::IsFromMe(const CTransaction& tx) const
870+
{
871+
return (GetDebit(tx, ISMINE_ALL) > 0);
872+
}
873+
874+
CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const
875+
{
876+
CAmount nDebit = 0;
877+
BOOST_FOREACH(const CTxIn& txin, tx.vin)
878+
{
879+
nDebit += GetDebit(txin, filter);
880+
if (!MoneyRange(nDebit))
881+
throw std::runtime_error("CWallet::GetDebit(): value out of range");
882+
}
883+
return nDebit;
884+
}
885+
886+
CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const
887+
{
888+
CAmount nCredit = 0;
889+
BOOST_FOREACH(const CTxOut& txout, tx.vout)
890+
{
891+
nCredit += GetCredit(txout, filter);
892+
if (!MoneyRange(nCredit))
893+
throw std::runtime_error("CWallet::GetCredit(): value out of range");
894+
}
895+
return nCredit;
896+
}
897+
898+
CAmount CWallet::GetChange(const CTransaction& tx) const
899+
{
900+
CAmount nChange = 0;
901+
BOOST_FOREACH(const CTxOut& txout, tx.vout)
902+
{
903+
nChange += GetChange(txout);
904+
if (!MoneyRange(nChange))
905+
throw std::runtime_error("CWallet::GetChange(): value out of range");
906+
}
907+
return nChange;
908+
}
909+
842910
int64_t CWalletTx::GetTxTime() const
843911
{
844912
int64_t n = nTimeSmart;

src/wallet/wallet.h

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -641,68 +641,16 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
641641

642642
isminetype IsMine(const CTxIn& txin) const;
643643
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
644-
isminetype IsMine(const CTxOut& txout) const
645-
{
646-
return ::IsMine(*this, txout.scriptPubKey);
647-
}
648-
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const
649-
{
650-
if (!MoneyRange(txout.nValue))
651-
throw std::runtime_error("CWallet::GetCredit(): value out of range");
652-
return ((IsMine(txout) & filter) ? txout.nValue : 0);
653-
}
644+
isminetype IsMine(const CTxOut& txout) const;
645+
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
654646
bool IsChange(const CTxOut& txout) const;
655-
CAmount GetChange(const CTxOut& txout) const
656-
{
657-
if (!MoneyRange(txout.nValue))
658-
throw std::runtime_error("CWallet::GetChange(): value out of range");
659-
return (IsChange(txout) ? txout.nValue : 0);
660-
}
661-
bool IsMine(const CTransaction& tx) const
662-
{
663-
BOOST_FOREACH(const CTxOut& txout, tx.vout)
664-
if (IsMine(txout))
665-
return true;
666-
return false;
667-
}
647+
CAmount GetChange(const CTxOut& txout) const;
648+
bool IsMine(const CTransaction& tx) const;
668649
/** should probably be renamed to IsRelevantToMe */
669-
bool IsFromMe(const CTransaction& tx) const
670-
{
671-
return (GetDebit(tx, ISMINE_ALL) > 0);
672-
}
673-
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const
674-
{
675-
CAmount nDebit = 0;
676-
BOOST_FOREACH(const CTxIn& txin, tx.vin)
677-
{
678-
nDebit += GetDebit(txin, filter);
679-
if (!MoneyRange(nDebit))
680-
throw std::runtime_error("CWallet::GetDebit(): value out of range");
681-
}
682-
return nDebit;
683-
}
684-
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const
685-
{
686-
CAmount nCredit = 0;
687-
BOOST_FOREACH(const CTxOut& txout, tx.vout)
688-
{
689-
nCredit += GetCredit(txout, filter);
690-
if (!MoneyRange(nCredit))
691-
throw std::runtime_error("CWallet::GetCredit(): value out of range");
692-
}
693-
return nCredit;
694-
}
695-
CAmount GetChange(const CTransaction& tx) const
696-
{
697-
CAmount nChange = 0;
698-
BOOST_FOREACH(const CTxOut& txout, tx.vout)
699-
{
700-
nChange += GetChange(txout);
701-
if (!MoneyRange(nChange))
702-
throw std::runtime_error("CWallet::GetChange(): value out of range");
703-
}
704-
return nChange;
705-
}
650+
bool IsFromMe(const CTransaction& tx) const;
651+
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;
652+
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const;
653+
CAmount GetChange(const CTransaction& tx) const;
706654
void SetBestChain(const CBlockLocator& loc);
707655

708656
DBErrors LoadWallet(bool& fFirstRunRet);

0 commit comments

Comments
 (0)