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