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

Method TestBuilder

src/test/script_tests.cpp:255–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254public:
255 TestBuilder(const CScript& script_, const std::string& comment_, script_verify_flags flags_, bool P2SH = false, WitnessMode wm = WitnessMode::NONE, int witnessversion = 0, CAmount nValue_ = 0) : script(script_), comment(comment_), flags(flags_), nValue(nValue_)
256 {
257 CScript scriptPubKey = script;
258 if (wm == WitnessMode::PKH) {
259 uint160 hash;
260 CHash160().Write(std::span{script}.subspan(1)).Finalize(hash);
261 script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(hash) << OP_EQUALVERIFY << OP_CHECKSIG;
262 scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
263 } else if (wm == WitnessMode::SH) {
264 witscript = scriptPubKey;
265 uint256 hash;
266 CSHA256().Write(witscript.data(), witscript.size()).Finalize(hash.begin());
267 scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
268 }
269 if (P2SH) {
270 redeemscript = scriptPubKey;
271 scriptPubKey = CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemscript)) << OP_EQUAL;
272 }
273 creditTx = MakeTransactionRef(BuildCreditingTransaction(scriptPubKey, nValue));
274 spendTx = BuildSpendingTransaction(CScript(), CScriptWitness(), *creditTx);
275 }
276
277 TestBuilder& ScriptError(ScriptError_t err)
278 {

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected