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