@@ -239,59 +239,47 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::
239
239
240
240
namespace
241
241
{
242
- class CScriptVisitor : public boost ::static_visitor<bool >
242
+ class CScriptVisitor : public boost ::static_visitor<CScript >
243
243
{
244
- private:
245
- CScript *script;
246
244
public:
247
- explicit CScriptVisitor (CScript *scriptin) { script = scriptin; }
248
-
249
- bool operator ()(const CNoDestination &dest) const {
250
- script->clear ();
251
- return false ;
245
+ CScript operator ()(const CNoDestination& dest) const
246
+ {
247
+ return CScript ();
252
248
}
253
249
254
- bool operator ()(const PKHash &keyID) const {
255
- script->clear ();
256
- *script << OP_DUP << OP_HASH160 << ToByteVector (keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
257
- return true ;
250
+ CScript operator ()(const PKHash& keyID) const
251
+ {
252
+ return CScript () << OP_DUP << OP_HASH160 << ToByteVector (keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
258
253
}
259
254
260
- bool operator ()(const ScriptHash &scriptID) const {
261
- script->clear ();
262
- *script << OP_HASH160 << ToByteVector (scriptID) << OP_EQUAL;
263
- return true ;
255
+ CScript operator ()(const ScriptHash& scriptID) const
256
+ {
257
+ return CScript () << OP_HASH160 << ToByteVector (scriptID) << OP_EQUAL;
264
258
}
265
259
266
- bool operator ()(const WitnessV0KeyHash& id) const
260
+ CScript operator ()(const WitnessV0KeyHash& id) const
267
261
{
268
- script->clear ();
269
- *script << OP_0 << ToByteVector (id);
270
- return true ;
262
+ return CScript () << OP_0 << ToByteVector (id);
271
263
}
272
264
273
- bool operator ()(const WitnessV0ScriptHash& id) const
265
+ CScript operator ()(const WitnessV0ScriptHash& id) const
274
266
{
275
- script->clear ();
276
- *script << OP_0 << ToByteVector (id);
277
- return true ;
267
+ return CScript () << OP_0 << ToByteVector (id);
278
268
}
279
269
280
- bool operator ()(const WitnessUnknown& id) const
270
+ CScript operator ()(const WitnessUnknown& id) const
281
271
{
282
- script->clear ();
283
- *script << CScript::EncodeOP_N (id.version ) << std::vector<unsigned char >(id.program , id.program + id.length );
284
- return true ;
272
+ return CScript () << CScript::EncodeOP_N (id.version ) << std::vector<unsigned char >(id.program , id.program + id.length );
285
273
}
286
274
};
275
+
276
+ const CScriptVisitor g_script_visitor;
277
+
287
278
} // namespace
288
279
289
280
CScript GetScriptForDestination (const CTxDestination& dest)
290
281
{
291
- CScript script;
292
-
293
- boost::apply_visitor (CScriptVisitor (&script), dest);
294
- return script;
282
+ return boost::apply_visitor (::g_script_visitor, dest);
295
283
}
296
284
297
285
CScript GetScriptForRawPubKey (const CPubKey& pubKey)
0 commit comments