| 323 | |
| 324 | public: |
| 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 | { |
nothing calls this directly
no test coverage detected