@@ -72,6 +72,53 @@ std::string COutput::ToString() const
7272 return strprintf (" COutput(%s, %d, %d) [%s]" , tx->GetHash ().ToString (), i, nDepth, FormatMoney (tx->tx ->vout [i].nValue ));
7373}
7474
75+ class CAffectedKeysVisitor : public boost ::static_visitor<void >
76+ {
77+ private:
78+ const CKeyStore& keystore;
79+ std::vector<CKeyID>& vKeys;
80+
81+ public:
82+ CAffectedKeysVisitor (const CKeyStore& keystoreIn, std::vector<CKeyID>& vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
83+
84+ void Process (const CScript& script)
85+ {
86+ txnouttype type;
87+ std::vector<CTxDestination> vDest;
88+ int nRequired;
89+ if (ExtractDestinations (script, type, vDest, nRequired)) {
90+ for (const CTxDestination& dest : vDest)
91+ boost::apply_visitor (*this , dest);
92+ }
93+ }
94+
95+ void operator ()(const CKeyID& keyId)
96+ {
97+ if (keystore.HaveKey (keyId))
98+ vKeys.push_back (keyId);
99+ }
100+
101+ void operator ()(const CScriptID& scriptId)
102+ {
103+ CScript script;
104+ if (keystore.GetCScript (scriptId, script))
105+ Process (script);
106+ }
107+
108+ void operator ()(const CNoDestination& none) {}
109+ };
110+
111+ std::vector<CKeyID> CWallet::GetAffectedKeys (const CScript& spk)
112+ {
113+ std::vector<CKeyID> ret;
114+ std::vector<CKeyID> vAffected;
115+ CAffectedKeysVisitor (*this , vAffected).Process (spk);
116+ for (const CKeyID& keyid : vAffected) {
117+ ret.emplace_back (keyid);
118+ }
119+ return ret;
120+ }
121+
75122// //////////////////////////////////////////////////////////////////////////////////////////////////
76123
77124// /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -3977,53 +4024,6 @@ bool CWallet::SetStakeSplitThreshold(const CAmount sst)
39774024
39784025/* * @} */ // end of Actions
39794026
3980- class CAffectedKeysVisitor : public boost ::static_visitor<void >
3981- {
3982- private:
3983- const CKeyStore& keystore;
3984- std::vector<CKeyID>& vKeys;
3985-
3986- public:
3987- CAffectedKeysVisitor (const CKeyStore& keystoreIn, std::vector<CKeyID>& vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
3988-
3989- void Process (const CScript& script)
3990- {
3991- txnouttype type;
3992- std::vector<CTxDestination> vDest;
3993- int nRequired;
3994- if (ExtractDestinations (script, type, vDest, nRequired)) {
3995- for (const CTxDestination& dest : vDest)
3996- boost::apply_visitor (*this , dest);
3997- }
3998- }
3999-
4000- void operator ()(const CKeyID& keyId)
4001- {
4002- if (keystore.HaveKey (keyId))
4003- vKeys.push_back (keyId);
4004- }
4005-
4006- void operator ()(const CScriptID& scriptId)
4007- {
4008- CScript script;
4009- if (keystore.GetCScript (scriptId, script))
4010- Process (script);
4011- }
4012-
4013- void operator ()(const CNoDestination& none) {}
4014- };
4015-
4016- std::vector<CKeyID> CWallet::GetAffectedKeys (const CScript& spk)
4017- {
4018- std::vector<CKeyID> ret;
4019- std::vector<CKeyID> vAffected;
4020- CAffectedKeysVisitor (*this , vAffected).Process (spk);
4021- for (const CKeyID& keyid : vAffected) {
4022- ret.emplace_back (keyid);
4023- }
4024- return ret;
4025- }
4026-
40274027
40284028void CWallet::GetKeyBirthTimes (std::map<CKeyID, int64_t >& mapKeyBirth) const
40294029{
0 commit comments