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

Function MutateTxAddOutAddr

src/bitcoin-tx.cpp:290–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290static void MutateTxAddOutAddr(CMutableTransaction& tx, const std::string& strInput)
291{
292 // Separate into VALUE:ADDRESS
293 std::vector<std::string> vStrInputParts;
294 boost::split(vStrInputParts, strInput, boost::is_any_of(":"));
295
296 if (vStrInputParts.size() < 2)
297 throw std::runtime_error("TX output missing or too many separators");
298
299 // Extract and validate VALUE
300 CAmount value = ExtractAndValidateValue(vStrInputParts[0]);
301
302 // extract and validate ADDRESS
303 std::string strAddr = vStrInputParts[1];
304 CTxDestination destination = DecodeDestination(strAddr);
305 if (!IsValidDestination(destination)) {
306 throw std::runtime_error("invalid TX output address");
307 }
308 CScript scriptPubKey = GetScriptForDestination(destination);
309
310 // extract and validate ASSET
311 CAsset asset;
312 if (!g_con_elementsmode && vStrInputParts.size() == 3) {
313 throw std::runtime_error("TX output asset type invalid for BITCOIN serialization");
314 }
315 if (vStrInputParts.size() == 3) {
316 asset = CAsset(uint256S(vStrInputParts[2]));
317 if (asset.IsNull()) {
318 throw std::runtime_error("invalid TX output asset type");
319 }
320 } else {
321 asset = Params().GetConsensus().pegged_asset;
322 }
323
324 // construct TxOut, append to transaction output list
325 CTxOut txout(asset, CConfidentialValue(value), scriptPubKey);
326 tx.vout.push_back(txout);
327}
328
329static void MutateTxAddOutPubKey(CMutableTransaction& tx, const std::string& strInput)
330{

Callers 1

MutateTxFunction · 0.85

Calls 11

ExtractAndValidateValueFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
GetScriptForDestinationFunction · 0.85
CAssetClass · 0.85
uint256SFunction · 0.85
CConfidentialValueClass · 0.85
ParamsClass · 0.70
sizeMethod · 0.45
IsNullMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected