| 253 | } |
| 254 | |
| 255 | static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInput) |
| 256 | { |
| 257 | std::vector<std::string> vStrInputParts; |
| 258 | boost::split(vStrInputParts, strInput, boost::is_any_of(":")); |
| 259 | |
| 260 | // separate TXID:VOUT in string |
| 261 | if (vStrInputParts.size()<2) |
| 262 | throw std::runtime_error("TX input missing separator"); |
| 263 | |
| 264 | // extract and validate TXID |
| 265 | uint256 txid; |
| 266 | if (!ParseHashStr(vStrInputParts[0], txid)) { |
| 267 | throw std::runtime_error("invalid TX input txid"); |
| 268 | } |
| 269 | |
| 270 | static const unsigned int minTxOutSz = 9; |
| 271 | static const unsigned int maxVout = MAX_BLOCK_WEIGHT / (WITNESS_SCALE_FACTOR * minTxOutSz); |
| 272 | |
| 273 | // extract and validate vout |
| 274 | const std::string& strVout = vStrInputParts[1]; |
| 275 | int64_t vout; |
| 276 | if (!ParseInt64(strVout, &vout) || vout < 0 || vout > static_cast<int64_t>(maxVout)) |
| 277 | throw std::runtime_error("invalid TX input vout '" + strVout + "'"); |
| 278 | |
| 279 | // extract the optional sequence number |
| 280 | uint32_t nSequenceIn = CTxIn::SEQUENCE_FINAL; |
| 281 | if (vStrInputParts.size() > 2) { |
| 282 | nSequenceIn = TrimAndParse<uint32_t>(vStrInputParts.at(2), "invalid TX sequence id"); |
| 283 | } |
| 284 | |
| 285 | // append to transaction input list |
| 286 | CTxIn txin(txid, vout, CScript(), nSequenceIn); |
| 287 | tx.vin.push_back(txin); |
| 288 | } |
| 289 | |
| 290 | static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput) |
| 291 | { |
no test coverage detected