Skip to content

Commit cab8557

Browse files
jonasschnellijnewbery
authored andcommitted
[wallet] [moveonly] Move CAffectedKeysVisitor
1 parent 659c096 commit cab8557

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/wallet/wallet.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,38 @@ std::string COutput::ToString() const
8080
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->tx->vout[i].nValue));
8181
}
8282

83+
class CAffectedKeysVisitor : public boost::static_visitor<void> {
84+
private:
85+
const CKeyStore &keystore;
86+
std::vector<CKeyID> &vKeys;
87+
88+
public:
89+
CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
90+
91+
void Process(const CScript &script) {
92+
txnouttype type;
93+
std::vector<CTxDestination> vDest;
94+
int nRequired;
95+
if (ExtractDestinations(script, type, vDest, nRequired)) {
96+
for (const CTxDestination &dest : vDest)
97+
boost::apply_visitor(*this, dest);
98+
}
99+
}
100+
101+
void operator()(const CKeyID &keyId) {
102+
if (keystore.HaveKey(keyId))
103+
vKeys.push_back(keyId);
104+
}
105+
106+
void operator()(const CScriptID &scriptId) {
107+
CScript script;
108+
if (keystore.GetCScript(scriptId, script))
109+
Process(script);
110+
}
111+
112+
void operator()(const CNoDestination &none) {}
113+
};
114+
83115
const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
84116
{
85117
LOCK(cs_wallet);
@@ -3629,38 +3661,6 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
36293661

36303662
/** @} */ // end of Actions
36313663

3632-
class CAffectedKeysVisitor : public boost::static_visitor<void> {
3633-
private:
3634-
const CKeyStore &keystore;
3635-
std::vector<CKeyID> &vKeys;
3636-
3637-
public:
3638-
CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
3639-
3640-
void Process(const CScript &script) {
3641-
txnouttype type;
3642-
std::vector<CTxDestination> vDest;
3643-
int nRequired;
3644-
if (ExtractDestinations(script, type, vDest, nRequired)) {
3645-
for (const CTxDestination &dest : vDest)
3646-
boost::apply_visitor(*this, dest);
3647-
}
3648-
}
3649-
3650-
void operator()(const CKeyID &keyId) {
3651-
if (keystore.HaveKey(keyId))
3652-
vKeys.push_back(keyId);
3653-
}
3654-
3655-
void operator()(const CScriptID &scriptId) {
3656-
CScript script;
3657-
if (keystore.GetCScript(scriptId, script))
3658-
Process(script);
3659-
}
3660-
3661-
void operator()(const CNoDestination &none) {}
3662-
};
3663-
36643664
void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) const {
36653665
AssertLockHeld(cs_wallet); // mapKeyMetadata
36663666
mapKeyBirth.clear();

0 commit comments

Comments
 (0)