| 146 | } |
| 147 | |
| 148 | CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf, const uint32_t version) |
| 149 | { |
| 150 | CMutableTransaction rawTx; |
| 151 | |
| 152 | if (!locktime.isNull()) { |
| 153 | int64_t nLockTime = locktime.getInt<int64_t>(); |
| 154 | if (nLockTime < 0 || nLockTime > LOCKTIME_MAX) |
| 155 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, locktime out of range"); |
| 156 | rawTx.nLockTime = nLockTime; |
| 157 | } |
| 158 | |
| 159 | if (version < TX_MIN_STANDARD_VERSION || version > TX_MAX_STANDARD_VERSION) { |
| 160 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, version out of range(%d~%d)", TX_MIN_STANDARD_VERSION, TX_MAX_STANDARD_VERSION)); |
| 161 | } |
| 162 | rawTx.version = version; |
| 163 | |
| 164 | AddInputs(rawTx, inputs_in, rbf); |
| 165 | AddOutputs(rawTx, outputs_in); |
| 166 | |
| 167 | if (rbf.has_value() && rbf.value() && rawTx.vin.size() > 0 && !SignalsOptInRBF(CTransaction(rawTx))) { |
| 168 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number(s) contradict replaceable option"); |
| 169 | } |
| 170 | |
| 171 | return rawTx; |
| 172 | } |
| 173 | |
| 174 | /** Pushes a JSON object for script verification or signing errors to vErrorsRet. */ |
| 175 | static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage) |
no test coverage detected