| 288 | } |
| 289 | |
| 290 | static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput) |
| 291 | { |
| 292 | // Separate into VALUE:ADDRESS |
| 293 | std::vector<std::string> vStrInputParts; |
| 294 | boost::split(vStrInputParts, strInput, boost::is_any_of(":")); |
| 295 | |
| 296 | if (vStrInputParts.size() < 2) |
| 297 | throw std::runtime_error("TX output missing or too many separators"); |
| 298 | |
| 299 | // Extract and validate VALUE |
| 300 | CAmount value = ExtractAndValidateValue(vStrInputParts[0]); |
| 301 | |
| 302 | // extract and validate ADDRESS |
| 303 | std::string strAddr = vStrInputParts[1]; |
| 304 | CTxDestination destination = DecodeDestination(strAddr); |
| 305 | if (!IsValidDestination(destination)) { |
| 306 | throw std::runtime_error("invalid TX output address"); |
| 307 | } |
| 308 | CScript scriptPubKey = GetScriptForDestination(destination); |
| 309 | |
| 310 | // extract and validate ASSET |
| 311 | CAsset asset; |
| 312 | if (!g_con_elementsmode && vStrInputParts.size() == 3) { |
| 313 | throw std::runtime_error("TX output asset type invalid for BITCOIN serialization"); |
| 314 | } |
| 315 | if (vStrInputParts.size() == 3) { |
| 316 | asset = CAsset(uint256S(vStrInputParts[2])); |
| 317 | if (asset.IsNull()) { |
| 318 | throw std::runtime_error("invalid TX output asset type"); |
| 319 | } |
| 320 | } else { |
| 321 | asset = Params().GetConsensus().pegged_asset; |
| 322 | } |
| 323 | |
| 324 | // construct TxOut, append to transaction output list |
| 325 | CTxOut txout(asset, CConfidentialValue(value), scriptPubKey); |
| 326 | tx.vout.push_back(txout); |
| 327 | } |
| 328 | |
| 329 | static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& strInput) |
| 330 | { |
no test coverage detected