MCPcopy Create free account
hub / github.com/ElementsProject/elements / TestBuilder

Method TestBuilder

src/test/script_tests.cpp:325–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323
324public:
325 TestBuilder(const CScript& script_, const std::string& comment_, uint32_t flags_, bool P2SH = false, WitnessMode wm = WitnessMode::NONE, int witnessversion = 0, CAmount nValue_ = 0) : script(script_), havePush(false), comment(comment_), flags(flags_), scriptError(SCRIPT_ERR_OK), nValue(nValue_)
326 {
327 CScript scriptPubKey = script;
328 if (wm == WitnessMode::PKH) {
329 uint160 hash;
330 CHash160().Write(Span{script}.subspan(1)).Finalize(hash);
331 script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(hash) << OP_EQUALVERIFY << OP_CHECKSIG;
332 scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
333 } else if (wm == WitnessMode::SH) {
334 witscript = scriptPubKey;
335 uint256 hash;
336 CSHA256().Write(witscript.data(), witscript.size()).Finalize(hash.begin());
337 scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
338 }
339 if (P2SH) {
340 redeemscript = scriptPubKey;
341 scriptPubKey = CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemscript)) << OP_EQUAL;
342 }
343 creditTx = MakeTransactionRef(BuildCreditingTransaction(scriptPubKey, nValue));
344 spendTx = BuildSpendingTransaction(CScript(), CScriptWitness(), *creditTx);
345 }
346
347 TestBuilder& ScriptError(ScriptError_t err)
348 {

Callers

nothing calls this directly

Calls 14

CHash160Class · 0.85
ToByteVectorFunction · 0.85
CSHA256Class · 0.85
CScriptIDClass · 0.85
BuildSpendingTransactionFunction · 0.85
CScriptClass · 0.50
MakeTransactionRefFunction · 0.50
CScriptWitnessClass · 0.50
FinalizeMethod · 0.45
WriteMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected