MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / TestBuilder

Method TestBuilder

src/test/script_tests.cpp:324–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322
323public:
324 TestBuilder(const CScript& script_, const std::string& comment_, int 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_), replayMode(REPLAY_NONE)
325 {
326 CScript scriptPubKey = script;
327 if (wm == WitnessMode::PKH) {
328 uint160 hash;
329 CHash160().Write(&script[1], script.size() - 1).Finalize(hash.begin());
330 script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(hash) << OP_EQUALVERIFY << OP_CHECKSIG;
331 scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
332 } else if (wm == WitnessMode::SH) {
333 witscript = scriptPubKey;
334 uint256 hash;
335 CSHA256().Write(&witscript[0], witscript.size()).Finalize(hash.begin());
336 scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
337 }
338 if (P2SH) {
339 redeemscript = scriptPubKey;
340 scriptPubKey = CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemscript)) << OP_EQUAL;
341 }
342 creditTx = MakeTransactionRef(BuildCreditingTransaction(scriptPubKey, nValue));
343 spendTx = BuildSpendingTransaction(CScript(), CScriptWitness(), *creditTx);
344 }
345
346 TestBuilder& ScriptError(ScriptError_t err)
347 {

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected