| 223 | } |
| 224 | |
| 225 | static void MutateTxRBFOptIn(CMutableTransaction& tx, const std::string& strInIdx) |
| 226 | { |
| 227 | // parse requested index |
| 228 | int64_t inIdx; |
| 229 | if (!ParseInt64(strInIdx, &inIdx) || inIdx < 0 || inIdx >= static_cast<int64_t>(tx.vin.size())) { |
| 230 | throw std::runtime_error("Invalid TX input index '" + strInIdx + "'"); |
| 231 | } |
| 232 | |
| 233 | // set the nSequence to MAX_INT - 2 (= RBF opt in flag) |
| 234 | int cnt = 0; |
| 235 | for (CTxIn& txin : tx.vin) { |
| 236 | if (strInIdx == "" || cnt == inIdx) { |
| 237 | if (txin.nSequence > MAX_BIP125_RBF_SEQUENCE) { |
| 238 | txin.nSequence = MAX_BIP125_RBF_SEQUENCE; |
| 239 | } |
| 240 | } |
| 241 | ++cnt; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | template <typename T> |
| 246 | static T TrimAndParse(const std::string& int_str, const std::string& err) |
no test coverage detected