| 406 | } |
| 407 | |
| 408 | static void MutateTxAddOutData(CMutableTransaction& tx, const std::string& strInput) |
| 409 | { |
| 410 | CAmount value = 0; |
| 411 | |
| 412 | // separate [VALUE:]DATA in string |
| 413 | size_t pos = strInput.find(':'); |
| 414 | |
| 415 | if (pos==0) |
| 416 | throw std::runtime_error("TX output value not specified"); |
| 417 | |
| 418 | if (pos != std::string::npos) { |
| 419 | // Extract and validate VALUE |
| 420 | value = ExtractAndValidateValue(strInput.substr(0, pos)); |
| 421 | } |
| 422 | |
| 423 | // extract and validate DATA |
| 424 | std::string strData = strInput.substr(pos + 1, std::string::npos); |
| 425 | |
| 426 | if (!IsHex(strData)) |
| 427 | throw std::runtime_error("invalid TX output data"); |
| 428 | |
| 429 | std::vector<unsigned char> data = ParseHex(strData); |
| 430 | |
| 431 | CTxOut txout(value, CScript() << OP_RETURN << data); |
| 432 | tx.vout.push_back(txout); |
| 433 | } |
| 434 | |
| 435 | static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& strInput) |
| 436 | { |