| 473 | } |
| 474 | |
| 475 | static void MutateTxAddOutScript(CMutableTransaction &tx, |
| 476 | const std::string &strInput) { |
| 477 | // separate VALUE:SCRIPT[:FLAGS] |
| 478 | std::vector<std::string> vStrInputParts = SplitString(strInput, ':'); |
| 479 | if (vStrInputParts.size() < 2) { |
| 480 | throw std::runtime_error("TX output missing separator"); |
| 481 | } |
| 482 | |
| 483 | // Extract and validate VALUE |
| 484 | Amount value = ExtractAndValidateValue(vStrInputParts[0]); |
| 485 | |
| 486 | // extract and validate script |
| 487 | const std::string &strScript = vStrInputParts[1]; |
| 488 | CScript scriptPubKey = ParseScript(strScript); |
| 489 | |
| 490 | // Extract FLAGS |
| 491 | bool bScriptHash = false; |
| 492 | if (vStrInputParts.size() == 3) { |
| 493 | const std::string &flags = vStrInputParts.back(); |
| 494 | bScriptHash = (flags.find('S') != std::string::npos); |
| 495 | } |
| 496 | |
| 497 | if (scriptPubKey.size() > MAX_SCRIPT_SIZE) { |
| 498 | throw std::runtime_error(strprintf("script exceeds size limit: %d > %d", |
| 499 | scriptPubKey.size(), |
| 500 | MAX_SCRIPT_SIZE)); |
| 501 | } |
| 502 | |
| 503 | if (bScriptHash) { |
| 504 | if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) { |
| 505 | throw std::runtime_error( |
| 506 | strprintf("redeemScript exceeds size limit: %d > %d", |
| 507 | scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE)); |
| 508 | } |
| 509 | scriptPubKey = GetScriptForDestination(ScriptHash(scriptPubKey)); |
| 510 | } |
| 511 | |
| 512 | // construct TxOut, append to transaction output list |
| 513 | CTxOut txout(value, scriptPubKey); |
| 514 | tx.vout.push_back(txout); |
| 515 | } |
| 516 | |
| 517 | static void MutateTxDelInput(CMutableTransaction &tx, |
| 518 | const std::string &strInIdx) { |
no test coverage detected