MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ConstructTransaction

Function ConstructTransaction

src/rpc/rawtransaction_util.cpp:148–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148CMutableTransaction 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. */
175static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::string& strMessage)

Callers 5

sendFunction · 0.85
sendallFunction · 0.85
walletcreatefundedpsbtFunction · 0.85
createrawtransactionFunction · 0.85
createpsbtFunction · 0.85

Calls 9

JSONRPCErrorFunction · 0.85
AddInputsFunction · 0.85
AddOutputsFunction · 0.85
SignalsOptInRBFFunction · 0.85
isNullMethod · 0.80
CTransactionClass · 0.50
has_valueMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected