| 293 | } |
| 294 | |
| 295 | static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput) |
| 296 | { |
| 297 | // Separate into VALUE:ADDRESS |
| 298 | std::vector<std::string> vStrInputParts = SplitString(strInput, ':'); |
| 299 | |
| 300 | if (vStrInputParts.size() != 2) |
| 301 | throw std::runtime_error("TX output missing or too many separators"); |
| 302 | |
| 303 | // Extract and validate VALUE |
| 304 | CAmount value = ExtractAndValidateValue(vStrInputParts[0]); |
| 305 | |
| 306 | // extract and validate ADDRESS |
| 307 | const std::string& strAddr = vStrInputParts[1]; |
| 308 | CTxDestination destination = DecodeDestination(strAddr); |
| 309 | if (!IsValidDestination(destination)) { |
| 310 | throw std::runtime_error("invalid TX output address"); |
| 311 | } |
| 312 | CScript scriptPubKey = GetScriptForDestination(destination); |
| 313 | |
| 314 | // construct TxOut, append to transaction output list |
| 315 | CTxOut txout(value, scriptPubKey); |
| 316 | tx.vout.push_back(txout); |
| 317 | } |
| 318 | |
| 319 | static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& strInput) |
| 320 | { |
no test coverage detected