MCPcopy Create free account
hub / github.com/ElementsProject/elements / MutateTxAddInput

Function MutateTxAddInput

src/bitcoin-tx.cpp:255–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255static 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
290static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput)
291{

Callers 1

MutateTxFunction · 0.85

Calls 5

ParseHashStrFunction · 0.85
CScriptClass · 0.70
ParseInt64Function · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected