From 8b59a3d36626085db79db2874ae76272b2b42f25 Mon Sep 17 00:00:00 2001 From: jtimon Date: Wed, 27 Aug 2014 17:46:30 +0200 Subject: Move CAffectedKeysVisitor to wallet.cpp (remove ExtractAffectedKeys) --- src/scriptutils.cpp | 36 ------------------------------------ src/scriptutils.h | 1 - src/wallet.cpp | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/scriptutils.cpp b/src/scriptutils.cpp index a636eeedab..5099d7515a 100644 --- a/src/scriptutils.cpp +++ b/src/scriptutils.cpp @@ -89,39 +89,3 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey) return ISMINE_WATCH_ONLY; return ISMINE_NO; } - -class CAffectedKeysVisitor : public boost::static_visitor { -private: - const CKeyStore &keystore; - std::vector &vKeys; - -public: - CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} - - void Process(const CScript &script) { - txnouttype type; - std::vector vDest; - int nRequired; - if (ExtractDestinations(script, type, vDest, nRequired)) { - BOOST_FOREACH(const CTxDestination &dest, vDest) - boost::apply_visitor(*this, dest); - } - } - - void operator()(const CKeyID &keyId) { - if (keystore.HaveKey(keyId)) - vKeys.push_back(keyId); - } - - void operator()(const CScriptID &scriptId) { - CScript script; - if (keystore.GetCScript(scriptId, script)) - Process(script); - } - - void operator()(const CNoDestination &none) {} -}; - -void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector &vKeys) { - CAffectedKeysVisitor(keystore, vKeys).Process(scriptPubKey); -} diff --git a/src/scriptutils.h b/src/scriptutils.h index 98080fc456..4e98a1f74f 100644 --- a/src/scriptutils.h +++ b/src/scriptutils.h @@ -24,6 +24,5 @@ typedef uint8_t isminefilter; isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest); -void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector &vKeys); #endif // H_BITCOIN_SCRIPT diff --git a/src/wallet.cpp b/src/wallet.cpp index 218a137966..52660be9a0 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2086,6 +2086,39 @@ void CWallet::ListLockedCoins(std::vector& vOutpts) } } + +class CAffectedKeysVisitor : public boost::static_visitor { +private: + const CKeyStore &keystore; + std::vector &vKeys; + +public: + CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} + + void Process(const CScript &script) { + txnouttype type; + std::vector vDest; + int nRequired; + if (ExtractDestinations(script, type, vDest, nRequired)) { + BOOST_FOREACH(const CTxDestination &dest, vDest) + boost::apply_visitor(*this, dest); + } + } + + void operator()(const CKeyID &keyId) { + if (keystore.HaveKey(keyId)) + vKeys.push_back(keyId); + } + + void operator()(const CScriptID &scriptId) { + CScript script; + if (keystore.GetCScript(scriptId, script)) + Process(script); + } + + void operator()(const CNoDestination &none) {} +}; + void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { AssertLockHeld(cs_wallet); // mapKeyMetadata mapKeyBirth.clear(); @@ -2121,7 +2154,7 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { int nHeight = blit->second->nHeight; BOOST_FOREACH(const CTxOut &txout, wtx.vout) { // iterate over all their outputs - ::ExtractAffectedKeys(*this, txout.scriptPubKey, vAffected); + CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); BOOST_FOREACH(const CKeyID &keyid, vAffected) { // ... and all their affected keys std::map::iterator rit = mapKeyFirstBlock.find(keyid); -- cgit v1.2.3